Volume X · After Pretraining
The Student Becomes the Teacher
DeepSeek-R1 is a 671-billion-parameter model that thinks for thousands of tokens before it answers. Serving it takes a cluster. So DeepSeek did something that looks too simple to work: it had R1 write out about 800,000 solutions, and fine-tuned small models on them.
The mental model
Reasoning is a behaviour, and a behaviour can be shipped as data. A large model that has learned to reason writes the lessons; a small model studies them. The lesson lands better when the student practises on its own mistakes — and when several students share an ancestor, their weights can sometimes simply be combined.
Too big to serve
R1 is a mixture of experts with 671 billion parameters in total and 37 billion active per token. At one byte per weight, the arithmetic of Volume VIII, that is about 671 gigabytes before a single token of cache — a multi-accelerator node, not a card. And it is a model that answers at length: one reply can run to thousands of reasoning tokens. Most people who want a reasoning model want one that fits on a single device and answers at a reasonable price.
There are two routes to a small reasoner. Run the R1-Zero recipe of the last lecture on a small base model, and let RL discover the behaviour. Or let R1 do the discovering, write down how it solves problems, and train the small model to write the same. DeepSeek ran both on a 32-billion-parameter Qwen base and reported the comparison.
DeepSeek's own reading is two-sided. Distilling a stronger model into a smaller one works well, whereas a small model doing large-scale RL needs a great deal of computation and may still fall short of what distillation achieves. And the same passage concedes that pushing past the frontier probably still requires stronger base models and larger-scale RL. Put as a division of labour: RL discovers, distillation transmits. Discovery is a search, which is expensive and bounded by what the base model can already be induced to sample. Transmission needs only text.
Eight hundred thousand lessons
The recipe is plain. The roughly 800,000 samples that R1's pipeline curated for its own stage 3 — about 600,000 reasoning examples and 200,000 other ones — were used, unchanged, to fine-tune open models. Six students: four from Qwen2.5 and two from Llama. The students got supervised fine-tuning and nothing else. DeepSeek says explicitly that it applied no RL stage to them, though it expects RL would help, and left that to others.
“Distillation” names two different things, and this one is the less famous. Hinton, Vinyals and Dean (2015) trained a student to match the teacher's softened output distribution, which needs the teacher's probabilities. Kim and Rush (2016) showed the sequence-level alternative: train the student on text the teacher generated. R1's distillation is of the second kind. It has a practical consequence that matters more than it sounds: it works across tokenizers and architectures, and against any teacher you can sample from, because the student only ever reads sentences.
| Model | Fine-tuned from | AIME 2024 |
|---|---|---|
| R1-Distill-Qwen-1.5B | Qwen2.5-Math-1.5B | 28.9 |
| R1-Distill-Qwen-7B | Qwen2.5-Math-7B | 55.5 |
| R1-Distill-Llama-8B | Llama-3.1-8B | 50.4 |
| R1-Distill-Qwen-14B | Qwen2.5-14B | 69.7 |
| R1-Distill-Qwen-32B | Qwen2.5-32B | 72.6 |
| R1-Distill-Llama-70B | Llama-3.3-70B-Instruct | 70.0 |
| DeepSeek-R1 (the teacher) | DeepSeek-V3-Base | 79.8 |
Practising on your own mistakes
Fine-tuning on a teacher's text has a quiet flaw. Every token the student learns to predict is conditioned on a prefix the teacher wrote. At test time the prefix is the student's own, and the first slip carries it into a state no training example showed — the teacher never demonstrated recovering from an error because the teacher did not make one. This is exposure bias, and imitation learning had a name for the cure long before language models needed it. Ross, Gordon and Bagnell's DAgger (2011) lets the learner act, then asks the expert what it should have done in the states the learner actually reached.
On-policy distillation is DAgger for sequences. Agarwal et al.'s generalised knowledge distillation (ICLR 2024) trains the student on its own generated outputs, with the teacher scoring them, and lets the loss be a divergence other than forward KL when the student lacks the capacity to match the teacher exactly. The recent formulation from Thinking Machines (October 2025) makes the connection to RL concrete: sample from the student, and let the teacher grade every token.
rewardt = − ( log π_student(x_t | x_<t) − log π_teacher(x_t | x_<t) )
expected over samples, this is −KL( π_student ‖ π_teacher ) — the reverse KL, summed over positions
Reverse KL punishes the student for putting probability where the teacher puts little, so a small student learns to commit to behaviours it can actually reproduce instead of smearing itself across ones it cannot. The loop reuses an RL training pipeline; only the reward changes, and it needs the teacher's log-probabilities rather than a verifier or a reward model.
There is one published comparison worth holding up to the light. The Qwen3 report describes a two-phase strong-to-weak distillation for its five small dense models and its 30B-A3B mixture of experts: first off-policy distillation on teacher outputs, then on-policy distillation, in which the student generates and its logits are aligned to a larger Qwen3 teacher. For Qwen3-8B the report tabulates, after the off-policy phase, a further RL stage reaching 67.6 on AIME'24 at 17,920 GPU hours, against 74.4 for on-policy distillation at 1,800 GPU hours — about a tenth of the compute. The Thinking Machines write-up cites the same pair of numbers, reports a 9 to 30 times compute reduction against SFT in its own reasoning experiment, and says its replication of the RL baseline reached 68%.
Hold those figures loosely. They are one model size on one pair of benchmarks, and the two sides are not given equal information: the distillation run has a much larger teacher grading it, while the RL run has only a verifier. Part of the saving is simply what a bigger teacher buys. What the comparison does establish is that dense per-token feedback on the student's own samples is a serious competitor to RL at this scale, which is why it is spreading. DeepSeek-V4 is reported to lean on on-policy distillation from a fleet of specialist teachers unconfirmed, a claim this course can date but not verify from a primary paper; Lecture 24 returns to it.
Combining models without training
Distillation moves knowledge through data. There is a cruder route that moves it through the weights themselves, and it works more often than it has any right to. Start from the observation that the checkpoints in this part were mostly not trained from scratch: a math fine-tune and a code fine-tune of the same base model began from identical weights and moved a modest distance. If both stay inside one low-loss region of weight space, a point between them, or a point beyond them along both directions, may be a perfectly good model.
Model soups (Wortsman et al., 2022) are the simplest case: take several fine-tunes of one pretrained model, differing in hyperparameters, and average their weights. For large pretrained models that fine-tune into a similar low-error region, the paper reports the average often beats the best single member, and, unlike an ensemble of models, costs nothing extra at inference. Task arithmetic (Ilharco et al., 2023) generalises the idea. Define a task vector as the fine-tuned weights minus the pretrained weights. Vectors can be added to combine abilities, negated to suppress one, and scaled by a coefficient chosen on held-out data.
The bet fails when the changes collide. Two fine-tunes may push the same parameter in opposite directions, and most of what each one changed may be noise. TIES-Merging (Yadav et al., 2023) addresses both: reset parameters that moved only slightly, resolve the sign each parameter should take across models, and average only the entries that agree with it; the authors report that sign interference matters most. DARE (Yu et al., 2024) attacks the same redundancy differently: drop a random proportion p of each fine-tune's changes and rescale the survivors by 1/(1 − p). The authors report that the changes are small and redundant enough that 90% or even 99% can be dropped with little loss.
What merging cannot do
Merging adds no knowledge that no ingredient had; it interpolates, or extrapolates a little, among abilities already present. It asks for the same architecture, and in practice the same pretrained starting point, because independently trained networks are not aligned unit for unit. Git Re-Basin (Ainsworth et al., 2022) shows that permuting hidden units can align some independently trained networks well enough to merge them, but that result is for small vision models and not a routine way to combine language models. And the coefficient λ is tuned on a validation set, so a merge is a model selected on that data, to be evaluated on other data.
In production, the best-documented use is modest. Meta's Llama 3 report describes averaging models obtained from experiments with different data and hyperparameters at the reward model, SFT and DPO stages. Outside the laboratories, the open-source toolkit MergeKit packages these methods, and its authors report that thousands of merged models have been published. Whether a given 2026 flagship merges anything is rarely stated, which makes it a good question for the next lecture.
Where the part lands
Follow the part from the start. Volume IX was about keeping a very large run from blowing up, and getting more out of each token. This volume began with a base model that predicts text and ended with several ways of making it behave. Reinforcement learning against a checker turns a base model into a reasoner, at the price of a model that is expensive to run. Distillation spreads that reasoning down the size ladder, first as text and then, more efficiently, as per-token feedback on the student's own attempts. Merging recombines what the training runs produced without spending another GPU-hour.
| Technique | What it needs | What it gives | Lecture |
|---|---|---|---|
| RLVR with GRPO | A base model, a verifier, many samples per question | A reasoner; long answers; expensive to serve | 21 |
| Cold start, rejection sampling, SFT | A strong checkpoint to sample from | Readable, stable traces, and a curated dataset | 21 |
| Sequence-level distillation | Teacher-sampled text only | A small reasoner; ceiling is the teacher | 22 |
| On-policy distillation | Teacher log-probabilities on student samples; an RL-style loop | Dense feedback on the student's own states | 22 |
| Model merging | Models fine-tuned from one base; a validation set for λ | One set of weights combining several, with no further training | 22 |
Every row of that table is also a question a technical report either answers or declines to answer. The fifth question of the checklist in the next lecture asks what the post-training recipe is and what it was optimised against. You can now parse that sentence. A verifier or a learned judge. A critic or a group baseline. Distilled from whom, and on whose samples. Merged or not. The reports differ most in how much of that they say.
Read the primary source
- DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning — DeepSeek-AI, 2025.
- Distilling the Knowledge in a Neural Network — Hinton, Vinyals and Dean, 2015.
- Sequence-Level Knowledge Distillation — Kim and Rush, 2016.
- A Reduction of Imitation Learning and Structured Prediction to No-Regret Online Learning — Ross, Gordon and Bagnell (DAgger).
- On-Policy Distillation of Language Models: Learning from Self-Generated Mistakes — Agarwal et al., ICLR 2024.
- On-Policy Distillation — Kevin Lu and Thinking Machines Lab, October 2025.
- Qwen3 Technical Report — Qwen Team, 2025.
- Does Reinforcement Learning Really Incentivize Reasoning Capacity in LLMs Beyond the Base Model? — Yue et al., 2025.
- Model soups — Wortsman et al., 2022.
- Editing Models with Task Arithmetic — Ilharco et al., ICLR 2023.
- TIES-Merging: Resolving Interference When Merging Models — Yadav et al., NeurIPS 2023.
- Language Models are Super Mario — Yu et al., ICML 2024.
- Git Re-Basin: Merging Models modulo Permutation Symmetries — Ainsworth, Hayase and Srinivasa, 2022.
- Arcee's MergeKit — Goddard et al., 2024.
- The Llama 3 Herd of Models — Meta, 2024.