On-policy distillation
How two specialist teachers become one student model
A student that writes its own homework
What is distillation? tells the classic story: a large teacher writes solutions, and a smaller student learns to copy them. The student only ever sees the teacher’s work.
On-policy distillation turns that around. The student writes the attempt. The teacher then looks at every step the student actually took and says, token by token, what it would have written there. The student learns from its own mistakes, in the places it really goes, with a teacher at its shoulder.
In 2026 this became a way to merge models. This page follows the last part of Brandon Amos’s talk Post-training Beam [1] and the Beam technical report, §4.3 [2]. The wider story is on Evolution of post-training.
Classic distillation is studying a teacher’s worked examples. On-policy distillation is doing the exercise yourself while the teacher reads over your shoulder and corrects each line as you write it. You get feedback exactly where you go wrong.
Why train two specialists at all?
Beam trains two specialists from one shared midtrained model: an agentic teacher (code, terminal, maths, search) and an alignment teacher (conversation, safety, tool use, instruction following). Each has its own SFT and RL [1][2]. The pipeline figure is on Evolution of post-training.
- For: each team can iterate on its tasks and fix a regression without touching every other domain. Each branch has its own rewards and schedule.
- Against: the specialists may learn inconsistent habits (“split-braining”), skills that need both at once get fewer chances to grow together, and the merge itself costs compute and evaluation [1].
Other labs make different splits: by reasoning effort, by many domains (DeepSeek uses more than forty teachers), or no split at all with one joint run [1]. That comparison is a slide on Evolution of post-training.
The merge: multi-teacher on-policy distillation
- The student starts from the midtrained model and gets SFT on the combined specialist data. SFT alone did not recover both specialists [1].
- The student attempts a task.
- One frozen teacher is chosen for that rollout, based on the task family.
- At every position the student visited, the teacher gives its full next-token distribution.
- The trainer moves the student toward the teacher with reverse KL. There is no task reward at this stage [1][2].
Reverse KL is \(\mathrm{KL}(p_{\text{student}} \,\Vert\, p_{\text{teacher}})\): the average, under the student’s own probabilities, of how much more likely the student finds a token than the teacher does. It punishes the student for putting mass where the teacher would not. Compare it with the forward KL on What is distillation?.
The neat part is engineering reuse. It is the same asynchronous loop as RL at scale: the same inference pool, sandboxes, weight sync and router replay. The grader is replaced by a teacher, and the reward update by a KL loss [1].
Which teacher? Probabilistic routing
Coding, maths and search go to the agentic teacher. Conversation and safety go to the alignment teacher. Tasks that need both — instruction following, long context, tool workflows — flip a weighted coin per rollout: 50–50 or 60–40 [1].
Why not average the two teachers at every token? Because an average of two good answers can be a bad answer. Routing lets each teacher supervise whole attempts in its own style [1].
A student with a maths tutor and a writing tutor. A pure maths problem goes to the maths tutor. An essay goes to the writing tutor. A science report needs both, so this week one tutor marks it and next week the other. Nobody writes a half-maths, half-writing correction in the margin.
Every word, or a sample?
There are three ways to compute the reverse KL at a position [1]:
| Method | What it uses | Trade-off |
|---|---|---|
| Sampled | Only the token the student actually wrote | Cheap, but a noisy estimate |
| Top-k | The student’s k most likely tokens | Cheaper than full, but not a true KL on its own |
| Full vocabulary | Every token in the vocabulary (about 152K for Beam) | Exact, but looks expensive |
Beam uses the full vocabulary, and it ran in about the same wall time as the sampled version [1][2]. Two tricks make it cheap:
- Send the small vector, not the big one. The teacher’s last hidden state has 5,120 numbers; its logits have 151,936. Send the hidden state, and let the trainer multiply it by a cached copy of the teacher’s output head. For 16K tokens that is 336 MB instead of 9.96 GB [1]. DeepSeek-V4 uses the same idea [7].
- Compute in chunks. A FlashAttention-style kernel computes the KL a few positions at a time and never holds the whole logit table in memory [1][2].
Did the merge work?
Mostly yes. The student matches the agentic teacher on coding, maths and science, and matches or beats the alignment teacher on its tasks. Where both teachers supervise (AA-LCR, long-context reasoning), the student beats both. DeepSWE is the clear remaining gap (43.4 → 40.2) [1][2].
In one table
| Idea | In one sentence |
|---|---|
| Off-policy (classic) distillation | The student learns from the teacher’s own attempts |
| On-policy distillation | The student writes; the teacher corrects every token the student wrote |
| Reverse KL | Punishes the student for putting probability where the teacher would not |
| Multi-teacher routing | Pick one teacher per rollout by task family; flip a weighted coin for mixed tasks |
| Full-vocabulary KL | Compare the whole distribution, not one sampled token |
| Hidden-state transport | Move the 5,120-number vector; rebuild the 152K logits at the trainer |
FAQ
How is this different from the distillation in Lab LL01-1? In Lab#LL01-1 the student trains on traces the teacher already wrote (off-policy, hard targets). Here the student writes, and the teacher supplies full distributions on the student’s own text.
Why on-policy? Because a student copying perfect teacher traces never sees its own mistakes. Once it drifts off the teacher’s path, it is in places it never practised. On-policy feedback is given exactly where the student goes [5][6].
Is there still a reward? Not in Beam’s merge stage. The teachers already learned from rewards; the student learns from the teachers [1].
Does the student have to be smaller? No. In Beam the student is the same size as the teachers. The goal is to combine skills, not to shrink.
See also
- What is distillation? and Lab#LL01-1: Distilling a reasoning model
- Evolution of post-training
- RL at scale — the loop this stage reuses
- Tasks, verifiers and judges — the task families that decide the routing
References
- [1] Brandon Amos, Post-training Beam, MIT ScaleML seminar, 30 November 2026. Slides page, PDF, Beamer source and figure credits. Slide images reproduced with credit; slide numbers are PDF page numbers.
- [2] Reflection Team, Beam Model Technical Report, 2026, §4.3. arXiv:2611.26358; report PDF.
- [3] Geoffrey Hinton, Oriol Vinyals and Jeff Dean, Distilling the Knowledge in a Neural Network, 2015. https://arxiv.org/abs/1503.02531.
- [4] Yoon Kim and Alexander M. Rush, Sequence-Level Knowledge Distillation, EMNLP 2016. https://aclanthology.org/D16-1139/.
- [5] Rishabh Agarwal and colleagues, On-Policy Distillation of Language Models: Learning from Self-Generated Mistakes, 2024. https://arxiv.org/abs/2306.13649.
- [6] Yuxian Gu, Li Dong, Furu Wei and Minlie Huang, MiniLLM: Knowledge Distillation of Large Language Models, ICLR 2024. https://openreview.net/forum?id=5h0qf7IBZZ.
- [7] DeepSeek-AI, DeepSeek-V4, 2026, §5.2.2. https://arxiv.org/html/2606.19348v1.






