arXiv:2508.15423cs.SEcs.AI2025-08中稿 · ICSE 2026被引 4

知识蒸馏让代码模型更小更快,性能损失少于2%。

An Empirical Study of Knowledge Distillation for Code Understanding Tasks

  • 用大模型指导小模型,提升代码理解效率。
  • 小模型仅5%参数就能保留98%大模型性能。
  • 适合部署在资源受限的代码分析场景。

预训练语言模型(PLMs)在代码理解任务中表现强大,但其计算开销大、推理延迟高,难以大规模应用。知识蒸馏(KD)通过将大模型的知识迁移至紧凑的小模型,有效缓解这一问题。本文系统研究了KD在代码理解任务中的效果,对比了基于输出概率和特征的两类方法,在三个下游任务上使用两个不同领域的教师模型与八种学生模型进行实验。结果表明,相比标准微调,KD能持续提升各尺寸学生模型的性能;以代码专用模型为教师时效果更佳。最新的特征蒸馏方法表现最优,使学生模型仅用5%参数即可保留高达98%的教师性能。此外,学生模型架构与教师相似并非性能提升关键。研究还分析了蒸馏过程中的效率与行为,并指明未来方向。

原文摘要 · Abstract (English)

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.

知识蒸馏代码理解模型压缩

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。