What Is Knowledge Distillation? Teacher and Student LLMs
By LatestLLM Editorial · Published · Facts verified · 7 min read
Also called: knowledge distillation, model distillation, teacher-student, soft targets, distilled model
Before this: Pre-training and loss, Next-token prediction
In one line
Distillation is training a small student model to imitate a larger teacher, using the teacher's output probabilities or generated text as targets instead of only the correct answers.
Distillation, simply and technically
In plain English
A very large model is expensive to run, so it is often worth teaching a smaller model to imitate it. A student that only sees right and wrong answers learns slowly. A student that also sees the teacher's reasoning learns faster, because the teacher's answers carry extra information: not just which word is right, but which wrong words are almost right and which are absurd.
That extra information, passed from a big model to a small one, is called distillation. It is how many small, fast models are produced, including smaller versions of well-known reasoning models.
Think of it like this: Distillation is like a master chef coaching an apprentice. A cookbook says only the final recipe, the right answer. The chef also says “this is almost right, add a little more salt, but never vinegar”, which tells the apprentice how close each wrong choice is. The apprentice never becomes better than the master by this method alone, and the comparison fails there: a student can sometimes match the teacher on a narrow task but typically trails it on everything else.
Everyday example: Almost right, completely wrong
A model must predict the word after “The capital of France is”. The right label is “Paris”.
Input:
Hard label: Paris
Output:
Teacher's soft answer: Paris and France plausible, banana nearly zero
What it shows: A bare label says only “Paris: yes, everything else: no”. The teacher's probabilities say more: “Paris” and “France” are plausible continuations, while “banana” is nonsense. Training the student on these probabilities teaches it which wrong answers are close, which helps it generalise from far fewer examples.
Technically
In classical distillation (Hinton et al. 2015) the student is trained to match the teacher's output distribution, with both softmaxes computed at a raised temperature T: q_i = exp(z_i / T) / Σ_j exp(z_j / T). A higher T softens the teacher's distribution so the small probabilities, which carry the “dark knowledge” about similarities between classes, become visible; the student is trained at the same temperature, usually mixed with the ordinary hard-label loss. DistilBERT applied this during pre-training and reduced BERT by 40% while retaining 97% of its language understanding and being 60% faster.
For LLMs, distillation also means training on text generated by the teacher. DeepSeek released six dense models (1.5B, 7B, 8B, 14B, 32B and 70B) distilled from DeepSeek-R1, built on Qwen and Llama, and reported that on Qwen2.5-32B direct distillation from R1 outperformed applying reinforcement learning to the base model. Distillation can also be restricted by provider terms, since the student inherits the teacher's behaviour.
Technical example: Softening a real next-token distribution
The eight most likely next tokens after “The capital of France is” in GPT-2 small, treated as a teacher's logits (ln p), renormalised over those eight at three temperatures.
Code (python):
import math
top = [(" the", .0846), (" now", .0479), (" a", .0462), (" France", .0324),
(" Paris", .0322), (" in", .0266), (" also", .0264), (" not", .0238)]
logits = [math.log(p) for _, p in top] # ln p is the logit up to a constant
def soft(T):
e = [math.exp(z / T) for z in logits]
return [v / sum(e) for v in e]
for T in (1, 2, 4):
q = soft(T)
print(f"T={T}: ' the' {q[0]:.3f} ' Paris' {q[4]:.3f} ' not' {q[7]:.3f} spread {q[0] / q[7]:.2f}x")
Output:
T=1: ' the' 0.264 ' Paris' 0.101 ' not' 0.074 spread 3.55x
T=2: ' the' 0.186 ' Paris' 0.115 ' not' 0.099 spread 1.89x
T=4: ' the' 0.153 ' Paris' 0.120 ' not' 0.112 spread 1.37x
What it shows: As T rises the distribution flattens: the ratio between the most and least likely of these tokens falls from 3.55 to 1.89 at T = 2 and 1.37 at T = 4, so a student trained at high temperature must also fit the ordering of the near-misses, not just the top token. At T = 1 the numbers are just the renormalised teacher.
Teacher and student
In plain English: The big model is the teacher and the small one the student. The student is trained not on the original data labels alone but on what the teacher says about each example, so it inherits some of the teacher's judgement.
Technically:
The motive is deployment. Models too large or slow for phones, browsers or cheap servers can be replaced by a student that reproduces much of their behaviour. Distillation can also be used to improve a model of the same size, or to transfer a capability such as reasoning to models that lack it.
The student's size sets a ceiling: a student cannot hold all the teacher's knowledge, so distilled models usually keep the common cases and lose the rare ones.
Soft targets and temperature
In plain English: A label is a very thin signal: one word is right. The teacher's full set of probabilities is a rich one. A knob called temperature softens the teacher's answer so that the small probabilities are not rounded away to nothing.
Technically:
Hinton et al. described the idea: raise the temperature of the final softmax until the teacher produces a suitably soft set of targets, then use the same high temperature when training the student to match them; matching logits directly is a special case. After training, the student is run at temperature 1.
The soft-target loss is usually a KL divergence between the teacher's and student's tempered distributions, combined with the normal cross-entropy on the true labels. The figure shows how raising T flattens GPT-2's real predictions, making the near-misses visible.
What is dark knowledge?
The information in the teacher's small probabilities, such as which wrong answers are nearly right, that a hard label discards.
Distillation in practice
In plain English: For language models there are two common recipes. One matches the teacher's word probabilities directly. The other simply has the teacher write lots of answers and trains the student on that text, which works even when only the teacher's text, not its probabilities, is available.
Technically:
DistilBERT used a triple loss combining language modelling, distillation and cosine-distance losses during pre-training, giving a 40% smaller and 60% faster model that retains 97% of BERT's performance on GLUE. Sequence-level distillation trains on the teacher's generated outputs, which is how reasoning traces from DeepSeek-R1 were used to teach smaller Qwen and Llama models to reason.
The DeepSeek-R1 report found that distilling from R1 into Qwen2.5-32B outperformed applying the same large-scale RL to the 32B model directly, suggesting that a strong teacher's reasoning patterns are cheaper to transfer than to rediscover.
Everyday example: A student on a diet of teacher text
A small model is trained on hundreds of thousands of answers written by a stronger model.
What it shows: It will usually sound and reason like the teacher on the kinds of questions in that data, but it can inherit the teacher's mistakes, and it may fail on questions unlike anything the teacher was shown.
Limits and trade-offs
In plain English: Distillation is not a free lunch. The student is smaller, so it knows less, and it may copy the teacher's flaws. Providers may also forbid training on their model's outputs.
Technically:
Distilled students inherit biases, hallucinations and refusal behaviours of the teacher, and can look better on benchmarks that resemble the distillation data than on novel tasks. Terms of service of some APIs prohibit using outputs to train competing models, so distillation from an open teacher or an owned model is the norm in practice.
In accuracy per parameter distillation usually beats training the same small model from scratch on labels alone, which is why most small variants in model families are distilled in some form.
Common misconceptions
Myth: A distilled model is a compressed copy that does everything the teacher does.
Reality: It is a smaller model trained to imitate the teacher. It matches the teacher on much of the training distribution and usually falls short elsewhere.
Myth: Distillation needs access to the teacher's weights.
Reality: Matching probabilities needs them, but training on text the teacher generated needs only its outputs.
Myth: Distillation and quantization are the same thing.
Reality: Distillation trains a different, smaller model. Quantization stores the same model's numbers in fewer bits.
Where you'll see this
- DeepSeek-V3 architecture: DeepSeek-R1, built on the V3 architecture, was distilled into six smaller dense models.
Key takeaways
- Distillation trains a small student on a large teacher's output probabilities or generated text, not only on correct labels.
- Temperature softens the teacher's distribution so that the relative sizes of small probabilities, the near-misses, become learnable.
- DistilBERT is 40% smaller and 60% faster while retaining 97% of BERT's language understanding.
- DeepSeek released six dense models from 1.5B to 70B distilled from DeepSeek-R1, and found distillation beat applying RL directly to a 32B base.
Frequently asked questions
What is knowledge distillation?
Training a small student model to reproduce a larger teacher's behaviour, using the teacher's probabilities or generated text as the training target.
What are soft targets?
The teacher's full probability distribution over possible answers, which carries more information than the single correct label.
What does temperature do in distillation?
It flattens the teacher's distribution so that small probabilities become visible and the student can learn from them.
How much does distillation shrink a model?
DistilBERT reduced BERT by 40% and ran 60% faster while retaining 97% of its language understanding.
Is a distilled model as good as the original?
Usually close on common tasks and weaker on rare or hard ones. It cannot hold all of the larger model's knowledge.
Sources
Facts last verified November 23, 2026.
- Hinton, Vinyals and Dean: Distilling the Knowledge in a Neural Network (arXiv)
- Sanh et al.: DistilBERT, a distilled version of BERT (arXiv)
- DeepSeek-AI: DeepSeek-R1, Incentivizing Reasoning Capability via Reinforcement Learning (arXiv)
- Radford et al.: Language Models are Unsupervised Multitask Learners (GPT-2)
- DeepSeek-R1 on Hugging Face