Note: This is an experimental fine-tuning attempt for research purposes. The dataset and model are designed to simulate students with mathematical misconceptions.
This project fine-tunes Qwen3-8B using LoRA to simulate struggling students in mathematics. Based on the methodology from:
- Sonkar et al. (2024): "LLM-based Cognitive Models of Students with Misconceptions"
- MisstepMath dataset from Hugging Face
student_simulation_dataset/
├── scripts/ # Data processing scripts
│ ├── 01_data_acquisition.py # Download MisstepMath
│ ├── 02_data_filtering.py # Filter K6-K8 samples
│ ├── 03_llm_augmentation.py # Two-stage LLM generation
│ ├── 04_build_final_dataset.py
│ ├── 05_convert_to_mlx_format.py
│ └── 06_adjust_ratio.py # Adjust misconception ratio
├── data/
│ ├── final/ # Alpaca format dataset
│ └── mlx/ # MLX training format
├── models/
│ └── Qwen3-8B/ # Base model (downloaded)
├── adapters/
│ └── qwen3-student/ # Trained LoRA adapters
├── train.sh # Training script
├── test_model.sh # Single test
└── compare_models.sh # Compare base vs fine-tuned
./train.shThis will:
- Download Qwen3-8B if not present (~16GB)
- Fine-tune using LoRA (600 iterations)
- Save adapters to
./adapters/qwen3-student/
# Single test
./test_model.sh "Calculate: 1/2 + 1/3 = ?"
# Compare base vs fine-tuned
./compare_models.sh| Metric | Value |
|---|---|
| Total Samples | 1,069 |
| Training Set | 1,069 |
| Validation Set | 149 |
| Test Set | 151 |
| Misconception Ratio | 85% |
| Parameter | Value |
|---|---|
| Base Model | Qwen3-8B |
| Method | LoRA |
| Framework | MLX-LM |
| Iterations | 600 |
| Batch Size | 1 |
| LoRA Layers | 8 |
| Learning Rate | 1e-5 |
| Max Seq Length | 1280 |
The fine-tuned model successfully learned:
- ✅ Overconfidence (refuses to check answers)
- ✅ Natural spoken language style
- ✅ Shorter, more direct responses
⚠️ Calculation errors (~37% of tests)⚠️ Conceptual confusions (~25% of tests)
Best checkpoint: Iteration 400 (Val Loss: 1.174)
{"text": "<|im_start|>system\nYou are a student with difficulties...<|im_end|>\n<|im_start|>user\nMath problem<|im_end|>\n<|im_start|>assistant\nStudent response<|im_end|>"}{
"instruction": "You are a 6th grade student with procedural difficulties...",
"input": "Solve: x + 5 = 10",
"output": "Hmm, let me think... (shows error patterns)"
}- macOS with Apple Silicon (M1/M2/M3)
- Python 3.10+
- 32GB+ RAM recommended
- MLX-LM (
pip install mlx-lm)
MIT License
@article{sonkar2024llm,
title={LLM-based Cognitive Models of Students with Misconceptions},
author={Sonkar, Shashank and others},
year={2024}
}