Resources/Model training/Training methods

Method

On-policy distillation: the teacher grades the student

In on-policy distillation the student writes its own answers and the teacher scores every token of them, so the student learns exactly where it goes wrong. Teacher and student must share a vocabulary.

Chapter 74 min read4 references

How it works

  1. The student answers. For each prompt the student writes its own answer, a practice answer.
  2. 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.
  3. 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.
Training row: the prompt only
{"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.

Way 1 · teacher writes answers
your prompt→teacher (large)→full answer text→student learns prompt → answer

Any model families. Only text crosses over. Trains exactly like supervised fine-tuning.

Way 2 · teacher grades the student's own answer
your prompt→student writes→teacher scores every token→student moves toward teacher

Same tokenizer required, so the teacher is usually a bigger model of the same family. Learns from its own mistakes.

Off-policy distillation passes finished text from teacher to student. On-policy distillation lets the student write, then shows it, token by token, what the teacher would have said instead.
Learning at the token where it went wrong
  1. Prompt: “What's the difference between EBITDA and EBIT?”
  2. The student starts well, then writes “EBIT adds back depreciation…”, which is backwards: it is EBITDA that adds it back.
  3. At the token “adds”, the teacher's probabilities favour “deducts” or “subtracts”; the student's favoured “adds”. The divergence is large exactly there.
  4. 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.
  5. 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.
possible answers →β = 0 · forward KLCovers everything the teacher might say, and so also puts weight on the gap between its answers. Broader, more varied, sometimes vague.
possible answers →β = 1 · reverse KLCommits to the teacher's main answer and ignores the rest. Sharper and more decisive, less varied.
teacher (dashed)student (filled)
A small student cannot copy a teacher that has two good answers. Forward KL makes it spread out to cover both (mode-covering); reverse KL makes it pick one and fit it well (mode-seeking). β between 0 and 1 blends the two.

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.

  1. 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.
  2. 02MiniLLM: On-Policy Distillation of Large Language ModelsGu et al., 2023 · arXiv · arxiv.orgArgues for reverse KL when distilling into small language models.
  3. 03On-Policy DistillationThinking Machines Lab, 2025 · thinkingmachines.aiA practical account, with compute comparisons against RL and use for recovering skills after further training.
  4. 04Distillation TrainerHugging Face TRL docs · huggingface.coAn open-source on-policy distillation trainer, and its definition of β.

Turn weeks of expert work into minutes

See how Scalata fits your team, your data, and your controls.