On-Policy Distillation of Language Models: Learning from Self-Generated Mistakes

Rishabh Agarwal, Nino Vieillard, Yongchao Zhou, Piotr Stanczyk, Sabela Ramos Garea, Matthieu Geist, Olivier Bachem

TL;DR

Generalized Knowledge Distillation (GKD) fixes the "distribution mismatch" in language model compression by training student models on their own generated sequences rather than fixed datasets. By combining on-policy data with flexible loss functions, GKD allows tiny models to significantly outperform traditional distillation methods and even rival massive models like PaLM-540B on specific tasks.

What Problem Does This Paper Address?

Large Language Models (LLMs) are powerful but expensive to run. Knowledge Distillation (KD) is the standard way to "compress" a giant teacher model into a nimble student model. Traditionally, this is done by showing the student a fixed dataset and telling it to mimic the teacher's probability distribution for those specific words.

However, this creates a major problem known as distribution mismatch or exposure bias. During training, the student only sees "perfect" sequences (from the teacher or ground truth). But at inference time, the student generates text one token at a time. If it makes a small mistake early on, it enters a state it never saw during training. These errors cascade, leading to hallucinations or gibberish. It’s like teaching someone to drive by only showing them videos of a professional on a clear highway; they won't know how to recover when they hit a pothole.

Methods

The authors introduce Generalized Knowledge Distillation (GKD), which shifts the training from "off-policy" (fixed data) to "on-policy" (student-generated data).

The core algorithm works as follows:

  1. On-Policy Sampling: Instead of just reading a dataset, the student model generates its own output sequences for a given prompt.
  2. Teacher Feedback: The teacher model evaluates the student's generated sequences and provides the "correct" probability distribution for every token the student produced.
  3. Flexible Divergence: Unlike standard KD which almost exclusively uses "Forward KL" divergence, GKD allows for "Reverse KL" or "Generalized Jensen-Shannon Divergence (JSD)."
    • Forward KL (Mode-covering) forces the student to try and capture every possible thing the teacher might say.
  4. Reverse KL (Mode-seeking) allows the student to focus on the most likely "modes," which is often better when the student is too small to capture the teacher's full complexity.

GKD also introduces a hyperparameter to mix student-generated data with traditional ground-truth data.

Datasets

The researchers evaluated GKD across several diverse benchmarks using the T5 model family (ranging from 77M to 3B parameters):

  • XSum: Abstractive summarization of news articles.
  • WMT en-de: Machine translation from English to German.
  • GSM8K: Grade school math word problems requiring multi-step reasoning (Chain-of-Thought).
  • MMLU & BBH: Massive Multitask Language Understanding and BIG-bench Hard for task-agnostic instruction tuning.

Key Insights and Ideas

  • Mistakes are the Best Teachers: The most critical finding is that training on "on-policy" data—sequences the student is actually likely to produce—is far more effective than training on high-quality teacher sequences. It allows the student to learn how to "self-correct" or stay on track.
  • Capacity Mismatch Matters: If a student model is much smaller than the teacher, trying to mimic the teacher perfectly (Forward KL) can actually hurt. Using mode-seeking losses (Reverse KL) helps the student "specialize" in high-probability outputs, reducing hallucinations.
  • Surpassing the Giants: In one of the most striking results, a T5-small model (77M parameters) distilled via GKD was able to outperform the few-shot performance of PaLM (540B parameters) on the XSum summarization task—a 7000x difference in parameter count.
  • RL Integration: GKD can be combined with Reinforcement Learning (RLAIF). By using GKD as a regularizer during RL fine-tuning, the authors improved factual consistency in summaries without sacrificing general quality.

Key Results

Performance of GKD compared to baseline distillation methods across XSum, WMT, and GSM8K tasks.
  • Summarization: GKD achieved a 2.1x relative gain in ROUGE-2 scores over baseline KD methods across various student sizes.
  • Reasoning: On GSM8K (math reasoning), on-policy GKD provided a 1.9x relative improvement in accuracy.
  • Instruction Tuning: GKD improved absolute accuracy on held-out benchmarks (MMLU/BBH) by 1-2% compared to standard supervised distillation.
  • Data Efficiency: On-policy GKD using only 5% of the training data outperformed standard KD using 100% of the data.
Data efficiency of GKD on the XSum task, showing that 5% of data with GKD outperforms 100% with standard KD.

Limitations and Future Work

  • Computational Cost: Generating sequences from the student during training is more computationally expensive than reading a fixed dataset. The authors note a 1.8x to 2.2x overhead, though they argue this is a small price to pay for the massive gains in performance and reduced inference-time costs.
  • Starting Point: GKD works best when the student has already undergone some initial Supervised Fine-Tuning (SFT). It is not intended for training a model from scratch.
  • Future Directions: The authors suggest extending GKD to other auto-regressive domains beyond text, such as audio, video, and image generation.

Summary updated

BibTeX
@inproceedings{agarwal2024policy,
  author = {Rishabh Agarwal and Nino Vieillard and Yongchao Zhou and Piotr Stanczyk and Sabela Ramos Garea and Matthieu Geist and Olivier Bachem},
  title = {{On-Policy Distillation of Language Models: Learning from Self-Generated Mistakes}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=3zKtaqxLhW},
}
Figure