arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2309.12499cs.SE
收藏

CodePlan:基于大语言模型与规划的仓库级编码

CodePlan: Repository-level Coding using LLMs and Planning

Ramakrishna Bairi, Atharv Sonwane, Aditya Kanade, Vageesh D C, Arun Iyer, Suresh Parthasarathy, Sriram Rajamani, B. Ashok, Shashank Shet

AI总结:

CodePlan 将仓库级编码任务建模为规划问题,通过增量依赖分析、变更影响分析和自适应规划算法生成多步骤编辑链,并在包迁移和时间性代码编辑任务上显著优于无规划基线。

摘要:

软件工程活动,如包迁移、修复静态分析或测试报告的错误,以及向代码库添加类型注解或其他规范,都涉及对整个代码仓库进行普遍性编辑。我们将这些活动形式化为仓库级编码任务。近期由大语言模型(LLMs)驱动的工具(如 GitHub Copilot)已成功为局部编码问题提供高质量解决方案。仓库级编码任务更为复杂,无法直接使用 LLMs 解决,因为仓库内的代码相互依赖,且整个仓库可能过大而无法放入提示中。我们将仓库级编码构建为一个规划问题,并提出一个任务无关的框架 CodePlan 来解决它。CodePlan 合成一个多步骤的编辑链(计划),其中每一步都会在某个代码位置上调用 LLM,并使用来自整个仓库、先前代码更改和任务特定指令的上下文。CodePlan 基于增量依赖分析、变更可能影响分析和自适应规划算法的新颖组合。我们在两个仓库级任务上评估了 CodePlan 的有效性:包迁移(C#)和时间性代码编辑(Python)。每个任务都在多个代码仓库上进行评估,每个仓库都需要对许多文件(2-97 个文件之间)进行相互依赖的更改。这种复杂程度的编码任务此前尚未使用 LLMs 实现自动化。我们的结果表明,与基线相比,CodePlan 与真实结果具有更好的匹配度。CodePlan 能够让 6 个仓库中的 5 个通过有效性检查(例如,无错误构建并做出正确的代码编辑),而基线(没有规划但具有与 CodePlan 相同类型的上下文信息)无法让任何一个仓库通过这些检查。

英文摘要:

Software engineering activities such as package migration, fixing errors reports from static analysis or testing, and adding type annotations or other specifications to a codebase, involve pervasively editing the entire repository of code. We formulate these activities as repository-level coding tasks. Recent tools like GitHub Copilot, which are powered by Large Language Models (LLMs), have succeeded in offering high-quality solutions to localized coding problems. Repository-level coding tasks are more involved and cannot be solved directly using LLMs, since code within a repository is inter-dependent and the entire repository may be too large to fit into the prompt. We frame repository-level coding as a planning problem and present a task-agnostic framework, called CodePlan to solve it. CodePlan synthesizes a multi-step chain of edits (plan), where each step results in a call to an LLM on a code location with context derived from the entire repository, previous code changes and task-specific instructions. CodePlan is based on a novel combination of an incremental dependency analysis, a change may-impact analysis and an adaptive planning algorithm. We evaluate the effectiveness of CodePlan on two repository-level tasks: package migration (C#) and temporal code edits (Python). Each task is evaluated on multiple code repositories, each of which requires inter-dependent changes to many files (between 2-97 files). Coding tasks of this level of complexity have not been automated using LLMs before. Our results show that CodePlan has better match with the ground truth compared to baselines. CodePlan is able to get 5/6 repositories to pass the validity checks (e.g., to build without errors and make correct code edits) whereas the baselines (without planning but with the same type of contextual information as CodePlan) cannot get any of the repositories to pass them.

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

↑