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

没有人是一座孤岛:通过代码搜索、代码生成和程序修复迈向全自动编程

No Man is an Island: Towards Fully Automatic Programming by Code Search, Code Generation and Program Repair

Quanjun Zhang, Chunrong Fang, Ye Shang, Tongke Zhang, Shengcheng Yu, Zhenyu Chen

AI总结:

本文提出一个自动编程框架,首次整合代码搜索、代码生成和程序修复,利用大型语言模型提升生成代码质量,并在编程问题上取得62.53%的提升。

摘要:

自动编程旨在尽量减少可执行代码生成过程中的人工干预,长期以来一直是软件工程领域的一项挑战。为了推进自动编程,研究人员主要聚焦于三个方向:(1)代码搜索,即从外部数据库中复用已有代码片段;(2)代码生成,即根据自然语言生成新的代码片段;(3)程序修复,即通过修复检测到的缺陷来改进已有代码片段。尽管取得了显著进展,但最先进技术的有效性仍然有限,例如搜索到的代码的可用性以及生成代码的正确性。受真实世界编程过程的启发,开发人员通常使用各种外部工具来辅助编码过程,例如代码搜索引擎和代码测试工具,在本工作中,我们提出了一个自动编程框架,该框架利用近期的大型语言模型(LLMs)将这三个研究领域整合起来,以解决它们固有的局限性。具体而言,我们的框架首先利用不同的代码搜索策略检索相似的代码片段,然后利用这些片段进一步指导大型语言模型的代码生成过程。我们的框架还通过编译器和测试用例验证生成代码的质量,并构建修复提示来查询大型语言模型以生成正确的补丁。我们进行了初步实验以展示该框架的潜力,例如帮助CodeLlama解决267个编程问题,提升幅度达到62.53%。作为一个通用框架,它能够整合各种代码搜索、生成和修复工具,首次将这三个研究领域结合在一起。更重要的是,它展示了利用传统软件工程工具增强大型语言模型在自动编程中可用性的潜力。

英文摘要:

Automatic programming attempts to minimize human intervention in the generation of executable code, and has been a long-standing challenge in the software engineering community. To advance automatic programming, researchers are focusing on three primary directions: (1) code search that reuses existing code snippets from external databases; (2) code generation that produces new code snippets from natural language; and (3) program repair that refines existing code snippets by fixing detected bugs. Despite significant advancements, the effectiveness of state-of-the-art techniques is still limited, such as the usability of searched code and the correctness of generated code. Motivated by the real-world programming process, where developers usually use various external tools to aid their coding processes, such as code search engines and code testing tools, in this work, we propose \toolname{}, an automatic programming framework that leverages recent large language models (LLMs) to integrate the three research areas to address their inherent limitations. In particular, our framework first leverages different code search strategies to retrieve similar code snippets, which are then used to further guide the code generation process of LLMs. Our framework further validates the quality of generated code by compilers and test cases, and constructs repair prompts to query LLMs for generating correct patches. We conduct preliminary experiments to demonstrate the potential of our framework, \eg helping CodeLlama solve 267 programming problems with an improvement of 62.53\%. As a generic framework, \toolname{} can integrate various code search, generation, and repair tools, combining these three research areas together for the first time. More importantly, it demonstrates the potential of using traditional SE tools to enhance the usability of LLMs in automatic programming.

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

↑