smol-math-dpo-merged
yas1988/smol-math-sft-merged (SmolLM2-1.7B fine-tuned for math with SFT + LoRA) further aligned with Direct Preference Optimization (DPO), then merged into the base weights.
Model Details
- Developed by: yas1988
- Model type: causal language model (Llama architecture)
- Language: English
- License: Apache 2.0 (same as SmolLM2)
- Finetuned from: yas1988/smol-math-sft-merged
- Part of: Hugging Face smol course, Unit 2 (Preference Alignment) submission
How to use
from transformers import pipeline
pipe = pipeline("text-generation", model="yas1988/smol-math-dpo-merged", device_map="auto")
msgs = [{"role": "user", "content": "Tom has 5 apples and buys 3 more. How many does he have?"}]
print(pipe(msgs, max_new_tokens=200, return_full_text=False)[0]["generated_text"])
Training Details
Pipeline: SmolLM2-1.7B -> SFT on MetaMathQA (Unit 1) -> DPO (this model).
- Method: DPO with LoRA (TRL
DPOTrainer), adapter merged into the weights afterwards - Preference data: first 3,000 samples of
trl-lib/ultrafeedback_binarized(chosen/rejected pairs) - LoRA: r=16, alpha=32, dropout 0.05, target modules
all-linear - Hyperparameters: beta 0.1, learning rate 2e-5, 1 epoch (172 steps), per-device batch 1 x gradient accumulation 16 (effective batch 16), fp16, gradient checkpointing, max length 512
- Hardware: one Colab T4 GPU, about 42 minutes
- Training loss: 0.692 -> about 0.64 (starts near ln 2 = 0.693, as expected for DPO)
- Final reward metrics: accuracy 0.54, margin 0.015
- End-of-sequence token:
<|im_end|>, so generation stops after the answer
Evaluation
Results dataset: yas1988/details_yas1988__smol-math-dpo-merged_private
| Task | Metric | Score |
|---|---|---|
| GSM8K (0-shot) | extractive_match | 0.4375 ± 0.0137 (SFT model: 0.4268 ± 0.0136) |
| ARC-Challenge (0-shot) | acc | 0.3567 ± 0.0140 |
| TruthfulQA (0-shot) | mc1 / mc2 | 0.2644 / 0.3950 |
GSM8K stayed within noise of the SFT model, so DPO preserved the math ability.
Evaluation command (Colab T4, lighteval accelerate with batch size 1 to avoid out-of-memory errors; batch_size=1 was needed for TruthfulQA):
lighteval accelerate \
"model_name=yas1988/smol-math-dpo-merged,dtype=float16,batch_size=1" \
"truthfulqa:mc|0,arc:challenge|0,gsm8k|0" \
--push-to-hub --results-org yas1988
Limitations
- DPO ran on a 3,000-sample subset for one epoch, so the change from the SFT model is modest (reward margin 0.015).
- The preference data is general-purpose chat data, not math, so GSM8K stays about the same (0.4375 vs 0.4268, within noise).
- Small model: it can make factual and arithmetic mistakes, so don't use it where a wrong answer matters.