SKDBERT: Compressing BERT via Stochastic Knowledge Distillation

Zixiang Ding, Guoqing Jiang, Shuai Zhang, Lin Guo, Wei Lin

TL;DR

SKDBERT introduces Stochastic Knowledge Distillation (SKD), a method that compresses large models by randomly sampling from a pool of diverse teacher models during training. By treating multi-teacher distillation like Stochastic Gradient Descent (SGD), the authors achieve state-of-the-art performance on GLUE and CIFAR-100 benchmarks with significantly higher efficiency than traditional ensemble methods.

What Problem Does This Paper Address?

Large Language Models (LLMs) like BERT are incredibly capable but notoriously "heavy," making them difficult to deploy on edge devices or in low-latency environments. Knowledge Distillation (KD) is the standard solution: a small "student" model learns to mimic a large "teacher" model.

While using multiple teachers (ensemble distillation) usually yields better results than a single teacher, it comes with a massive computational tax. If you have five teachers, you typically have to run five forward passes for every single training step. This makes training slow and resource-intensive. The authors set out to find a way to capture the "wisdom of the crowd" from multiple teachers without the linear increase in compute cost.

Methods

The core innovation is Stochastic Knowledge Distillation (SKD). Instead of calculating the average output of all teacher models at every iteration (which is analogous to Batch Gradient Descent), SKD randomly selects one teacher from the pool for each training step.

Key components include:

  • The SGD Analogy: The authors provide a mathematical proof showing that the gradient updates in SKD are a stochastic approximation of the full ensemble gradient. Just as SGD allows a model to converge efficiently by looking at one data point at a time, SKD allows a student to converge to the ensemble's performance by looking at one teacher at a time.
  • Diverse Teacher Teams: The researchers used a wide array of BERT-style teachers (ranging from 8 to 24 layers) to provide a rich, varied signal to the student.
  • Sampling Distributions: They experimented with different ways to pick the teacher, including uniform distribution (equal chance) and rank-based sampling (favoring better-performing teachers).

Datasets

The authors evaluated SKDBERT across two distinct domains to prove its generalizability:

  • Natural Language Processing (NLP): The GLUE benchmark, including tasks like MRPC (paraphrase), RTE (entailment), SST-2 (sentiment), QQP (question similarity), QNLI, and MNLI.
  • Computer Vision (CV): The CIFAR-100 image classification dataset, using various ResNet and Wide ResNet (WRN) architectures as teachers and students.

Key Insights and Ideas

  • Efficiency is the "Killer Feature": By only performing one teacher forward pass per step, SKD maintains the training speed of single-teacher distillation while reaping the accuracy benefits of an ensemble.
  • The "Stochastic" Advantage: Surprisingly, the randomness of SKD might act as a form of regularization. The student doesn't just memorize one teacher's quirks; it learns a generalized representation that satisfies the "consensus" of the teacher pool.
  • Cross-Domain Success: The fact that SKD outperformed specialized computer vision distillation methods (like CRD) on CIFAR-100 suggests that the principle of stochastic teacher sampling is a fundamental improvement in distillation theory, not just a BERT-specific trick.

Key Results

  • GLUE Performance: SKDBERT$_6$ (a 6-layer student) achieved an average score of 85.87 on the GLUE-dev benchmark, outperforming the popular TinyBERT baseline.
  • CIFAR-100 Superiority: In head-to-head comparisons against 12 other popular distillation approaches (including KD, FitNet, and CRD), SKD achieved the best performance in 5 out of 6 experimental groups.
  • Teacher Scaling: The results showed that even smaller students (like the 4-layer SKDBERT$_4$) saw significant gains when distilled from a diverse team of teachers compared to being distilled from a single "super-teacher."

Limitations and Future Work

  • Teacher Selection: While the paper explores sampling distributions, it doesn't provide a definitive "recipe" for the perfect teacher team. Choosing which models to include in the pool still requires some empirical trial and error.
  • Adaptive Sampling: The current method uses fixed sampling distributions. A promising future direction mentioned is adaptive sampling, where the system could automatically favor teachers that provide the most "useful" or "challenging" signals to the student as training progresses.
  • Extreme Compression: The paper focuses on 4 and 6-layer students. Exploring how SKD performs when pushing for even more extreme compression (e.g., 1 or 2-layer models) remains an open question.

Summary updated

BibTeX
@inproceedings{ding2023skdbert,
  author = {Zixiang Ding and Guoqing Jiang and Shuai Zhang and Lin Guo and Wei Lin},
  title = {{SKDBERT: Compressing BERT via Stochastic Knowledge Distillation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2023},
  doi = {10.1609/aaai.v37i6.25902},
}
Figure