Skip to content

MiniLLM: On-Policy Distillation of Large Language Models

optionalextendedfundamentalpaperrubric 10/122023 · ICLR 2024 · ~30 min

Yuxian Gu, Li Dong, Furu Wei, Minlie Huang

Read first: On-policy distillation: a map · REINFORCE and the Policy-Gradient Theorem (Williams 1992; Sutton et al. 1999)

Status

TL;DR. MiniLLM is one of the two 2023 papers (with GKD) that started on-policy distillation of LLMs. It replaces the forward KL of standard knowledge distillation with reverse KL KL(qθ ∥ p)\mathrm{KL}(q_\theta\,\|\,p) from student qθq_\theta to teacher pp, optimises it with policy gradient on the student’s own samples, and adds three fixes that alleviate (not eliminate) gaming of the dense reward.

Why it matters now. It is the reference for treating distillation as RL with a per-token reward log⁡p−log⁡qθ\log p - \log q_\theta, which is what MOPD and DeepSeek-V4 cite. Its failure modes (short outputs, repetition) also show early that dense rewards can be hacked. See the OPD map for the whole family.

Why reverse KL. For generation, the teacher’s distribution has many modes a small student cannot all cover. Forward KL forces the student to spread mass over all of them, so it overestimates the teacher’s low-probability (“void”) regions and samples text the teacher would never produce. Reverse KL is mode-seeking: the student concentrates on modes it can model.

Policy-gradient form. With per-token reward rt=log⁡p(yt∣y<t,x)qθ(yt∣y<t,x)r_t = \log \frac{p(y_t\mid y_{\lt t},x)}{q_\theta(y_t\mid y_{\lt t},x)} and return Rt=∑t′≥trt′R_t = \sum_{t'\ge t} r_{t'},

∇θ KL(qθ ∥ p)=− Ey∼qθ[∑t(Rt−1) ∇θlog⁡qθ(yt∣y<t,x)].\nabla_\theta\,\mathrm{KL}(q_\theta\,\|\,p) = -\,\mathbb{E}_{y\sim q_\theta}\Big[\sum_t (R_t - 1)\,\nabla_\theta \log q_\theta(y_t\mid y_{\lt t},x)\Big].

Three fixes.

  1. Single-step decomposition. Split the gradient into the immediate step, whose expectation over yty_t is computed exactly by summing over the vocabulary, and a long-term part using Rt+1R_{t+1}. This reduces variance.
  2. Teacher-mixed sampling. Sample from p~=αp+(1−α)qθ\tilde p = \alpha p + (1-\alpha) q_\theta with α=0.2\alpha = 0.2 and correct with a per-token importance weight. This stops the student from reinforcing degenerate high-likelihood strings.
  3. Length normalisation. Normalise Rt+1R_{t+1} by length, because the raw return favours short or empty responses.

Training also uses PPO-style clipping and adds a language-modelling loss on pretraining data. The student starts from an SFT checkpoint (the one with lowest validation loss).

Instruction following trained on databricks-dolly-15k; evaluated on DollyEval, SelfInst, VicunaEval, S-NI and UnNI with Rouge-L and GPT-4 feedback, five seeds, temperature 1. Students: GPT-2 120M/340M/760M (teacher GPT-2 1.5B), OPT 1.3B/2.7B/6.7B (teacher OPT-13B), LLaMA-7B (teacher LLaMA-13B).

DollyEval (Table 1)SFTKDSeqKDMiniLLM
GPT-2 120M, GPT-4 score / Rouge-L38.6 / 23.340.3 / 22.841.2 / 22.744.7 / 24.6
OPT 1.3B, GPT-4 score52.652.751.060.7
LLaMA-7B, GPT-4 score (teacher 79.0)73.073.773.676.4

