Lifting the Curse of Capacity Gap in Distilling Large Language Models

Chen Zhang, Yang Yang, Jiahao Liu, Jingang Wang, Wei Wu, Benyou Wang, Dawei Song

TL;DR

This paper tackles the "curse of capacity gap" in knowledge distillation for large language models (LLMs), where larger teacher models can surprisingly lead to worse student performance. They introduce MiniMoE, a novel student architecture that significantly increases capacity with minimal inference cost by using sparse Mixture-of-Experts (MoE) in its feed-forward networks. MiniMoE effectively lifts this curse, achieving state-of-the-art performance for compressed LLMs while preserving nearly 95% of the teacher's performance with up to 50x compression.

What Problem Does This Paper Address?

Large Language Models (LLMs) like BERT and GPT have revolutionized natural language processing, but their massive size makes them computationally expensive for inference. Knowledge distillation (KD) is a popular technique to create smaller, more efficient "student" models that mimic the performance of larger "teacher" models. However, a significant challenge arises when there's a large "capacity gap" between the teacher and the student. This phenomenon, termed the "curse of capacity gap," can lead to a surprising degradation in the student model's performance, even worse than distilling from a smaller teacher. While this curse has been observed and studied in computer vision, it remains a persistent issue in LLM distillation, hindering the creation of truly efficient yet powerful models.

Methods

The core innovation of this paper is MiniMoE (Mixture of Minimal Experts). Inspired by the success of Mixture-of-Experts (MoE) architectures in scaling up models, MiniMoE applies this concept to the student model in distillation. Instead of a standard feed-forward network (FFN) within each transformer layer, MiniMoE uses a set of "minimal experts" (smaller FFNs) and a gating mechanism to select which expert to use for a given input. This allows the student model to have a much larger effective capacity (more parameters) without a proportional increase in inference compute, as only a subset of experts are activated.

Key aspects of MiniMoE:

  • Minimal Experts: Each expert is a small FFN, designed to be efficient.
  • Sparse Activation: A gating network routes inputs to only one (top-one gating) or a few experts, keeping inference costs low.
  • Capacity Enlargement: By adding multiple experts, the total parameter count of the student increases significantly, addressing the capacity gap.
  • Relation Alignment: The paper also employs a relation alignment strategy for distillation, which helps in matching the teacher's knowledge more effectively.

Datasets

The authors conducted experiments on the following standard NLP benchmarks:

  • GLUE: A collection of diverse natural language understanding tasks, including SST-2 (sentiment analysis) and MNLI (natural language inference).
  • CoNLL: A dataset for token classification (named entity recognition).
  • Wikipedia: Used for task-agnostic distillation.

The paper also mentions experiments on Chinese datasets like TNews, AFQMC, and OCNLI when evaluating on larger models like Chinese BERTxlarge.

Key Insights and Ideas

  • The "Curse" is Real and Pervasive in LLMs: The paper provides strong empirical evidence that the curse of capacity gap is a significant problem in LLM distillation, not just a theoretical concern.
  • MoE for Students, Not Just Teachers: While MoE is typically used to scale up large teacher models, this work ingeniously applies the MoE principle to the student model to increase its capacity without incurring high inference costs.
  • Capacity vs. Compute Trade-off: MiniMoE offers a novel way to decouple model capacity from inference compute, a critical factor for deploying LLMs.
  • Minimal Experts are Key: The "minimal" aspect of the experts is crucial. It's not just about having many experts, but about having efficient experts that, when combined sparsely, create a powerful yet lean student.
  • Vision Distillation Methods Don't Directly Translate: The paper notes that methods successful in vision model distillation don't always perform well on LMs, highlighting the unique challenges of distilling transformer-based models.

Key Results

  • Lifting the Curse: MiniMoE effectively mitigates the curse of capacity gap, showing performance improvements when distilling from larger teachers (BERTlarge) compared to smaller ones (BERTbase) for the same student architecture. For instance, MiniMoE3L;384H distilled from BERTlarge showed a 0.5 performance gain over BERTbase on GLUE.
  • State-of-the-Art Performance: MiniMoE achieves state-of-the-art results among compressed models at comparable FLOPs.
  • High Compression with High Performance: With compression rates as high as ~50x, MiniMoE preserves approximately 95% of the teacher's GLUE score. For example, MiniMoE6L;384H achieved a GLUE score of 84.7, very close to the BERTbase teacher's 86.7, while using significantly fewer GFLOPS.
  • Practical Inference Speed: MiniMoE maintains a good balance between compression and inference speed, with some configurations showing significant throughput gains.

Limitations and Future Work

  • Extreme Cases: The paper notes that MiniMoE can sometimes struggle in "extreme cases" (very high compression ratios), but suggests that these can be improved with teacher assistants (TA).
  • Memory Efficiency: While MiniMoE excels in compute efficiency, it can introduce more parameters than a dense MiniLM. The authors explore parameter decomposition (like SVD) as a potential avenue to improve memory efficiency, suggesting it could yield similar memory footprints to MiniLM.
  • Scalability to Larger Models: The paper investigates MiniMoE on Chinese BERTxlarge, showing potential but also highlighting the challenges and computational cost of distilling extremely large models. Future work could explore more efficient methods for such large-scale distillation.
  • Expert Number Trade-off: The impact of the number of experts was studied, revealing a trade-off where too many experts can lead to diminishing returns or even performance degradation, especially for smaller students. Further research into optimal expert configurations is suggested.

Summary updated

BibTeX
@inproceedings{zhang2023lifting,
  author = {Chen Zhang and Yang Yang and Jiahao Liu and Jingang Wang and Wei Wu and Benyou Wang and Dawei Song},
  title = {{Lifting the Curse of Capacity Gap in Distilling Large Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.249},
}
Figure