一句话:系统实证评估知识蒸馏在代码理解任务中的有效性,覆盖两类蒸馏方法与多组师生模型配置。
预训练语言模型在代码理解任务上表现强大,但其计算开销大、推理延迟高,难以大规模部署。知识蒸馏通过将大教师模型的知识迁移到紧凑学生模型,可在保持大部分性能的同时实现高效推理,然而该技术在代码理解领域尚缺乏系统研究。本文对代码理解任务中的知识蒸馏展开系统实证研究,涵盖基于 logit 与基于特征的两类主流蒸馏方法,在三个下游任务上使用两个来自不同领域的教师预训练语言模型和八个学生模型进行实验。结果表明,与标准微调相比,知识蒸馏对不同规模的学生模型均能带来显著性能提升;代码专用预训练模型作为教师效果更佳;最新的基于特征的蒸馏方法表现最优,仅用 5% 参数即可保留教师模型最高 98% 的性能。此外,学生架构与教师架构相似并不必然带来更好性能。论文还讨论了蒸馏过程与推理的效率及行为,并总结了研究发现与未来方向。
Pre-trained language models (PLMs) have emerged as powerful tools for code understanding. However, deploying these PLMs in large-scale applications faces practical challenges due to their computational intensity and inference latency. Knowledge distillation (KD), a promising model compression and acceleration technique, addresses these limitations by transferring knowledge from large teacher models to compact student models, enabling efficient inference while preserving most of the teacher models’ capabilities. While this technique has shown remarkable success in natural language processing and computer vision domains, its potential for code understanding tasks remains largely underexplored. In this paper, we systematically investigate the effectiveness and usage of KD in code understanding tasks. Our study encompasses two popular types of KD methods, i.e., logit-based and feature-based KD methods, experimenting across eight student models and two teacher PLMs from different domains on three downstream tasks. The experimental results indicate that KD consistently offers notable performance boosts across student models with different sizes compared with standard fine-tuning. Notably, code-specific PLM demonstrates better effectiveness as the teacher model. Among all KD methods, the latest feature-based KD methods exhibit superior performance, enabling student models to retain up to 98% teacher performance with merely 5% parameters. Regarding student architecture, our experiments reveal that similarity with teacher architecture does not necessarily lead to better performance. We further discuss the efficiency and behaviors in the KD process and inference, summarize the implications of findings, and identify promising future directions.