The Problem: A Large Model Is Slow and Expensive
Picture a brilliant university professor who charges $500 an hour. You cannot put them in front of every student around the clock. But if that professor spends time training an assistant, the assistant can handle most of the questions for a fraction of the cost.
That is the principle of distillation. You have a large model that answers very well but is expensive to run; you want a small one that comes close. By convention the large one is the teacher and the small one the student.
The question is: what exactly do you have the student learn? The whole lesson turns on that.
Hinton, Vinyals & Dean (2015), Distilling the Knowledge in a Neural NetworkThe Core Idea: Learn the Distribution, Not the Answer
A classifier does not produce an answer, it produces a probability distribution: a number between 0 and 1 for every possible answer, the whole set summing to 1. Shown a photo, it does not say "cat"; it says cat 0.90, tiger 0.07, lion 0.02, dog 0.01.
Now compare the two ways to train the student.
- Ordinary training: you hand it the label. "This is a cat." In other words the distribution 1 for cat, 0 everywhere else. One example, one piece of information.
- Distillation: you hand it the teacher's four numbers. It learns the right answer and, for free, that this image looks a little like a tiger, barely like a lion, and almost nothing like a dog.
The second version carries far more information per example, and that is precisely the original paper's argument: when the teacher's targets have high entropy (when they are spread out rather than concentrated on a single answer) they provide much more information per training case than hard labels do.
Hard targets are the labels: the right answer and nothing else. Soft targets are the distributions the teacher produces. Logits are the raw scores the network computes before converting them into probabilities; that conversion is done by a function called softmax, which takes arbitrary scores and turns them into positive numbers summing to 1.

The original paper runs an experiment that shows how strong the effect is. On handwritten digit recognition, the authors strip every example of the digit 3 out of the student's training set. As far as the student is concerned, 3 is a mythical digit it has never seen. It still recognises most of them: out of the 1,010 threes in the test set, it misses only 133. The information "this looks like a 3" reached it through the small probabilities the teacher was placing on 3 while looking at 8s and 5s.
Why the Word "Distillation"?
The name is not a loose metaphor. It refers to a specific operation, and that operation is the second half of the mechanism.
Here is the snag: soft targets are only soft if the teacher hesitates. A good teacher does not. It says cat 0.999 and puts on tiger. All the similarity information is there, but crushed so close to zero that it carries no weight in the student's training.
The authors' fix: turn up the heat. Rewrite the softmax with one extra knob, the temperature :
Symbol by symbol. is the logit of answer number , that is, its raw score. is the probability that comes out. is the exponential function, which makes everything positive. means "add over all possible answers", and it is that sum in the denominator that forces the total to be 1. is the temperature, normally set to 1, in which case you get the ordinary softmax back.
In one sentence: dividing every score by before exponentiating pulls the scores closer together, which flattens the resulting distribution. A higher temperature yields a softer distribution.
This is a distillation in the chemist's literal sense: you heat the mixture until the component you want to recover (here the similarity structure among the answers) becomes extractable. The authors put it this way: their solution is to raise the temperature of the final softmax until the cumbersome model produces a suitably soft set of targets, then to use that same high temperature when training the small model.
Heating, concretely: raise each probability to the power , then renormalise so the total is 1 again. (This is the same operation as the formula above: dividing logits by amounts to raising probabilities to the power .)
Start from cat 0.90, tiger 0.07, lion 0.02, dog 0.01 and take , hence the power :
- · · ·
- sum:
- after dividing by the sum: cat 0.45, tiger 0.24, lion 0.17, dog 0.14
The tiger has gone from 7% to 24%. It now carries enough weight for the student to learn something from it.
The Loss Function, Term by Term
Two objectives are combined. Cross-entropy, often abbreviated CE, is the standard measure of the gap between two distributions: it is at its smallest when they coincide.
- is the loss: the number training drives down.
- (alpha) splits the weight between the two terms; is what remains, so that the two weights sum to 1.
- The first term is ordinary training: the student's output, at temperature 1, is compared to the label.
- The second is the distillation: the two distributions are compared, computed at the same high temperature on both sides. Otherwise the comparison would be meaningless.
Two details from the paper that almost never get said, and that account for the constants.
Where the comes from. It is not an empirical knob. When you divide the logits by , the gradients (the corrections sent back to the weights) end up divided by , shrunk by that much. Multiplying this term by cancels the effect exactly. Without the factor, changing the temperature would also silently change the relative importance of the two terms; with it, you can tune without unbalancing everything else. The authors say so plainly: since the magnitudes of the gradients produced by the soft targets scale as , it is important to multiply them by when using both hard and soft targets.
Which of the two terms wins. Contrary to what you often read, it is not half and half: the authors report that the best results are generally obtained by putting a considerably lower weight on the label term. The teacher is the main signal; the label is a guardrail.

