Code completion aims at speeding up code writing by predicting the next code token(s) the developer is likely to write. Works in this field focused on improving the accuracy of the generated predictions, with substantial leaps forward made possible by deep learning (DL) models. However, code completion techniques are mostly evaluated in the scenario of predicting the next token to type, with few exceptions pushing the boundaries to the prediction of an entire code statement. Thus, little is known about the performance of state-of-the-art code completion approaches in more challenging scenarios in which, for example, an entire code block must be generated. We present a large-scale study exploring the capabilities of state-of-the-art Transformer-based models in supporting code completion at different granularity levels, including single tokens, one or multiple entire statements, up to entire code blocks (e.g., the iterated block of a for loop). We experimented with several variants of two recently proposed Transformer-based models, namely RoBERTa and the Text-To-Text Transfer Transformer (T5), for the task of code completion. The achieved results show that Transformer-based models, and in particular the T5, represent a viable solution for code completion, with perfect predictions ranging from ~29%, obtained when asking the model to guess entire blocks, up to ~69%, reached in the simpler scenario of few tokens masked from the same code statement.
代码完成是一种流行的软件开发工具,集成到所有主要的IDE中。许多神经语言模型在合成基准上的完成建议预测中取得了令人满意的结果。然而,最近的一项研究When Code Completion Fails:a Case Study on Real-World Completions表明,这些结果可能不会转化为现实世界性能的改善。为了对抗这种影响,我们在真实世界的代码完成示例上训练模型,发现这些模型的准确率分别比在提交的源代码和工作版本快照上训练的模型高出12.8%和13.8%。我们在建模技术中观察到这种改进,并通过A/B测试表明,它对应于程序员实际自动完成使用量增加6.2%。此外,我们的研究还描述了一个大型的自动补全使用记录语料库,以研究为什么在真实世界的例子上训练会导致更强大的模型。
CodeMark: Imperceptible Watermarking for Code Datasets against Neural Code Completion Models
Beihang University(北京航空航天大学);Monash University(莫纳什大学);Institute of Software, Chinese Academy of Sciences(中国科学院软件研究所);University of Chinese Academy of Sciences(中国科学院大学)
Package-Aware Approach for Repository-Level Code Completion in Pharo
Univ. Lille, Inria, CNRS, Centrale Lille(里尔大学、法国国家信息与自动化研究所、法国国家科学研究中心、里尔中央理工学院);CNRS, University of Bordeaux, Bordeaux INP(法国国家科学研究中心、波尔多大学、波尔多国立理工学院)
Enhancing Project-Specific Code Completion by Inferring Internal API Information
State Key Laboratory of Blockchain and Data Security, Zhejiang University(区块链与数据安全国家重点实验室,浙江大学);Ant Group(蚂蚁集团);School of Computing and Information Systems, Singapore Management University(新加坡管理大学计算机与信息系)
针对项目代码补全中内部 API 未显式导入的问题,提出基于使用示例与语义描述推断 API 信息并构建知识库的方法,同时发布 ProjBench,实验显著提升补全性能。