ReAugKD: Retrieval-Augmented Knowledge Distillation For Pre-trained Language Models

Jianyi Zhang, Aashiq Muhamed, Aditya Anantharaman, Guoyin Wang, Changyou Chen, Kai Zhong, Qingjun Cui, Yi Xu, Belinda Zeng, Trishul Chilimbi, Yiran Chen

Introduction

Large-scale pre-trained language models (PLMs) like BERT and RoBERTa have revolutionized natural language processing but remain computationally prohibitive for deployment on edge devices. Knowledge Distillation (KD) has emerged as the standard technique to mitigate this, where a compact "student" model is trained to mimic a larger "teacher." However, traditional KD is constrained by the student's parametric memory—its fixed number of weights. Once training concludes, the teacher's nuanced knowledge is typically lost to the student.

ReAugKD (Retrieval-Augmented Knowledge Distillation) overcomes this bottleneck by providing the student with a "cheat sheet": a non-parametric external memory of the teacher's knowledge. By allowing the student to query this memory during inference, ReAugKD effectively expands model capacity without a significant increase in parameter count or latency.

Methodology

The ReAugKD framework operates in two distinct phases: training for alignment and inference for augmentation.

1. Training Phase: Aligning Embedding Spaces

For retrieval to be effective, the student's query must reside in the same semantic space as the teacher's stored knowledge.

  • Projection Head: A linear projection head is added to the teacher to map its high-dimensional embeddings into the student's lower-dimensional space. This is fine-tuned using a supervised contrastive loss.
  • Relational KD Loss: The authors introduce a novel loss function that minimizes the divergence between teacher-teacher and teacher-student embedding distributions. This ensures that if the teacher perceives two inputs as similar, the student learns to represent them similarly, making the student's embeddings "retrieval-ready."

2. Inference Phase: Retrieval-Augmented Prediction

During inference, the model utilizes a Knowledge Base (KB) containing projected teacher embeddings and soft labels from the training set.

  • Retrieval: For a new input, the student generates an embedding and uses the HNSW (Hierarchical Navigable Small World) algorithm to find the $K$ most similar entries in the KB.
  • Aggregation: The final output is a convex combination of the student's own prediction and a weighted average of the retrieved teacher labels. A hyperparameter $\beta$ manages the balance between internal logic and external knowledge.
The ReAugKD framework: The training phase (left) aligns student and teacher embedding spaces via relational KD, while the testing phase (right) utilizes a Knowledge Base for kNN-based prediction augmentation.

Experimental Results

The authors evaluated ReAugKD on the GLUE (General Language Understanding Evaluation) benchmark, using BERT-Base as the teacher and a 6-layer BERT as the student.

Performance and Efficiency

ReAugKD achieved state-of-the-art (SOTA) results on 5 out of 6 GLUE tasks, outperforming competitive baselines such as MetaDistil and TinyBERT. The method showed an average improvement of 0.34% over the previous best method. Crucially, the retrieval component itself contributed a 0.37% gain over a baseline that used the new loss function but lacked the external memory.

Comparison of ReAugKD against various task-specific distillation baselines on the GLUE benchmark. ReAugKD (ours) achieves the highest average score and SOTA results on most individual tasks.

Despite the added retrieval step, the system remains highly efficient. By utilizing approximate kNN on the CPU, the authors kept the latency overhead below 3%, making it viable for real-time applications where speed is critical.

Key Insights and Conclusion

The primary innovation of ReAugKD is the shift from purely parametric learning to a hybrid approach. The "aha" moment lies in the realization that a small model does not necessarily need more parameters to be smarter; it needs better access to external information. Furthermore, the authors discovered that training for retrieval improves the student's internal representations even when the retrieval step is omitted, suggesting that the relational loss forces the student to learn higher-quality, teacher-aligned features.

While the method currently requires access to teacher internals (precluding "black-box" distillation) and carries a memory footprint for the Knowledge Base, it represents a significant step forward in efficient model compression. Future work may involve dataset distillation to compress the Knowledge Base itself, further optimizing the memory-performance trade-off.

Summary updated

BibTeX
@inproceedings{zhang2023reaugkd,
  author = {Jianyi Zhang and Aashiq Muhamed and Aditya Anantharaman and Guoyin Wang and Changyou Chen and Kai Zhong and Qingjun Cui and Yi Xu and Belinda Zeng and Trishul Chilimbi and Yiran Chen},
  title = {{ReAugKD: Retrieval-Augmented Knowledge Distillation For Pre-trained Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-short.97},
}
Figure