How it works
- The student answers. For each prompt the student writes its own answer, a practice answer.
- The teacher reads it. The teacher processes the same prompt and answer in one pass and, at every position, outputs its probability distribution over the next token: what it would have said there.
- Compare and update. At each token, the student's distribution is compared with the teacher's using a divergence, and the student is moved toward the teacher.
{"prompt": [
{"role": "user", "content": "What's the difference between EBITDA and EBIT?"}
]}No reference answer is needed and your replies are not used as targets; only the prompts are. The teacher never writes a whole answer, it only reads one, which is much cheaper per token than generating.
Why it works so well
On-policy distillation takes the best of two other methods. Like supervised training, its signal is dense: every token gets feedback. Like reinforcement learning, its data is on-policy: it comes from the student's own answers, so it covers the mistakes the student actually makes. Off-policy students only ever see the teacher's flawless paths; RL students see their own paths but get one number per whole answer.
Any model families. Only text crosses over. Trains exactly like supervised fine-tuning.
Same tokenizer required, so the teacher is usually a bigger model of the same family. Learns from its own mistakes.
- Prompt: “What's the difference between EBITDA and EBIT?”
- The student starts well, then writes “EBIT adds back depreciation…”, which is backwards: it is EBITDA that adds it back.
- At the token “adds”, the teacher's probabilities favour “deducts” or “subtracts”; the student's favoured “adds”. The divergence is large exactly there.
- The update lowers “adds” and raises the teacher's choices in that context: the precise correction. Tokens where the two already agree contribute almost nothing.
- RL with a grader would have scored the whole answer low and discouraged all of its tokens equally, the correct ones included.
Forward KL, reverse KL, or a mix
The student's and teacher's distributions can be compared in two directions, and the choice changes what the student becomes.
- Forward KL, KL(teacher ‖ student), heavily penalises the student for giving low probability to anything the teacher considers likely. The student spreads out to cover all of the teacher's options (mode-covering). A small student that can't fit them all ends up putting weight between them, which can produce vague or low-quality text.
- Reverse KL, KL(student ‖ teacher), heavily penalises the student for saying things the teacher considers unlikely. The student commits to the teacher's main option and ignores the rest (mode-seeking): sharper, more decisive, less varied.
- Jensen–Shannon divergence (JSD), and its generalised form, blends the two. The GKD paper found the best choice depends on the task.
Reverse KL suits small students and tasks with one right answer in mind, which is why it is common for on-policy distillation of chat and reasoning models: Thinking Machines' 2025 write-up uses a per-token reverse KL, and TRL's DistillationTrainer defaults to it. In Scalata this choice is the divergence β setting.
Requirements and costs
- Same vocabulary. Distributions are compared token by token, so both models must split text into the same tokens. In practice the teacher is a bigger model of the same family, for example Qwen2.5-3B teaching Qwen2.5-0.5B.
- Both models on the GPU. The teacher is loaded next to the student; a 3B teacher in bf16 needs about 6 GB on top of the student.
- Generation time. Every step generates answers token by token, which makes it slower than supervised training on the same data; the max practice answer length is the main lever.
- Style. The student learns the teacher's habits, including length. To also get your team's style, run supervised training on your replies afterwards, continuing from the distilled model.
The payoff can be large. Figures from the Qwen3 technical report, compared in Thinking Machines' write-up, show on-policy distillation bringing Qwen3-8B to 74.4% on AIME'24 with about 1,800 GPU hours, where RL from a similar starting point reached 67.6% with 17,920. With small models on narrow tasks the gains are smaller, but the per-token signal still moves a student further per prompt than a handful of teacher answers would.
Common mistakes
- Picking a teacher from another model family. The vocabularies differ, so token-by-token comparison is impossible.
- Forgetting the teacher's memory. A GPU that fits the student alone may not fit both.
- Setting a long practice answer length “to be safe”. Generation dominates the step time.
- Expecting your style. Your replies are never targets here.
References and further reading
External sources open in a new tab.
- 01On-Policy Distillation of Language Models: Learning from Self-Generated MistakesAgarwal et al., 2024 · ICLR / arXiv · arxiv.orgThe method: train on the student's own outputs with token-level teacher feedback, and a choice of divergence.
- 02MiniLLM: On-Policy Distillation of Large Language ModelsGu et al., 2023 · arXiv · arxiv.orgArgues for reverse KL when distilling into small language models.
- 03On-Policy DistillationThinking Machines Lab, 2025 · thinkingmachines.aiA practical account, with compute comparisons against RL and use for recovering skills after further training.
- 04Distillation TrainerHugging Face TRL docs · huggingface.coAn open-source on-policy distillation trainer, and its definition of β.