A^3-CodGen:面向代码复用、具备局部感知、全局感知与第三方库感知的仓库级代码生成框架
A^3-CodGen: A Repository-Level Code Generation Framework for Code Reuse with Local-Aware, Global-Aware, and Third-Party-Library-Aware
AI总结:
提出 A^3-CodGen 仓库级代码生成框架,融合当前文件、跨文件及第三方库上下文,提升生成代码的准确性、效率与复用率。
摘要:
基于 LLM 的代码生成工具在软件开发过程中对帮助开发者至关重要。现有工具往往与工作上下文(即代码仓库)脱节,导致生成的代码不像人类开发者所编写。本文提出一种名为 A^3-CodGen 的新型代码生成框架,以利用代码仓库内的信息生成代码,从而减少潜在逻辑错误、代码冗余以及由库引发的兼容性问题。我们识别出代码仓库的三类代表性信息:来自当前代码文件的局部感知信息、来自其他代码文件的全局感知信息,以及第三方库信息。结果表明,通过采用 A^3-CodGen 框架,我们成功提取、融合代码仓库信息并将其输入 LLM,生成了更准确、高效且高度可复用的代码。与人类开发者相比,该框架生成的代码具有更高的复用率,进一步凸显了其有效性。本研究对代码生成领域作出重要贡献,为开发者提供了更强大的工具,以应对实际软件开发中不断变化的需求。
英文摘要:
LLM-based code generation tools are essential to help developers in the software development process. Existing tools often disconnect with the working context, i.e., the code repository, causing the generated code to be not similar to human developers. In this paper, we propose a novel code generation framework, dubbed A^3-CodGen, to harness information within the code repository to generate code with fewer potential logical errors, code redundancy, and library-induced compatibility issues. We identify three types of representative information for the code repository: local-aware information from the current code file, global-aware information from other code files, and third-party-library information. Results demonstrate that by adopting the A^3-CodGen framework, we successfully extract, fuse, and feed code repository information into the LLM, generating more accurate, efficient, and highly reusable code. The effectiveness of our framework is further underscored by generating code with a higher reuse rate, compared to human developers. This research contributes significantly to the field of code generation, providing developers with a more powerful tool to address the evolving demands in software development in practice.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。