Seedlabs
Source research

On-Policy Context Distillation for Language Models

Tianzhu Ye, Li Dong, Xun Wu, Shaohan Huang, Furu Wei · 2026 · 240 citationsRead the paper

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.

What the full text shows

Working prototype
  • OPCD outperforms off-policy context distillation and base models in experiential knowledge consolidation across math and text-game tasks. — 76.7% accuracy for Llama-3.1-8B-Ins (vs 75.2% Context Distill. and 68.4% Base) (Experiential knowledge distillation on DAPO-Math-17K)
  • OPCD enables smaller student models to internalize experiential knowledge from larger teachers, whereas direct in-context injection of that knowledge can degrade performance. — Consistent improvement across Qwen3-1.7B, 4B, and 8B scales (Cross-size distillation from Qwen3-8B teacher)
  • OPCD improves accuracy in system prompt distillation for medical and safety tasks compared to off-policy baselines. — 79.6% accuracy for Llama-3.1-8B-Ins on Medical (vs 77.2% Context Distill.) (Medical system prompt distillation using MedMCQA)
  • OPCD mitigates catastrophic forgetting on out-of-distribution (OOD) tasks compared to off-policy context distillation. — Approximately 4 points higher accuracy on medical OOD task; 2% higher IF-Eval scores on Frozen Lake (Distilling safety system prompts into Qwen2.5-3B-Instruct)
  • Teacher-student distillation is more stable and effective than self-distillation. — 53.9% accuracy vs 18.8% for self-distillation on Sokoban (Experiential knowledge distillation using Qwen3-4B-Instruct)
Setup
Evaluated on DAPO-Math-17K, Frozen Lake, Sokoban, MedMCQA, and safety datasets (Tweet Eval, Hatecheck, Ethos) using Llama-3.1/3.2 and Qwen2.5/3 models ranging from 1.7B to 8B parameters.
How
The framework uses on-policy sampling where a student model generates trajectories without context, and is trained to minimize the reverse Kullback-Leibler (KL) divergence against a teacher model conditioned on the context. The reverse KL is approximated by restricting the summation to the top-k tokens predicted by the student.
Limitations
Requires a teacher model to be available during the training phase · Computational overhead of on-policy rollout during training

Summarized by Gemma 4 from the open-access full text · 28 Nov 2026. Read it