Distilling a Large Model into a Small One

Shrinking a big model's skill into a small, cheap one.

🔴 advanced5 min readefficiency
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 LCE\mathcal{L}_{CE} and soft teacher KL Divergence LKL\mathcal{L}_{KL}:

Ldistill=(1−α)LCE(y,σ(zS))+αT2DKL(σ(zTT)∥σ(zST))\mathcal{L}_{\text{distill}} = (1 - \alpha) \mathcal{L}_{CE}(y, \sigma(z_S)) + \alpha T^2 D_{KL}\left( \sigma\left(\frac{z_T}{T}\right) \parallel \sigma\left(\frac{z_S}{T}\right) \right)

Distillation vs Quantization vs Pruning

Efficiency TechniqueMechanicsAccuracy ImpactBest Used For
DistillationTrains a small model to mimic a large teacherPreserves high task performanceSpecialized task adaptation (8B replacement)
QuantizationLowers weight precision (FP16 →\to INT4)<1%< 1\% drop (AWQ)General inference VRAM reduction
Structured PruningRemoves entire attention heads / FFN layersModerate dropShrinking 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

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?

More in LLMs & GenAI

See all →
Pretraining → SFT → RLHF5 minFine-Tune vs RAG vs Prompt: Choosing5 minRetrieval-Augmented Generation5 min