CoEdPilot:利用学习到的先前编辑相关性、项目级感知和交互特性推荐代码编辑
CoEdPilot: Recommending Code Edits with Learned Prior Edit Relevance, Project-wise Awareness, and Interactive Nature
AI总结:
本文提出 CoEdPilot,利用多个神经模型识别相关先前编辑、分析项目级连锁影响并生成后续编辑选项;在 471 个项目、180K 次提交上训练,位置和内容预测表现良好。
摘要:
近年来,基于 LLM 的代码生成不断发展。与在软件项目中生成代码相比,经验观察表明增量式代码编辑更为频繁。新兴的代码编辑方法通常将该问题表述为:基于已知的相关先前编辑和上下文生成一次编辑。然而,实际代码编辑可能更加复杂。首先,一个编辑会话可能包含对正在编辑代码的多个相关或不相关编辑。其次,推断后续编辑并非易事,因为其连锁反应的范围可能波及整个项目。在本工作中,我们提出 CoEdPilot,这是一种由 LLM 驱动的代码编辑推荐方案,通过区分相关编辑、探索其交互特性并评估其在项目中的连锁反应来推荐代码编辑。具体而言,CoEdPilot 协同多个神经 transformer,从编辑位置和编辑内容两方面识别项目中要编辑什么以及如何编辑。当用户完成一次编辑并提供可选的编辑描述后,Subsequent Edit Analysis 会首先报告项目中最相关的文件,以及这些文件中每行代码可能发生何种类型的编辑(例如 keep、insert 和 replace)。随后,Edit-content Generator 会根据 Edit-dependency Analyzer 报告的相关先前变更,为这些代码行生成具体的编辑选项。最后,Subsequent Edit Analysis 和 Edit-content Generator 都会捕获相关的先前编辑作为反馈,以重新调整其推荐。我们通过收集来自 5 种编程语言、471 个开源项目的超过 180K 次提交来训练模型。大量实验表明,CoEdPilot 能够很好地预测编辑(即预测编辑位置的准确率为 70.8%-85.3%,预测编辑内容的精确匹配率为 41.8%,BLEU4 得分为 60.7)……
英文摘要:
Recent years have seen the development of LLM-based code generation. Compared to generating code in a software project, incremental code edits are empirically observed to be more frequent. The emerging code editing approaches usually formulate the problem as generating an edit based on known relevant prior edits and context. However, practical code edits can be more complicated. First, an editing session can include multiple (ir)relevant edits to the code under edit. Second, the inference of the subsequent edits is non-trivial as the scope of its ripple effect can be the whole project. In this work, we propose CoEdPilot, an LLM-driven solution to recommend code edits by discriminating the relevant edits, exploring their interactive natures, and estimating its ripple effect in the project. Specifically, CoEdPilot orchestrates multiple neural transformers to identify what and how to edit in the project regarding both edit location and edit content. When a user accomplishes an edit with an optional editing description, a Subsequent Edit Analysis first reports the most relevant files in the project with what types of edits (e.g., keep, insert, and replace) can happen for each line of their code. Next, an Edit-content Generator generates concrete edit options for the lines of code, regarding its relevant prior changes reported by an Edit-dependency Analyzer. Lastly, both the Subsequent Edit Analysis and the Edit-content Generator capture relevant prior edits as feedback to readjust their recommendations. We train our models by collecting over 180K commits from 471 open-source projects in 5 programming languages. Our extensive experiments show that CoEdPilot can well predict the edits (i.e., predicting edit location with an accuracy of 70.8%-85.3%, and the edit content with an exact match rate of 41.8% and BLEU4 score of 60.7)...
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。