arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2302.00438cs.SE
收藏

代码生成技术的鲁棒性研究--基于GitHub副驾驶仪的实证研究

On the Robustness of Code Generation Techniques: An Empirical Study on GitHub Copilot

Antonio Mastropaolo, Luca Pascarella, Emanuela Guglielmi, Matteo Ciniselli, Simone Scalabrino, Rocco Oliveto, Gabriele Bavota

摘要:

软件工程研究一直关注代码完成方法的改进,这表明开发人员在编码时可能会输入下一个标记。GitHub Copilot的发布是向前迈出的一大步,也是因为它具有前所未有的能力,可以从自然语言描述中自动生成甚至整个函数。虽然Copilot的实用性是显而易见的,但它的健壮程度仍不清楚。具体地说,我们不知道在提供给模型的自然语言描述中的语义保持变化对生成的代码函数的影响程度。在本文中,我们提出了一个实证研究,我们的目的是了解不同的,但语义等价的自然语言描述是否会导致相同的推荐功能。否定的答案会对基于深度学习(DL)的代码生成器的鲁棒性提出质疑,因为这意味着开发人员使用不同的措辞来描述相同的代码将获得不同的建议。我们要求Copilot从原始Javadoc描述开始自动生成892个Java方法。然后,我们手动和自动为每种方法生成不同的语义等效描述,并分析了Copilot生成的预测变化的程度。我们的研究结果表明,修改的描述结果在不同的代码建议在~46%的情况下。此外,语义等效描述中的差异可能会影响生成代码的正确性约28%。

英文摘要:

Software engineering research has always being concerned with the improvement of code completion approaches, which suggest the next tokens a developer will likely type while coding. The release of GitHub Copilot constitutes a big step forward, also because of its unprecedented ability to automatically generate even entire functions from their natural language description. While the usefulness of Copilot is evident, it is still unclear to what extent it is robust. Specifically, we do not know the extent to which semantic-preserving changes in the natural language description provided to the model have an effect on the generated code function. In this paper we present an empirical study in which we aim at understanding whether different but semantically equivalent natural language descriptions result in the same recommended function. A negative answer would pose questions on the robustness of deep learning (DL)-based code generators since it would imply that developers using different wordings to describe the same code would obtain different recommendations. We asked Copilot to automatically generate 892 Java methods starting from their original Javadoc description. Then, we generated different semantically equivalent descriptions for each method both manually and automatically, and we analyzed the extent to which predictions generated by Copilot changed. Our results show that modifying the description results in different code recommendations in ~46% of cases. Also, differences in the semantically equivalent descriptions might impact the correctness of the generated code ~28%.

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

↑