On-Policy Distillation of Language Models: Learning from Self-Generated Mistakes (GKD)
Read first: REINFORCE and the Policy-Gradient Theorem (Williams 1992; Sutton et al. 1999)
TL;DR. Classic distillation trains the student on fixed sequences (ground truth or teacher outputs). At inference, though, the student continues its own prefixes, so the errors it never practised compound. GKD trains the student on its own samples, uses the teacher’s full next-token distribution on every prefix as the label, and lets you pick both the data mix λ and the divergence (forward KL, reverse KL or generalized JSD). It also plugs straight into RL fine-tuning.
Why it matters now. This is the technical root of “on-policy distillation”, the recipe behind Qwen3’s small models and the Thinking Machines blog. It is also the root of the 2026 self-distillation wave (OPSD, SDFT). For an IR person it is the principled version of “distil the big cross-encoder or LLM reranker into a small one”: train on the student’s own outputs, not just the teacher’s.
Key idea
Section titled “Key idea”Distillation as imitation learning. Treat the student as a policy and the teacher as an expert you can query at any state. A “state” is a prefix . The token-level discrepancy on a sequence is the average divergence over its positions (Eq. 2):
Which sequences? Supervised KD averages this over a fixed dataset of pairs. On-policy KD averages it over , the student’s own samples (temperature 1 during training), without backpropagating through the sampling. GKD mixes the two:
Supervised KD is with forward KL. On-policy KD is with forward KL.
Which divergence? Forward KL is maximum-likelihood-like and mass-covering: the student must put mass everywhere the teacher does, and a small student then spreads mass onto tokens the teacher considers unlikely. Reverse KL is mode-seeking: the student concentrates on what the teacher likes most, which gives higher quality and less diversity. This mass-between-modes intuition concerns a capacity-limited student; with an unrestricted student, both KL directions are minimized by matching the teacher. The generalized JSD interpolates between them:
Its gradients behave like forward KL as and like reverse KL as .
Plus RL. Because on-policy GKD needs only student samples, it composes with RLHF/RLAIF (Eq. 5):
When combining with RL, the authors recommend reverse KL or JSD(0.9), which match the reverse-KL regulariser RLHF already uses.
Key results
Section titled “Key results”Setup: T5 students (small 77M, base 250M, large 800M) distilled from a supervised-fine-tuned T5-XL (~3B) teacher, on XSum (summarisation), WMT en→de (translation) and GSM8K (arithmetic reasoning). All methods start from the same SFT student.
- Headline (Fig. 1). Averaged over student sizes, the improvement over the initial student from on-policy GKD is 2.1× (summarisation), 1.7× (translation) and 1.9× (arithmetic) the improvement from baseline KD methods.
- Data efficiency (Fig. 3). On XSum, on-policy GKD on a 5% subsample, without ground-truth summaries, beats supervised KD and ImitKD trained on the full dataset.
- Divergence vs temperature (Fig. 4). Under temperature sampling, mode-seeking divergences (JSD(0.5), JSD(0.9), reverse KL) give better quality but less diversity (higher Self-BLEU). With greedy decoding the choice matters much less.
- GSM8K (Fig. 8). Performance typically improves once more than 25% of the data is student-generated, and purely student-generated CoTs work best.
- Task-agnostic (Fig. 10). Distilling FLAN T5-XL into T5-large with on-policy GKD (reverse KL best) gives +2% on held-out BBH and +1% on MMLU (absolute).
- RLAIF (Fig. 5). On XSum with a factual-consistency reward, α trades distillation quality (ROUGE-2) against factual consistency.
Limitations & open questions
Section titled “Limitations & open questions”- Shared vocabulary implied. Token-level divergences compare the teacher’s and student’s distributions over the same -token vocabulary (all the paper’s models are T5). Arbitrary teacher–student pairs with different tokenizers need extra machinery that the paper does not address.
- Small, short-output regime. The evidence comes from T5 models up to ~3B with short outputs. Long reasoning traces push student prefixes further from the teacher’s support, where teacher feedback may degrade.
- Divergence is a hyperparameter. There is no rule for choosing it beyond “it depends on the task and temperature”.
- The teacher only grades, never searches. If the student never visits a good region, the teacher’s per-token feedback on bad prefixes may not get it there. This is the gap that privileged teachers and Pedagogical RL target.
Connections
Section titled “Connections”- Map of the family: On-policy distillation: a map compares OPD variants and when to use OPD, RLVR or SFT.
- Before: REINFORCE / policy gradients, imitation learning (DAgger), Hinton-style KD. DAgger queries the expert on states visited by the learner; KD transfers a teacher’s output distribution rather than only hard labels.
- After: On-Policy Distillation (Thinking Machines) scales the reverse-KL, λ = 1 version to reasoning models. OPSD and SDFT make the teacher the same model conditioned on privileged context.
- Concurrent: MiniLLM optimises sequence-level reverse KL with policy gradient. Multi-teacher: MOPD merges several RL specialists by on-policy distillation.
- RL link: the RL + GKD objective is RLHF with the reference model replaced by a teacher. See PPO and InstructGPT.
- Contrast: LUFFY takes the other route. It uses teacher trajectories (off-policy) inside GRPO rather than teacher logits on student trajectories.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Derive / compute
A teacher's next-token distribution over three tokens is p_T = (A 0.49, B 0.49, C 0.02). A weak student can choose Q1 = (0.96, 0.02, 0.02) or Q2 = (0.34, 0.33, 0.33). Compute the forward KL(p_T‖Q) and reverse KL(Q‖p_T) for both, say which student each divergence prefers, and connect the result to the paper's quality vs diversity findings.
What a strong answer covers
- Forward: KL(p_T‖Q1) ≈ 1.24 and KL(p_T‖Q2) ≈ 0.32, so forward KL prefers the spread-out Q2. It is mass-covering: missing B (0.02 vs 0.49) is very costly.
- Reverse: KL(Q1‖p_T) ≈ 0.58 and KL(Q2‖p_T) ≈ 0.67, so reverse KL prefers Q1. It is mode-seeking: putting 0.33 on C, which the teacher gives only 0.02, is very costly.
- Q2 samples C a third of the time, a token the teacher thinks is nearly impossible. This is the low-quality or hallucination failure the paper attributes to forward KL with a low-capacity student under temperature sampling.
- Q1 has less entropy, matching the observed drop in diversity (higher Self-BLEU) as the divergence moves from forward toward reverse KL via JSD(β).
- Mechanism
Why does training on the student's own samples (λ = 1) reduce the train–inference mismatch that supervised KD on a fixed dataset suffers from? Explain in terms of which prefixes y_1..y_(n−1) the student sees during training versus at inference, and what the teacher's token-level distribution provides on a prefix that already contains a student mistake.
What a strong answer covers
- Supervised KD conditions on ground-truth or teacher prefixes. At inference the student conditions on its own prefixes, which drift after its first error, so errors compound (exposure bias, as in imitation learning).
- On-policy KD samples prefixes from the student, so training states match inference states. This is the DAgger idea of an interactive expert labelling the learner's own states.
- On an erroneous prefix the teacher still gives a full next-token distribution that says how to continue or recover from there. Fixed data never contains that recovery signal.
- There is no gradient through the sampling step: the samples are treated as data. This keeps training stable and cheap, and the student's samples improve as it trains.
- What if…
On GSM8K the paper varies the fraction λ of student-generated data and finds performance typically improves once λ exceeds 25%, with purely student-generated chain-of-thought best. Predict what happens at λ = 0, 0.25 and 1 for a weak student, and what would change if the student had not been supervised-fine-tuned first.
What a strong answer covers
- λ = 0 is supervised KD: the student imitates on reference CoT prefixes and never practises recovering from its own reasoning errors.
- Low λ adds a few on-policy samples whose teacher feedback is diluted. Gains appear only once on-policy prefixes make up a substantial share of the data (above about 25% here).
- λ = 1 gives the most on-distribution feedback. The paper's Fig. 8 shows only-student-generated CoTs beating the mixtures.
- Without SFT, student samples could be so poor that teacher feedback on them is uninformative or off-support. The paper explicitly assumes a student of adequate quality, like the SFT stage before RLHF.
- Connect
Show that on-policy GKD with reverse KL is a special case of RL: write the per-token reward that makes the policy-gradient objective equal to −KL(p_S‖p_T) on student samples, and relate it to the paper's RL + GKD objective (1 − α)·E[r] − α·E[D] and to the KL-to-reference penalty in RLHF.
What a strong answer covers
- Reverse KL on student samples is E over y ~ p_S of the sum over n of (log p_S − log p_T). Maximising its negative is RL with per-token reward r_n = log p_T(y_n | y_1..y_(n−1), x) − log p_S(y_n | y_1..y_(n−1), x).
- Unlike RLHF's single end-of-sequence reward, this reward is dense: every token gets graded.
- Eq. 5 mixes a task reward with this distillation term. α = 1 is pure distillation, α = 0 pure RL. With the teacher equal to the initial policy, the D term is exactly RLHF's KL-to-reference regulariser.
- This is why the authors recommend reverse KL or JSD(0.9) when bolting GKD onto an existing RLHF pipeline. It is also the basis of the Thinking Machines on-policy distillation recipe.
- Design
You must distil a 70B LLM reranker that writes a short rationale and then a relevance label into a 1B student for production search, with a fixed GPU budget and an unlabelled query–passage log. Choose λ, the divergence and the training temperature for GKD, state any compatibility constraint between the two models, and say how you would validate the choice.
What a strong answer covers
- Token-level GKD needs the teacher's full next-token distribution on the student's prefixes, so the two models must share a tokenizer and vocabulary, or you need a cross-tokenizer approximation.
- The unlabelled log favours λ near 1: student sampling is cheap, and the teacher only scores (one forward pass), never generates.
- Divergence: if the deployed student decodes greedily, the paper finds the divergence matters little. If you sample (for example for diversity), prefer mode-seeking JSD(0.9) or reverse KL. Label-calibration needs may favour forward KL, which preserves the label distribution.
- Validate the student on ranking metrics (nDCG@10 on held-out judged queries) and calibration of the label probabilities, not just token-level KL. Check diversity only if it matters downstream.
- Critique
GKD's evidence comes from T5 students (77M–800M) and a roughly 3B T5-XL teacher on summarisation, translation and GSM8K, and the best divergence varies by task and temperature. What are the main threats to concluding that "on-policy + mode-seeking" transfers to modern long-chain reasoning distillation, and what experiment would test it?
What a strong answer covers
- Scale and length gap: the outputs are short. Long reasoning traces make early student errors push prefixes far off the teacher's support, where its feedback may be poor (compare the teacher-recovery decay reported in the Pedagogical RL post).
- Task-dependent divergence choice risks per-task tuning on the evaluation metric. A fixed protocol for selecting the divergence on a validation split is needed.
- The metrics (ROUGE-2, BLEU, GSM8K accuracy) do not measure faithfulness, except in the RLAIF experiment.
- Experiment: distil a 32B reasoning model into 1.5B–8B students on AIME-style data, comparing λ ∈ {0, 0.5, 1} × {forward KL, JSD(0.9), reverse KL} at matched FLOPs, with seeds and length-bucketed analysis.