Abstract
Knowledge Distillation (KD) is one of the widely known methods for model compression. In essence, KD trains a smaller student model based on a larger teacher model and tries to retain the teacher model's level of performance as much as possible. However, existing KD methods suffer from the following limitations. First, since the student model is smaller in absolute size, it inherently lacks model capacity. Second, the absence of an initial guide for the student model makes it difficult for the student to imitate the teacher model to its fullest. Conventional KD methods yield low performance due to these limitations. In this paper, we propose Pea-KD (Parameter-efficient and accurate Knowledge Distillation), a novel approach to KD. Pea-KD consists of two main parts: Shuffled Parameter Sharing (SPS) and Pretraining with Teacher's Predictions (PTP). Using this combination, we are capable of alleviating the KD's limitations. SPS is a new parameter sharing method that increases the student model capacity. PTP is a KD-specialized initialization method, which can act as a good initial guide for the student. When combined, this method yields a significant increase in student model's performance. Experiments conducted on BERT with different datasets and tasks show that the proposed approach improves the student model's performance by 4.4% on average in four GLUE tasks, outperforming existing KD baselines by significant margins.
Introduction
Large language models like BERT-base have revolutionized natural language processing but remain computationally expensive to deploy in low-latency or resource-constrained environments. Knowledge Distillation (KD) is a standard technique to address this, where a large "teacher" model transfers its knowledge to a smaller "student" model. However, traditional KD often struggles with two primary hurdles: the Capacity Gap, where the student lacks the parameters to capture complex nuances, and the Initialization Gap, where starting from a truncated version of the teacher provides a poor foundation for imitation.
Pea-KD (Parameter-efficient and accurate Knowledge Distillation) addresses these issues through a two-pronged strategy: Shuffled Parameter Sharing (SPS) and Pretraining with Teacher's Predictions (PTP).
Methodology
Shuffled Parameter Sharing (SPS)
To overcome the capacity gap without increasing the actual parameter count, Pea-KD employs Shuffled Parameter Sharing. This method increases the "effective capacity" of the student model through a two-step process:
- Layer Stacking: The student model's depth is doubled by sharing parameters between the bottom and top halves. For instance, a 3-layer student is expanded into a 6-layer model where the fourth layer shares weights with the first, the fifth with the second, and so on.
- Parameter Shuffling: Within the shared upper layers, the Query (Q) and Key (K) parameters of the self-attention mechanism are swapped. This forces the shared weights to perform different functions in different layers, acting as a regularization technique that encourages the model to learn more diverse features.
Pretraining with Teacher’s Predictions (PTP)
To bridge the initialization gap, Pea-KD introduces a specialized "warm-up" phase. Instead of immediate task-specific distillation, the student is first trained to predict the teacher's level of confidence. The teacher's outputs are categorized into four "meta-labels":
- Confidently Correct
- Unconfidently Correct
- Confidently Wrong
- Unconfidently Wrong
By learning to predict these labels, the student gains an initial understanding of the teacher's "intuition"—specifically identifying which examples the teacher finds difficult—before the final distillation process begins.
Experimental Results
The researchers evaluated Pea-KD against the GLUE (General Language Understanding Evaluation) benchmark, focusing on tasks such as SST-2, QNLI, RTE, and MRPC.
Performance Gains
Pea-KD demonstrated a significant performance boost, improving student accuracy by an average of 4.4% over the standard PatientKD baseline. In specific scenarios, such as a 1-layer student on the QNLI task, the improvement reached as high as 14.8%. Furthermore, a 6-layer Pea-KD student outperformed established models like DistilBERT by 5.6% and TinyBERT by 1.3%.
Training Efficiency
A major advantage of Pea-KD is its efficiency. Unlike models that require extensive Masked Language Modeling (MLM) pretraining, Pea-KD achieves state-of-the-art results using only downstream task data. While DistilBERT requires approximately 90 hours on eight V100 GPUs, Pea-KD models can reach peak performance in under an hour on just two NVIDIA T4 GPUs.
Conclusion
Pea-KD offers a robust solution to the inherent limitations of Knowledge Distillation for BERT. By effectively doubling model depth through SPS and providing a better starting point via PTP, it achieves superior accuracy with a fraction of the training time required by other methods. Future work will explore the application of these techniques to other transformer architectures like GPT and RoBERTa, as well as their synergy with weight pruning and quantization.
Summary updated