[Paper Review] Knowledge Distillation from Internal Representations
This paper proposes knowledge distillation from internal representations in BERT-like models, training a student network to match both the soft labels and hidden-layer activations of a large teacher model. By incorporating distillation at multiple internal layers using KL divergence on attention maps and hidden states, the method significantly improves generalization and outperforms standard knowledge distillation across GLUE benchmark datasets.
Knowledge distillation is typically conducted by training a small model (the student) to mimic a large and cumbersome model (the teacher). The idea is to compress the knowledge from the teacher by using its output probabilities as soft-labels to optimize the student. However, when the teacher is considerably large, there is no guarantee that the internal knowledge of the teacher will be transferred into the student; even if the student closely matches the soft-labels, its internal representations may be considerably different. This internal mismatch can undermine the generalization capabilities originally intended to be transferred from the teacher to the student. In this paper, we propose to distill the internal representations of a large model such as BERT into a simplified version of it. We formulate two ways to distill such representations and various algorithms to conduct the distillation. We experiment with datasets from the GLUE benchmark and consistently show that adding knowledge distillation from internal representations is a more powerful method than only using soft-label distillation.
Motivation & Objective
- To address the limitation of standard knowledge distillation, which only transfers output probabilities and may fail to preserve the teacher’s internal linguistic knowledge.
- To improve model compression by transferring not only soft labels but also the internal representations (e.g., attention maps and hidden states) from a large teacher model to a smaller student model.
- To ensure the student model generalizes similarly to the teacher by aligning its internal behavior with that of the teacher, not just its output distribution.
- To develop a method that enhances student performance beyond what is achievable through soft-label distillation alone, especially in low-resource or constrained inference settings.
Proposed method
- The method performs knowledge distillation not only on the final output probabilities but also on intermediate hidden representations across multiple layers of the teacher model.
- It uses KL divergence to match the attention probabilities of the teacher and student models at each layer, capturing high-level linguistic abstractions.
- It applies a separate KL divergence loss between the hidden states of the teacher and student models at selected layers, enabling structural alignment of internal representations.
- The approach supports both progressive and stacked knowledge distillation strategies, allowing flexible compression of multiple teacher layers into a single student layer.
- The student is trained using a combination of cross-entropy loss on hard labels, distillation loss on soft labels, and additional distillation losses on attention maps and hidden states.
- The method avoids introducing additional parameters for representation alignment, unlike prior approaches such as FitNet, by directly matching representations in the same space.
Experimental results
Research questions
- RQ1Can distilling internal representations (e.g., attention maps and hidden states) from a large teacher model improve the generalization and performance of a smaller student model beyond standard knowledge distillation?
- RQ2Does aligning the internal behavior of the student with that of the teacher—beyond matching output probabilities—lead to more robust and accurate predictions, especially on ambiguous or challenging examples?
- RQ3How does internal representation distillation compare to standard KD in terms of error patterns and consistency with the teacher’s predictions?
- RQ4Can the method effectively compress the linguistic knowledge encoded in deep transformer layers without introducing additional parameters or increasing inference complexity?
- RQ5What is the impact of distilling at different layers (e.g., early vs. late) on the final student performance and generalization capability?
Key findings
- The student model trained with internal representation distillation achieved 97.9% of the teacher’s correct predictions on the QQP development set (36,191 out of 36,967), compared to 95.7% (35,401) for standard KD.
- The internally distilled student made 776 incorrect predictions, compared to 1,566 for the standard KD student, indicating better alignment with the teacher’s decision boundaries.
- On the QQP dataset, the internally distilled student correctly identified 100% of the cases where the teacher was correct and the standard KD student failed, such as in sample 3 and 4 from Table 4.
- The method reduced the number of incorrect predictions by more than 50% compared to standard KD when the teacher was correct, demonstrating superior consistency and generalization.
- In cases where the teacher made an error (e.g., sample 1 in Table 4), the internally distilled student was more cautious (probability 0.4221 vs. 0.9999 in standard KD), suggesting reduced overconfidence and better calibration.
- The method consistently outperformed standard KD across all four GLUE benchmark datasets, demonstrating robust gains in both accuracy and alignment with the teacher’s behavior.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.