arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2306.06490cs.SEcs.PL
收藏

基于搜索-生成-修改的自动化代码编辑

Automated Code Editing with Search-Generate-Modify

Changshu Liu, Pelin Cetin, Yogesh Patodia, Saikat Chakraborty, Yangruibo Ding, Baishakhi Ray

AI总结:

本文提出SARGAM工具,通过模拟开发者搜索-生成-修改的代码编辑行为,结合代码搜索、生成与修改的混合方法,在编辑生成和程序修复任务上优于现有最先进技术。

摘要:

代码编辑在软件开发的演进过程中至关重要。目前已有许多自动化代码编辑工具被提出,这些工具同时利用了基于信息检索的技术以及基于机器学习的代码生成和代码编辑模型。每种技术都有其自身的优势与不足,它们通常被结合使用,以互补优势并弥补各自的缺陷。本文提出了一种混合方法,通过综合利用代码搜索、代码生成和代码修改的能力来更好地合成代码编辑。我们的关键观察是:通过搜索和检索获得的补丁,即使并不完美,也能为代码生成模型提供有用的指导。然而,由代码生成模型产生的检索引导补丁仍可能与目标补丁存在若干标记的偏差。这类生成的补丁可以通过轻微修改来得到目标补丁。SARGAM是一个新颖的工具,旨在模拟真实开发者的代码编辑行为。给定一个原始代码版本,开发者可能会搜索相关补丁,生成或编写代码,然后修改生成的代码以使其适应正确的上下文。我们对SARGAM在编辑生成任务上的评估表明,其性能优于当前最先进的技术。SARGAM在自动化程序修复任务上也表现出显著的有效性。

英文摘要:

Code editing is essential in evolving software development. Many automated code editing tools have been proposed that leverage both Information Retrieval-based techniques and Machine Learning-based code generation and code editing models. Each technique comes with its own promises and perils, and they are often used together to complement their strengths and compensate for their weaknesses. This paper proposes a hybrid approach to better synthesize code edits by leveraging the power of code search, generation, and modification. Our key observation is that a patch obtained by search and retrieval, even if imperfect, can provide helpful guidance to a code generation model. However, a retrieval-guided patch produced by a code generation model can still be a few tokens off from the intended patch. Such generated patches can be slightly modified to create the intended patches. SARGAM is a novel tool designed to mimic a real developer's code editing behavior. Given an original code version, the developer may search for related patches, generate or write the code, and then modify the generated code to adapt it to the right context. Our evaluation of SARGAM on edit generation shows superior performance with respect to current state-of-the-art techniques. SARGAM also shows great effectiveness on automated program repair tasks.

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

↑