arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2304.05216cs.SEcs.AIcs.CL
收藏

面向预训练代码模型的高效微调:一项实验研究及超越

Towards Efficient Fine-tuning of Pre-trained Code Models: An Experimental Study and Beyond

Xi’an Jiaotong University(西安交通大学);Sun Yat-sen University(中山大学);Chongqing University(重庆大学);Microsoft(微软)

Ensheng Shi, Yanlin Wang, Hongyu Zhang, Lun Du, Shi Han, Dongmei Zhang, Hongbin Sun

AI总结:

本文通过实验研究揭示预训练代码模型微调中层表示与代码属性的变化规律,并据此提出基于层冻结的高效微调方法 Telly,在保持性能的同时大幅降低训练参数和时间开销。

摘要:

近年来,在下游任务上微调预训练代码模型(如 CodeBERT)已在许多软件测试与分析任务中取得了巨大成功。尽管这种方法有效且普遍,但微调预训练参数会带来巨大的计算开销。本文开展了一项广泛的实验研究,以探究微调过程中逐层预训练表示及其所编码的代码知识会发生何种变化。基于上述发现,我们随后提出了对大型预训练代码模型进行高效微调的替代方案。我们的实验研究表明:(1)源代码的词法、语法和结构属性分别编码在较低层、中间层和较高层中,而语义属性则跨越整个模型。(2)微调过程保留了大部分代码属性。具体而言,较低层和中间层所捕获的基本代码属性在微调过程中仍然得以保留。此外,我们发现,在各种下游任务中,微调过程中只有最顶部两层的表示变化最大。(3)基于上述发现,我们提出了 Telly,通过层冻结来高效微调预训练代码模型。在五个不同下游任务上的大量实验结果表明,训练参数和相应的时间开销都大幅降低,而性能则相似或更优。包含源代码、数据集和在线附录的复现包可在以下地址获取:\url{https://github.com/DeepSoftwareAnalytics/Telly}。

英文摘要:

Recently, fine-tuning pre-trained code models such as CodeBERT on downstream tasks has achieved great success in many software testing and analysis tasks. While effective and prevalent, fine-tuning the pre-trained parameters incurs a large computational cost. In this paper, we conduct an extensive experimental study to explore what happens to layer-wise pre-trained representations and their encoded code knowledge during fine-tuning. We then propose efficient alternatives to fine-tune the large pre-trained code model based on the above findings. Our experimental study shows that (1) lexical, syntactic and structural properties of source code are encoded in the lower, intermediate, and higher layers, respectively, while the semantic property spans across the entire model. (2) The process of fine-tuning preserves most of the code properties. Specifically, the basic code properties captured by lower and intermediate layers are still preserved during fine-tuning. Furthermore, we find that only the representations of the top two layers change most during fine-tuning for various downstream tasks. (3) Based on the above findings, we propose Telly to efficiently fine-tune pre-trained code models via layer freezing. The extensive experimental results on five various downstream tasks demonstrate that training parameters and the corresponding time cost are greatly reduced, while performances are similar or better. Replication package including source code, datasets, and online Appendix is available at: \url{https://github.com/DeepSoftwareAnalytics/Telly}.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