arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2304.12269cs.CL
收藏

利用上下文数据丰富源代码以提升代码补全模型:一项实证研究

Enriching Source Code with Contextual Data for Code Completion Models: An Empirical Study

Delft University of Technology(代尔夫特理工大学)

Tim van Dam, Maliheh Izadi, Arie van Deursen

AI总结:

本文实证评估类型注解与注释对 UniXcoder、CodeGPT 和 InCoder 代码补全性能的影响,发现移除类型注解、保留多行注释略有帮助。

摘要:

基于 Transformer 的预训练模型近期在解决许多软件工程任务时取得了出色成果,其中包括作为开发者工具集中核心功能的自动代码补全。尽管许多研究致力于提升此类模型的代码理解能力,但相反的方向——让代码更易于理解——尚未得到充分研究。在本研究中,我们旨在回答:通过使用上下文数据让代码更易于理解,是否能够提升预训练代码语言模型在代码补全任务上的性能。我们将类型注解和注释视为两种常见的附加上下文信息形式,它们通常有助于开发者更好地理解代码。在实验中,我们研究了两种粒度级别的代码补全:token 补全和行补全,并采用三个近期的大规模源代码语言模型:UniXcoder、CodeGPT 和 InCoder,使用五项评估指标。最后,我们执行 Wilcoxon 符号秩检验以衡量显著性,并测量效应量。与预期相反,当移除类型注解时,所有模型的表现都更好(尽管效应量较小)。对于注释,我们发现模型在存在多行注释时表现更好(同样具有较小的效应量)。基于观察结果,我们建议在训练、微调或仅仅根据目标数据和应用选择此类模型时,作出适当的设计选择。还可以进一步研究更好的评估方法和多模态技术,以提高自动补全的实用性和准确性。

英文摘要:

Transformer-based pre-trained models have recently achieved great results in solving many software engineering tasks including automatic code completion which is a staple in a developer's toolkit. While many have striven to improve the code-understanding abilities of such models, the opposite -- making the code easier to understand -- has not been properly investigated. In this study, we aim to answer whether making code easier to understand through using contextual data improves the performance of pre-trained code language models for the task of code completion. We consider type annotations and comments as two common forms of additional contextual information that often help developers understand code better. For the experiments, we study code completion in two granularity levels; token and line completion and take three recent and large-scale language models for source code: UniXcoder, CodeGPT, and InCoder with five evaluation metrics. Finally, we perform the Wilcoxon Signed Rank test to gauge significance and measure the effect size. Contrary to our expectations, all models perform better if type annotations are removed (albeit the effect sizes are small). For comments, we find that the models perform better in the presence of multi-line comments (again with small effect sizes). Based on our observations, we recommend making proper design choices when training, fine-tuning, or simply selecting such models given the intended data and application. Better evaluations and multi-modal techniques can also be further investigated to improve the practicality and accuracy of auto-completions.

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

↑