Abstract
Large-scale pre-trained language models (PLMs) deliver exceptional performance across natural language understanding tasks but are often too computationally intensive for deployment on resource-constrained devices. Knowledge Distillation (KD) is a widely adopted technique for model compression, yet standard approaches frequently fail to capture the nuanced structural information residing within a teacher model's intermediate layers. We present CILDA (Contrastive Intermediate Layer Knowledge Distillation), a framework that integrates adversarial data augmentation with contrastive learning to enhance the distillation process. By employing a min-max training strategy, CILDA generates "hard" adversarial samples that maximize divergence in intermediate representations, forcing the student model to align its internal logic with the teacher. Our evaluations on the GLUE benchmark and various out-of-domain datasets demonstrate that CILDA achieves state-of-the-art performance and superior robustness compared to existing distillation methods.
Introduction
The deployment of massive models like RoBERTa-large on edge devices remains a significant challenge due to their high latency and memory requirements. While Knowledge Distillation allows a smaller "student" model to learn from a "teacher," the effectiveness of this process is often limited by the availability of diverse training data. Previous attempts to address this through adversarial data augmentation have primarily focused on matching final output logits, neglecting the rich linguistic features encoded in the teacher's internal layers. CILDA addresses this limitation by incorporating intermediate layer matching via a contrastive objective directly into the data augmentation loop.
Methodology: The Min-Max Training Loop
CILDA utilizes a two-step adversarial training process to refine the student model's understanding of the teacher's internal representations.
1. The Maximization Step (Generator Training)
In this phase, a generator model $G_\phi$ (such as BERT) creates augmented text samples $X'$ by perturbing masked versions of the input. The objective is to find samples where the student’s internal representations most significantly diverge from the teacher’s. This is achieved through a Contrastive Distillation Loss ($L_{CRD}$), which pushes the student to explore areas of the feature space where its internal "thought process" differs from the teacher's.
2. The Minimization Step (Student Training)
The student model $S_\theta$ is subsequently trained on a combination of original and generated "hard" samples. The goal is to minimize the discrepancy between the student's outputs and internal layers and those of the teacher, effectively closing the gap identified in the maximization step.
Experimental Results
We evaluated CILDA using a 24-layer RoBERTa-large teacher and a 6-layer DistilRoBERTa student across the GLUE benchmark and several out-of-domain (OOD) datasets.
GLUE Benchmark Performance
CILDA consistently outperformed strong baselines, including Vanilla-KD and MATE-KD. As shown in the results table, CILDA achieved an average score of 84.5, establishing a new state-of-the-art for this configuration.
Robustness and Generalization
The framework's focus on internal alignment yields significant gains in out-of-domain robustness. On the HANS dataset, which tests linguistic heuristics, CILDA achieved a score of 68.1, markedly higher than MATE-KD (66.6) and Vanilla-KD (58.9). This suggests that by learning the teacher's internal logic, the student becomes less prone to over-relying on superficial patterns in the training data.
Conclusion
CILDA demonstrates that aligning the internal "thought processes" of student and teacher models through contrastive adversarial augmentation is a powerful strategy for model compression. While the approach introduces some computational overhead during training, the resulting gains in both standard performance and out-of-domain robustness make it a compelling choice for producing efficient, high-quality language models.
Summary updated