Towards the Law of Capacity Gap in Distilling Language Models

Chen Zhang, Dawei Song, Zheyu Ye, Yan GaoarXiv 2023 · DOI

Introduction: Breaking the "Impossible Triangle"

In the development of Large Language Models (LLMs), the prevailing heuristic has been that larger teacher models inevitably yield better student models through knowledge distillation. However, recent research reveals a significant bottleneck: the Curse of Capacity Gap. When the disparity between teacher and student size is too large, the student's performance degrades.

This challenge is encapsulated in the "Impossible Triangle" of distillation, where researchers traditionally struggle to balance high student performance, optimal teacher selection, and low computational overhead.

The Impossible Triangle of LLM distillation.

The Curse of Capacity Gap

Knowledge Distillation (KD) aims to transfer reasoning capabilities from a large teacher to a compact student. The "Goldilocks zone"—an optimal teacher size—is critical. As shown in empirical studies with GPT-2 and Pythia families, a teacher that is too large (e.g., GPT2-xlarge for a 300M student) can result in higher perplexity compared to a more moderately sized teacher (GPT2-large).

Perplexity results showing the capacity gap effect.

The Law of Capacity Gap

To resolve this, researchers from the Beijing Institute of Technology proposed a mathematical "Law of Capacity Gap." By analyzing various model families and pruning ratios, they discovered a near-perfect linear relationship ($R^2 = 0.9957$) between the student scale ($S$) and the optimal teacher scale ($T^*$):

$$T^* \approx 2.5 \cdot S$$

This law suggests that the most effective teacher is consistently about 2.5 times the size of the target student. This finding eliminates the need for expensive "enumerative" trials, effectively breaking the Impossible Triangle by providing a direct path to the optimal teacher.

Methodology: From Theory to MiniMA

To validate this law at scale, the researchers developed MiniMA, a 3B-parameter model distilled from LLaMA2-7B and LLaMA3.1-8B (adhering to the ~2.5x ratio).

  1. Symmetric Pruning: Instead of global pruning, which can lead to irregular architectures, the team used "symmetric pruning." This method removes attention heads and neurons based on gradient-based expressive scores while maintaining uniform layer shapes, ensuring compatibility with standard hardware kernels.
  2. Distillation & Tuning: The student was aligned using standard cross-entropy loss on a 126-billion token dataset. It was further refined into MiniChat using a 1.1 million example instruction-following dataset.

Key Results and Benchmarks

MiniMA-3B establishes a new state-of-the-art for compute-efficient language models:

  • Superior Performance: It outperformed other 3B models like ShearedLLaMA and StableLM-3B across MMLU, GSM8K, and HumanEval.
  • Validation of the Law: A 3B student distilled from a 7B teacher (per the law) outperformed versions distilled from 13B or 70B teachers.
  • Instruction Following: MiniChat-3B surpassed scale-matched competitors and rivaled some 7B models on reasoning benchmarks.

Conclusion and Future Directions

The Law of Capacity Gap provides a predictable framework for efficient model compression. While the 2.5x constant is robust across the tested scales, future work is needed to determine if this ratio holds for ultra-large models (e.g., 400B+ parameters) and how advanced distillation techniques might influence the optimal gap. Nonetheless, MiniMA demonstrates that smaller, well-taught models can define the new Pareto frontier of LLM performance.

Summary updated

BibTeX
@misc{zhang2023towards,
  author = {Chen Zhang and Dawei Song and Zheyu Ye and Yan Gao},
  title = {{Towards the Law of Capacity Gap in Distilling Language Models}},
  year = {2023},
  eprint = {2311.07052},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2311.07052},
}
Figure