TL;DR
This paper investigates whether knowledge distillation (KD) is truly superior to pretraining from scratch for creating smaller language models (LMs) when computational budgets are fixed. Surprisingly, while simpler KD methods perform comparably to pretraining from scratch, more advanced KD techniques like TinyBERT and MiniLM significantly outperform it, especially when data is limited.
What Problem Does This Paper Address?
Knowledge distillation (KD) is a popular technique for compressing large, pre-trained language models (LMs) into smaller, more efficient student models. The core idea is to train the student model to mimic the behavior of a larger "teacher" model. However, KD introduces an extra forward pass through the teacher model during pretraining, which increases computational cost and slows down training throughput.
The authors highlight a critical gap in existing research: most KD studies don't compare it directly against pretraining from scratch (No-KD) under a fair setup. A fair setup means using the same model architecture for the student and, crucially, the same fixed computation budget. Because KD has an overhead, a fixed budget means No-KD can process more data (tokens) than KD. This leads to the central question: is KD still the best approach for creating small LMs when computational resources are limited and data processing capacity is a key differentiator? The authors hypothesize that No-KD might be just as good, if not better, under these fair conditions.
Methods
The paper compares several knowledge distillation strategies against pretraining from scratch for masked language modeling (MLM). The key to their methodology is establishing a fair experimental setup with respect to both computation budget and pretraining data.
They compare:
- No-KD: Pretraining a student model from scratch without any distillation.
- Vanilla-KD: A basic form of KD where the student mimics the teacher's output logits.
- TinyBERT: A more sophisticated KD method that distills knowledge from multiple levels of the teacher model, including embeddings, attention scores, and hidden states.
- MiniLM: Another advanced KD method that focuses on distilling the self-attention distributions and value relations from the teacher's last attention module.
The experiments were conducted using two model sizes: a 6-layer BERT student and a 12-layer BERT student, with a larger BERTbase or BERTLarge model serving as the teacher. They specifically focused on distilling from the last layer of the teacher, as they found no significant benefit from distilling multiple layers.
Datasets
- Training Data: Toronto BooksCorpus and English Wikipedia.
- Evaluation Benchmark: General Language Understanding Evaluation (GLUE) benchmark. The paper provides a brief overview of the GLUE datasets used: COLA, SST-2, MRPC, QQP, STS-B, MNLI, QNLI, and RTE.
Key Insights and Ideas
- Fairness is Crucial: The paper strongly emphasizes the importance of comparing KD and No-KD under identical computational budgets. This is where the core of their investigation lies.
- Simple KD Isn't Always Better: Vanilla-KD, which mimics the teacher's output logits, performs comparably to pretraining from scratch (No-KD) when the budget is fixed and data is unlimited. This suggests that the overhead of KD might negate its benefits in simpler forms.
- Advanced KD Shines: More sophisticated KD strategies like TinyBERT and MiniLM significantly outperform No-KD, even under a fixed compute budget. This indicates that these methods are more effective at extracting valuable knowledge from the teacher.
- Data Scarcity Favors KD: When the available data is limited within a fixed compute budget (requiring data repetition), KD strategies show a much larger advantage over No-KD. This is because KD models can extract more information from the limited data, while No-KD, though faster per token, needs more data to scale effectively.
- COLA Anomaly: Interestingly, No-KD6 (the 6-layer model pretrained from scratch) showed superior performance on the COLA (Corpus of Linguistic Acceptability) task compared to other strategies, even when data was unlimited. This suggests that COLA might benefit from the raw, unadulterated learning process of pretraining from scratch, or perhaps it requires a specific type of data exposure that No-KD provides more effectively in this setup.
Key Results
Unlimited Data, Fixed Compute Budget: * Token Throughput: No-KD models achieved approximately 1.8 times higher token throughput than KD models, highlighting the computational overhead of KD. * 6-Layer Models: * No-KD6 performed comparably to Vanilla-KD6 (average difference of 0.4 points on GLUE). * TinyBERT6 outperformed No-KD6 by an average of 1.5 points. * MiniLM6 outperformed No-KD6 by an average of 1.2 points. * 12-Layer Models: Similar trends were observed, with MiniLM12 showing a 1.4-point advantage over No-KD12. * COLA Performance: No-KD models consistently outperformed other strategies on the COLA task.
Limited Data, Fixed Compute Budget: * 6-Layer Models: * No-KD6 significantly underperformed compared to all KD strategies, lagging behind Vanilla-KD6 by 1.3 points and MiniLM6/TinyBERT6 by 1.8-2.4 points on average. * Vanilla-KD6 showed a substantial performance increase (13.5 points) when data was repeated, underscoring the need for sufficient token exposure.
Limitations and Future Work
- Compute Budget Measurement: The authors acknowledge that using wall-clock time as a proxy for compute budget has inherent limitations due to hardware fluctuations and background processes. However, they observed negligible variations in their runs.
- Data Size: While KD consistently outperformed No-KD even with their chosen data scale, exploring larger pretraining corpora could be beneficial.
- Shared Corpus: The fact that the teacher and student used the same pretraining corpus might influence KD strategies.
- Model Sizes and Architectures: The study focused on encoder-only models of moderate sizes. The authors suggest that future work should investigate KD vs. No-KD across a wider range of model sizes and architectures, particularly large decoder-only models.
- Teacher Budget: The impact of the teacher's computational budget on the fairness of the comparison was not extensively explored and warrants further investigation.
Summary updated