Distillation
Training smaller students from teacher model outputs to cut cost while keeping behavior.
In plain words
A big smart model teaches a small model by showing it lots of good answers, so the small one can do the job cheaply.
Think of it like…
An expert tutor writes worked solutions with reasoning for hundreds of practice problems, and a student studies those, learning the tutor's patterns rather than rediscovering them. The student won't match the tutor everywhere, but on the exam topics they practised they can come close, much faster.
Where you’ve seen it
A fintech classifies 30 million transactions a month into 40 categories. Using a frontier model costs about $18,000 a month with 900 ms latency. They have the frontier model label 200,000 diverse transactions (plus a short rationale), filter by agreement with a second pass, and fine-tune a 3B student on the 160,000 clean labels. On a human-labelled test set the student scores 94.2 percent versus the teacher's 95.8, runs in 60 ms on one GPU, and cuts the monthly cost by about 90 percent.
Words you’ll hear
- Teacher / student
- The large source model and the smaller model being trained to imitate it.
- Soft labels
- The teacher's full probability distribution over outputs, used as the training target.
- Sequence-level distillation
- Training the student on text the teacher generated, rather than on probabilities.
- Synthetic data
- Training examples generated by a model instead of collected from users.
Visual diagram
Theory & deep dive
Soft labels and sequence-level distillation
In the original formulation, the student is trained to match the teacher's output distribution, softened with a temperature so the relative probabilities of wrong answers stay visible: a teacher that says "cat 0.7, dog 0.25, truck 0.001" teaches that dogs are more cat-like than trucks. The loss is typically a mix of cross-entropy to the true label and KL divergence to the teacher distribution. This needs access to the teacher's logits and the same or a compatible tokenizer, which you often don't have with API-only models.
With closed models you only see text, so practitioners use sequence-level distillation: generate a large, diverse set of prompts, collect the teacher's answers (including step-by-step rationales if you want the student to reason), filter for quality, and fine-tune the student with ordinary supervised learning. Self-consistency or two-model agreement filters remove noisy labels. The same recipe builds task-specific small models, and larger reasoning models are often distilled into smaller ones by training on their reasoning traces.
Ask the teacher to label each input twice with different prompts. Keep only the examples where both labels agree (about 80% in the fintech case) and send the disagreements to human review; they're often the hard or ambiguous cases worth annotating properly.
Evaluation, limits and rules of the road
Evaluate the student on a human-labelled test set the teacher never touched, sliced by class, language and difficulty, and compare with both the teacher and a strong baseline such as the small model with a good prompt. The student rarely matches the teacher outside its training distribution, so monitor production inputs for drift and route low-confidence or out-of-distribution cases back to the teacher (a cascade). Errors the teacher makes are copied by the student, so teacher quality caps student quality on the task.
Check legal terms: some providers' terms prohibit using model outputs to train competing models, while open-weight licences vary; confirm what is permitted for your teacher and your use. Also consider privacy when generating data from real user inputs. Distillation is most attractive for high-volume, narrow, stable tasks; for open-ended or rapidly changing work, prompting a strong model or using RAG is usually simpler.
Serve the student first. If its top-class probability is below 0.8 (about 9% of traffic), call the teacher instead and log the case for the next training round. Overall accuracy approaches the teacher's at roughly a fifth of its cost.
How it works, step by step
Step 1 of 41. Define the narrow task and test set
Pick a high-volume, stable task and create a human-labelled evaluation set before generating any data.
- Test set
- independent of teacher
When to use it & trade-offs
What it is
Distillation trains a smaller student model to imitate a larger teacher. Classic distillation matches the teacher's full output probabilities (soft labels), which carry more information than a single right answer: they show which wrong answers were nearly right. For LLMs, the common practical form is sequence-level distillation: have the teacher generate high-quality responses (and reasoning) for many prompts, then fine-tune the student on those outputs. The goal is to keep most of the quality on a defined task at a fraction of the latency and cost.
Why it matters: Frontier models are expensive and slow, and many production tasks (classifying tickets, extracting fields, routing, summarising in a fixed style) don't need that power at every call. A distilled small model can serve millions of requests cheaply, run on your own hardware and meet tight latency budgets. Knowing the workflow, the legal caveats and how to evaluate the student is what makes this practical rather than a research idea.
When to reach for it
- Classification, extraction and routing at high volume
- Cutting latency for real-time features
- Creating on-device or self-hosted models
When to avoid or be careful
- Evaluating the student only on teacher-labelled data
- Distilling open-ended, fast-changing tasks
- Ignoring the teacher model's terms of use
Getting a cheaper model for a task
Strengths: Big cost and latency cuts; full control of the model.
Watch out: Data and training effort; student below teacher; licence checks.
Strengths: No training.
Watch out: Usually lower accuracy than a distilled model on the task.
Strengths: Preserves capability.
Watch out: Higher cost and latency than a small student.
Interview signals & numbers to know
When this topic comes up
- “Our LLM bill is too high for a simple classification task”
- “How do you train a small model from a bigger one?”
- “Reasoning model distillation”
- Synthetic data pipelines
- Model cascades
Benchmarks & rules of thumb
- ≈ 90%
- cost reduction in the fintech example
- 94.2% vs 95.8%
- student vs teacher accuracy
- 900 ms → 60 ms
- latency before and after
Common mistakes & follow-ups
Common interview mistakes
- Using the teacher's outputs as the test set, which only measures agreement with the teacher.
- Generating training data from a narrow slice of traffic, so the student fails on rare classes.
- Distilling without checking whether the provider's terms allow training on its outputs.
Likely interviewer follow-ups
- How would you distil a frontier model into a small classifier?
- Why do soft labels help the student?
- How would you keep quality high when the student is unsure?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Distillation with generative AI interview Q&A and hands-on practice.