Distilling a Large Model into a Small One
Shrinking a big model's skill into a small, cheap one.
Distillation trains a small, cheap student model to copy a large, expensive teacher model. The classic way trains the student to match the teacher's full spread of probabilities over possible answers, not just its top answer, because that spread carries extra information about how the teacher thinks. With modern language models the common way is simpler: have the teacher write lots of high-quality answers and step-by-step reasoning, then fine-tune the student on that text. You keep much of the quality at a fraction of the cost.
Two Forms of Model Distillation
1. CLASSIC LOGIT DISTILLATION (Hinton et al., 2015)
Teacher Model ──► Softmax Logits P_T (T=5.0) ──┐
├──► Minimize KL Divergence D_KL(P_T || P_S)
Student Model ──► Softmax Logits P_S (T=5.0) ──┘ (Transfers "Dark Knowledge")
2. LLM SEQUENCE DISTILLATION (Synthetic Instruction Tuning)
Frontier Teacher (GPT-4o) ──► Generates 100k Synthetic Reasoning Chains ──► SFT Fine-Tune 8B Student
Hinton Logit Distillation Loss
Total Loss combines hard target Cross-Entropy and soft teacher KL Divergence :
- : Raw logits from Teacher and Student.
- : Temperature parameter () that softens output probabilities to reveal dark knowledge correlations.
- multiplier balances gradient scales.
Distillation vs Quantization vs Pruning
| Efficiency Technique | Mechanics | Accuracy Impact | Best Used For |
|---|---|---|---|
| Distillation | Trains a small model to mimic a large teacher | Preserves high task performance | Specialized task adaptation (8B replacement) |
| Quantization | Lowers weight precision (FP16 INT4) | drop (AWQ) | General inference VRAM reduction |
| Structured Pruning | Removes entire attention heads / FFN layers | Moderate drop | Shrinking layer depth of existing models |
Say this out loud
"Model Distillation transfers knowledge from a large teacher to a small student. Classic Logit Distillation minimizes KL divergence between soft teacher and student logits at high temperature to transfer 'dark knowledge'. In modern GenAI, Sequence Distillation uses frontier models like GPT-4o to generate synthetic reasoning chains for fine-tuning 8B models, delivering 50x lower serving cost."
Follow-ups to expect
- What is On-Policy Distillation (MiniLLM / GDKD)? Standard sequence distillation suffers from exposure bias when the student model drifts from teacher trajectories. On-policy distillation samples outputs directly from the student and evaluates student trajectory probabilities against the teacher model.
- What is Speculative Decoding via Distillation? Fine-tuning a 1B draft model directly on target 70B model logit distributions to maximize draft token acceptance rates during speculative execution.
Check yourself
Question 1 of 3
Why does Hinton's classic Logit Distillation minimize KL divergence between teacher Softmax logits P_T and student Softmax logits P_S?