[Paper Review] On-Policy Context Distillation for Language Models
OPCD trains a student to imitate a context-conditioned teacher by on-policy sampling and reverse KL, enabling internalization of experiential knowledge and system prompts across math, games, and domain tasks, outperforming off-policy context distillation.
Context distillation enables language models to internalize in-context knowledge into their parameters. In our work, we propose On-Policy Context Distillation (OPCD), a framework that bridges on-policy distillation with context distillation by training a student model on its own generated trajectories while minimizing reverse Kullback-Leibler divergence against a context-conditioned teacher. We demonstrate the effectiveness of OPCD on two important applications: experiential knowledge distillation, where models extract and consolidate transferable knowledge from their historical solution traces, and system prompt distillation, where models internalize beneficial behaviors encoded in optimized prompts. Across mathematical reasoning, text-based games, and domain-specific tasks, OPCD consistently outperforms baseline methods, achieving higher task accuracy while better preserving out-of-distribution capabilities. We further show that OPCD enables effective cross-size distillation, where smaller student models can internalize experiential knowledge from larger teachers.
Motivation & Objective
- Address limitations of off-policy context distillation (exposure bias and mode issues).
- Propose On-Policy Context Distillation (OPCD) to learn from the student’s own trajectories against a context-conditioned teacher.
- Demonstrate OPCD on experiential knowledge distillation and system prompt distillation across math, games, and domain tasks.
- Show that OPCD supports cross-size distillation where smaller models learn from larger teachers and reduces forgetting.
Proposed method
- Minimize the reverse KL divergence between the student and a context-aware teacher using on-policy samples.
- Compute token-level D_KL via a top-k token approximation, promoting mode-seeking behavior.
- Train by having the student generate responses without the context, then align with the teacher’s distribution conditioned on the context.
- Allow flexible teacher configurations (teacher-student with a frozen teacher or self-distillation with shared weights).
- Evaluate on experiential knowledge and system prompt distillation tasks across math problems, text-based games, medical, and safety prompts, comparing to an off-policy context distillation baseline.
Experimental results
Research questions
- RQ1Can on-policy context distillation internalize transient in-context knowledge into model parameters?
- RQ2Does OPCD improve experiential knowledge consolidation and system prompt distillation across domains?
- RQ3Can smaller student models benefit from larger, possibly frozen teachers via OPCD?
- RQ4Does OPCD mitigate forgetting on out-of-distribution tasks compared to off-policy methods?
Key findings
- OPCD outperforms off-policy context distillation in test accuracy on math problems and text-based games.
- OPCD yields better out-of-distribution (OOD) performance while preserving in-distribution accuracy.
- System prompt distillation with OPCD achieves higher medical and safety task accuracy than off-policy baselines.
- OPCD enables effective cross-size distillation, with smaller models benefiting from large frozen teachers.
- On-policy training provides more stable improvements and mitigates forgetting on OOD data compared to off-policy methods.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.