Model Compression with Two-stage Multi-teacher Knowledge Distillation for Web Question Answering System

Ze Yang, Linjun Shou, Ming Gong, Wutao Lin, Daxin Jiang

TL;DR

Researchers at Microsoft have developed TMKD (Two-stage Multi-teacher Knowledge Distillation), a method to compress massive language models like BERT into smaller, faster versions without sacrificing significant accuracy. By distilling knowledge from multiple "teacher" models across two distinct stages—pre-training on unlabeled data and fine-tuning on specific tasks—they achieved over 10x speedups in inference while maintaining performance comparable to the original heavyweights.

What Problem Does This Paper Address?

Modern web Question Answering (Q&A) systems face a brutal trade-off between accuracy and speed. While deep pre-trained models like BERT and GPT have revolutionized NLP, they are computationally expensive. For a commercial search engine processing billions of queries, the high latency (e.g., ~5.2ms for BERT-large) and massive memory requirements make them difficult to deploy in real-time "tail query" scenarios where budgets are often under 10ms.

Standard model compression techniques, like basic knowledge distillation (where a small "student" model learns from a large "teacher"), often result in a significant performance drop. The authors identify two main culprits:

  1. Information Loss: Small models struggle to capture the complex feature representations of large models during a single fine-tuning step.
  2. Teacher Bias: A single teacher model might overfit or have specific biases that are then passed on to the student.

Methods

The authors propose a two-stage architecture designed to bridge the gap between student and teacher:

  1. Stage 1: Distillation Pre-training: Instead of just pre-training the student on raw text, they use a massive unlabeled Q&A corpus. Multiple teacher models (e.g., different BERT-large variants) score these pairs, providing "soft labels." The student is trained to mimic these scores, allowing it to learn general feature representations from a much larger data pool than human-labeled sets provide.
  2. Stage 2: Multi-teacher Fine-tuning: The pre-trained student is then fine-tuned on specific downstream tasks. Crucially, it learns from multiple teachers simultaneously alongside the "golden" human labels.

The architecture, shown in Figure 1, uses a Multi-header Layer where the student has different "heads" to learn from different teachers. This creates an "early calibration" effect: by seeing multiple teacher perspectives during training, the student avoids inheriting the specific overfitting biases of any single teacher.

The Overall Architecture of TMKD

Datasets

The study utilizes both massive commercial datasets and standard academic benchmarks:

  • DeepQA: A commercial dataset with 1 million labeled Q&A pairs.
  • CommQA-Unlabeled: A massive-scale corpus ranging from 4 million to 100 million unlabeled pairs for pre-training.
  • CommQA-Labeled: 12 million labeled pairs for large-scale evaluation.
  • GLUE Benchmark: Specifically the textual entailment tasks (MNLI, SNLI, QNLI, RTE) to test how well the Q&A-distilled model generalizes to other NLU problems.

Key Insights and Ideas

  • Early vs. Late Calibration: Traditional ensembles (late calibration) combine multiple student models at inference time, which is memory-intensive. TMKD performs "early calibration" by distilling multiple teachers into a single student during training, achieving similar benefits with much lower resource usage.
  • Q&A Pre-training is a Generalist: Surprisingly, pre-training the student on Q&A distillation tasks significantly boosted performance on unrelated GLUE tasks, suggesting that Q&A is an excellent "proxy" task for learning general language logic.
  • The Power of Soft Labels: The authors found that the student benefits more from the "nuance" in teacher scores (soft labels) than from just the binary ground truth. As shown in Figure 3, the best performance occurs when the loss function leans heavily toward the teachers' soft labels ($\alpha \approx 0.9$).
The impact of different loss weighted ratio

Key Results

  • Speed: The student model (a 3-layer BERT variant) achieved an inference speed of 217 Queries Per Second (QPS), compared to just 16 QPS for BERT-large—a nearly 13.5x speedup.
  • Accuracy: On the DeepQA dataset, TMKD achieved 80.43% accuracy, coming remarkably close to the teacher's 81.47%, and significantly outperforming standard 3-layer distillation baselines (77.35%).
  • Teacher-Surpassing Performance: In a remarkable finding, when trained on the extremely large 100M unlabeled dataset, the TMKD student actually outperformed its teacher (79.22% vs 77.00%), proving that multi-teacher distillation can effectively filter out individual model noise.
Performance comparison on DeepQA and MNLI

Limitations and Future Work

While highly effective, the paper notes a few areas for further exploration:

  • Teacher Selection: The current method uses teachers with different hyperparameters. The authors suggest that exploring more diverse teacher architectures might yield even better results.
  • Task Expansion: The study focuses primarily on classification and ranking tasks. Future work could extend this two-stage distillation to sequence labeling (like NER) or machine reading comprehension.
  • Layer Count Trade-offs: The authors settled on a 3-layer student as the "sweet spot" for performance vs. latency, but note that this balance might shift depending on specific hardware constraints.

Summary updated

BibTeX
@inproceedings{yang2020model,
  author = {Ze Yang and Linjun Shou and Ming Gong and Wutao Lin and Daxin Jiang},
  title = {{Model Compression with Two-stage Multi-teacher Knowledge Distillation for Web Question Answering System}},
  booktitle = {WSDM},
  year = {2020},
  doi = {10.1145/3336191.3371792},
}
Figure