The paper measures this, and its answer is more interesting than a single value. With a roomy student (at least 300 units per hidden layer in their experiment) every temperature above 8 gives roughly the same result. But with a student cut down to 30 units per layer, the range 2.5 to 4 does significantly better than anything higher or lower.
The authors' reading: a student that is too small lacks the capacity to absorb the teacher's full structure, and in that case it is better to ignore the tiniest probabilities than to force the student to reproduce them. A moderate temperature leaves them in the shade; a very high one puts them in full light and wastes the student's capacity.
Keep the rule, not the numbers: the smaller the student relative to the teacher, the more moderate the temperature should be.
What It Buys You, Measured
The paper reports a clean result on handwritten digit recognition, with three comparable networks:
| Network | Training | Test-set errors |
|---|---|---|
| Large (2 layers of 1,200 units) | ordinary, heavily regularised | 67 |
| Small (2 layers of 800 units) | ordinary, no regularisation | 146 |
| Small (the same one) | soft targets from the large net, at | 74 |
Read the third row against the second: the same small network, on the same data, goes from 146 errors to 74. It did not gain a single parameter. The only difference is what it was shown, distributions instead of labels. And it lands at 74, close to the large model's 67.
This is the one number on the page worth remembering, because it isolates exactly the variable we care about.
For Language Models: Two Regimes, Depending on Access
A large language model (LLM) produces a distribution not over image classes but over the tens of thousands of tokens in its vocabulary, and it does so at every word of its answer. The principle does not change; what changes is what you have access to.
Black box: copy the text
You can only reach the teacher through an API (Application Programming Interface, the interface through which one program calls another), which hands you text and nothing else. The recipe:
- Assemble a large set of questions representative of your use case.
- Send them to the teacher, keep its answers.
- Fine-tune a small open-weights model on those question-answer pairs.
This is how the first small conversational models of 2023 were built. Alpaca (Stanford) was fine-tuned on 52,000 instructions generated by an OpenAI model of the GPT-3.5 generation, and Vicuna on ChatGPT conversations that users had posted to the ShareGPT site. In both cases only text was copied.
Note that this regime is not distillation in the sense of this page: you are back to hard targets. The teacher's text is a set of chosen words, not distributions. It is supervised fine-tuning on generated data, and common usage calls it distillation by extension.
White box: imitate the distributions
If you hold the teacher's weights, you can compare the distributions token by token, which is the mechanism described above applied at every position in the text. It is richer: the student also learns the teacher's hesitations, every word the teacher thought was nearly as good.
It also requires the two models to share the same token vocabulary, otherwise their distributions are not about the same objects and cannot be compared at all.