Students sometimes beat the teacher on Rouge-L, which the authors attribute to reduced exposure bias. Ablation (§3.4, GPT-2 125M from 1.5B, valid / Dolly Rouge-L): full MiniLLM 27.4 / 24.6; without length normalisation 17.4 / 14.7; without teacher-mixed sampling 22.3 / 20.4; without single-step decomposition 27.0 / 23.7.

  • Short instruction-following responses and models up to 13B; long-chain reasoning, where the cumulative return gets very noisy, is not tested.
  • GPT-4-feedback scores are an LLM judge; Rouge-L is a weak proxy for instruction quality.
  • The machinery (mixing, importance weights, an extra pretraining loss) is heavier than later recipes, and the shared-tokenizer requirement remains.

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.

  1. Derive / compute

    MiniLLM writes the gradient of reverse KL(q_θ‖p) as −E over y ~ q_θ of the sum over t of (R_t − 1)·∇log q_θ(y_t | y_<t, x), with R_t = Σ over t' ≥ t of r_t' and r_t' = log p(y_t' | ·)/q_θ(y_t' | ·). Explain where the cumulative return comes from, why R_t on its own favours short outputs, and how the single-step decomposition and length normalisation change the estimator.

    What a strong answer covers
    • Sequence-level reverse KL is E over y ~ q_θ of log q_θ(y|x) − log p(y|x), which factorises into a sum over positions. Applying the score-function trick and causality, each token's log-prob gradient is weighted by the sum of later per-token log-ratios: a policy gradient with discount 1 and reward r_t' = log p/q_θ.
    • Each r_t' is typically negative (the student puts more mass on its own sample than the teacher does), so a longer response accumulates a more negative return. The estimator therefore rewards stopping early, and empty or very short answers can look good.
    • Single-step decomposition: the immediate term E over y_t ~ q_θ of r_t is computed exactly by summing over the vocabulary at each position, so only the long-term part R_(t+1) is estimated from the sample. This lowers variance.
    • Length normalisation divides R_(t+1) by the number of remaining tokens, turning it into an average per-token log-ratio that no longer penalises length. The §3.4 ablation shows removing it drops Dolly Rouge-L from 24.6 to 14.7.
  2. Mechanism

    Why does MiniLLM sample from a teacher-mixed distribution p̃ = α·p + (1 − α)·q_θ (α = 0.2) rather than the pure student, and what correction does that require? Relate the failure it prevents to reward hacking in RL and to the paper's observation that reverse KL can keep decreasing while outputs degenerate.

    What a strong answer covers
    • Early in training the student can find sequences with high teacher likelihood that are degenerate, for example repeated phrases. The policy gradient reinforces them, and reverse KL still falls: the reward is being hacked.
    • Mixing in teacher samples keeps rollouts near sequences the teacher would actually produce, so the student is graded on sensible states.
    • Samples now come from p̃, not q_θ, so the gradient needs a per-token importance weight w_t ≈ q_θ(y_t)/p̃(y_t) (approximated per token to avoid the high variance of a full-sequence product).
    • Ablation (§3.4, GPT-2 125M from 1.5B): without teacher-mixed sampling Dolly Rouge-L falls from 24.6 to 20.4; without the strategies the authors observe repeated, short or meaningless strings.
  3. Connect

    Compare MiniLLM with the Thinking Machines on-policy distillation recipe and with GKD. All three train on student samples, but they differ in the return (discount), the divergence and how many tokens are graded per position. Which differences matter for distilling a reasoning model that writes 10,000-token chains of thought?

    What a strong answer covers
    • Thinking Machines uses discount 0: each token is graded only by its own log-ratio. MiniLLM uses discount 1 with a length-normalised long-term return; over 10,000 tokens the cumulative return is very noisy, which favours the discount-0 choice.
    • GKD computes the divergence over the full next-token distribution at each position (forward, reverse or JSD), with no policy gradient through future tokens. MiniLLM computes the immediate step exactly over the vocabulary but samples the long-term part.
    • MiniLLM's teacher-mixed sampling and pretraining-loss term add complexity that later recipes drop when the student is already a capable SFT model.
    • All need the teacher's probabilities on student tokens, hence a shared tokenizer. All target the teacher's distribution rather than task reward, which limits supervision but is not a strict score ceiling: MiniLLM's own Table 1 marks student scores above the teacher.

Done with this page?

Status