liveBook · Manning

On-policy distillation

As explained in Reinforcement Learning from Human Feedback

On-policy distillation is distillation in which training examples or trajectories are sampled from the current student policy and evaluated against a teacher policy.

On-policy distillation (OPD) trains a student on completions sampled from its current policy, then compares its next-token distributions with a fixed teacher. This avoids relying only on teacher-generated data, which can create a student–inference distribution mismatch and encourage overestimation of low-probability teacher regions. The resulting optimization uses a reverse-KL objective inside an online policy-gradient reinforcement-learning framework. section 12.3.2

For prompt s, completion a, and token-level state s_t = (s, a_<t), OPD proceeds as follows:

  • Sample a completion from the current student policy πθ(·|s), so training states reflect the behavior encountered during student inference. section 12.3.2
  • Compare the student distribution πθ(·|s_t) with the fixed teacher distribution πT(·|s_t) using reverse KL, DKL(πθ || πT). section 12.3.2
Equation 12.5
\[\label{eq:opd_reverse_kl} \mathcal{L}_{\mathrm{OPD}}(\theta) = \mathbb{E}_{s, a \sim \pi_\theta(\cdot \mid s)} \sum_t D_{\mathrm{KL}}\left(\pi_\theta(\cdot \mid s_t) \;\|\; \pi_T(\cdot \mid s_t)\right).\]

Formalizes the OPD loss as an expectation over student-generated trajectories and token-level reverse-KL comparisons with the teacher. section 12.3.2

Multiple specialist teachers

Multi-teacher OPD combines specialist or intermediate-checkpoint teachers, assigning prompt-dependent weights to their reverse-KL terms. Math and code teachers can therefore contribute differently across a training batch. OPD can also be combined with other advantage computations, while on-policy self-distillation lets a model verify completions itself or with external tools and train a weaker version. section 12.3.3

How Reinforcement Learning from Human Feedback covers it

How deep it goes
Defines student-induced states, reverse-KL loss, and token advantages, while deferring deeper reverse-KL intuition to later treatment.
Examples
Uses student-sampled completions, token-level teacher scores, specialist math and code teachers, and self-verification with external tools.
What it assumes
Requires student and teacher language models that often share a tokenizer for per-token supervision.
What you can do after
Apply it via an online policy-gradient pipeline that samples student trajectories and distills fixed or multiple teacher policies.
How it connects
Connects knowledge distillation with reinforcement learning, policy gradients, imitation learning, DAgger, reverse KL, and reward shaping.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Reinforcement Learning from Human Feedback. The section links point to the parts of the book it draws on.