Copying answers transmits the teacher's style more reliably than its way of reasoning: the student learns to write like it without learning to think like it. The Orca project (Microsoft, 2023) answered this by asking the teacher not for the answer but for the trace of its reasoning, step by step. The student no longer learns "the answer is 42" but "here is the path that gets you to 42", which, for the same amount of data, provides far more to work with on reasoning tasks. See also chain of thought.
2025: Distilling Reasoning
Orca's idea took on a whole new scale with reasoning models, the ones that write out a long deliberation before answering (see DeepSeek R1 and OpenAI o1). Their reasoning trace is exactly the material Orca was after: not "the answer is 42", but pages of attempts, checks and backtracking.
The DeepSeek-R1 Recipe (January 2025)
The DeepSeek-R1 paper describes two quite separate stages:
- The large model learns to reason through reinforcement learning (RL: the model tries, an automatic reward tells it whether it got the answer right, and it adjusts its weights). That is expensive and delicate.
- The large model then serves as teacher. DeepSeek has it produce about 800,000 examples (roughly 600,000 reasoning traces and 200,000 ordinary answers), then fine-tunes six small open-weights models from the Qwen and Llama families, from 1.5 to 70 billion parameters, on that text.
Note that stage 2 is black box in this page's sense: text is copied, not distributions. And yet the result is spectacular: the small 7-billion-parameter student reaches 55.5% on the AIME 2024 maths competition, against 9.3% for GPT-4o in the same evaluation (figures detailed in DeepSeek R1).
DeepSeek-AI (2025), DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement LearningDeepSeek ran the opposite experiment too: applying the expensive RL directly to a 32-billion-parameter model, with no teacher. Result on AIME 2024: 47.0% for the RL-trained model, against 72.6% for the same starting model simply fine-tuned on R1's reasoning traces.
The authors' conclusion is clear: for a small model, imitating a large model that already knows how to reason is both cheaper and more effective than having it discover reasoning on its own. RL is still needed to create the capability in the large model; distillation is enough to pass it on.
Sometimes a Few Examples Are Enough
The s1 project (Stanford and others, January 2025) pushed the economy to the extreme: 1,000 problems, carefully chosen and paired with reasoning traces from a Google model, were enough to fine-tune a 32-billion-parameter Qwen model to reasoning performance comparable with the first proprietary reasoning models on several maths benchmarks. The lesson echoes data quality: what counts is the quality and difficulty of the examples, more than their number.
Muennighoff et al. (2025), s1: Simple test-time scalingThat is also why reasoning traces became a commercial stake: if a few thousand traces can pass on a capability that cost months of compute, whoever leaves them visible gives a great deal away. Hence the rest of this page, and the lesson Encrypted Reasoning.
The Variant That Matters: Let the Student Write
Everything above shares one flaw: the student trains on text the teacher wrote. So it never practises in the situations it gets itself into, which are exactly the ones where it goes wrong. On-policy distillation (training on the student's own behaviour) fixes that: the student writes, the teacher annotates its work word by word. The two founding papers date from 2023. MiniLLM changes how the gap between the two distributions is measured: instead of forcing the student to cover everything the teacher considers possible, including unlikely words it will imitate badly, it pushes the student to concentrate on what the teacher considers most likely. GKD (Generalized Knowledge Distillation, Google DeepMind) generalises the idea and shows the value of training on the student's own text. The topic, which became a routine post-training step in 2025-2026 (Qwen3, DeepSeek-V4), has a lesson of its own: on-policy distillation.
Gu et al. (2023), MiniLLM: On-Policy Distillation of Large Language Models Agarwal et al. (2023), On-Policy Distillation of Language Models: Learning from Self-Generated Mistakes (GKD)One point from that lesson belongs here, because it drives the bill. The teacher's weights are frozen in both cases: it never learns anything. But its distributions must be recomputed at every step once you distil on-policy, since they are about text the student has only just written. Nothing can be cached. In classic distillation, by contrast, the teacher's outputs are written to a file once and reread indefinitely. That, and nothing else, is where the cost gap between the two lies.
What You Gain, and How to Compute It
Two gains, not to be confused.
Memory. It tracks the parameter count directly. Going from 7 billion parameters to 3 billion divides the space the weights occupy by .
Speed. It also tracks the parameter count, but for a reason that is far from obvious, and that is laid out in Quantization: the concepts: generating a token is limited by memory bandwidth, that is, by how long it takes to stream all the weights from memory into the compute units. Half as many weights to read, so roughly half the waiting. The factor of 2.3 above shows up again, as an order of magnitude, in the token throughput.
That is also what makes distillation and quantization complementary rather than redundant: the first cuts the number of parameters, the second the number of bytes per parameter. Both cut the same total of bytes to be read, through two independent levers, and their factors multiply.
The quality loss cannot be computed. It depends on the size gap, the task, and the volume and quality of the transfer data. Any page that announces "you lose 10 to 20% of quality" without saying on which benchmark and between which models is quoting a number that means nothing, "quality" is not a quantity you can measure in percent. Measure on your own task; that is the only honest answer.
See also, in on-policy distillation, Apple's distillation scaling law: it establishes that the shortcut has a domain of validity, and that beyond a certain compute budget direct training takes the lead again.
Distilling a Competitor's Model: Contracts and Accusations
What the Terms of Use Say
The terms of use of the big proprietary providers (OpenAI, Anthropic and Google, among others) prohibit using their models' outputs to develop or train a competing model. These clauses change over time and differ between providers. They are a contractual rule between the provider and its customer, not a technical impossibility: nothing in a text returned by an API prevents it from being used as training data. Their legal reach depends on the applicable law and has not been settled everywhere, as Training on Synthetic Data points out.
Open-weights models are clearer ground, but not uniformly free: every licence has its own restrictions, and some govern the use of outputs explicitly, for instance by requiring a derived model to carry the original name. What counts is the licence of the specific model, not the reputation of the family.
The Accusations Between Labs (2025-2026)
Unauthorised distillation went, within months, from a technical topic to a diplomatic one. The facts, in order, as reported by the parties themselves:
- January 2025: days after DeepSeek-R1's release, OpenAI told the press it had seen signs that DeepSeek may have distilled its models. No evidence was made public.
- 12 February 2026: in a memo to a US House of Representatives committee on China, OpenAI accused DeepSeek of getting around its protections (third-party routers, masked accounts, scripts) to extract its models' outputs.
- 23 February 2026: Anthropic published a report attributing to DeepSeek, Moonshot AI and MiniMax campaigns run through about 24,000 fraudulent accounts, for more than 16 million exchanges with Claude.
- 10 September 2026: a new Anthropic report targeted seven Chinese labs and nearly 190 million exchanges between May and July 2026, the largest share attributed to operators linked to Alibaba, which disputes it.
These are one party's accusations, which no court has examined. They do shed light on two very real practices: providers now detect the query patterns typical of distillation (thousands of accounts asking very similar questions, back to back), and they hide or encrypt their models' reasoning so as to deliver only the final answer, see Encrypted Reasoning. The industry background is covered in DeepSeek.
When to Distil
Distillation is the right call when you already have a distinctly better teacher, your inference budget is tight, and your use case is narrow, the student does not need to know everything, only your domain.
It is the wrong call when you need the teacher's full reasoning capacity, when your domain is too broad for any reasonable transfer set to cover it, or when the teacher's terms of use forbid it.
Reasoning qualifies the first limit: since DeepSeek-R1 we know that a large part of a reasoning capability can be passed on by distillation, provided you have a teacher that already reasons well and good-quality traces. For producing those traces and other model-generated data, see Training on Synthetic Data.
It is not a miracle cure but a trade: you give up some quality (how much you only learn by measuring) for a gain in speed and memory that is, by contrast, predictable from the ratio of sizes.
1. In the original paper's experiment, the same small network goes from 146 errors to 74 without gaining a single parameter. What changed in its training?
2. Why must the teacher's softmax be « heated » with a temperature before distilling?
3. Alpaca and Vicuna were built by fine-tuning a small model on text produced by an OpenAI model. Is that distillation in this page's sense?
4. An article announces: « distilling a 7-billion-parameter model into 3 billion loses 10 to 20 percent of quality ». What is the right reaction?
5. Before distilling from a proprietary model's API, what non-technical point should you know about?
6. DeepSeek compared two ways of making a 32-billion-parameter model good at reasoning. Which won on AIME 2024, and why?