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

上下文对仓库级代码生成的影响研究

On the Impacts of Contexts on Repository-Level Code Generation

FPT Software AI Center(FPT软件AI中心);Hanoi University of Science and Technology(河内科技大学)

Nam Le Hai, Dung Manh Nguyen, Nghi D. Q. Bui

AI总结:

本文提出 RepoExec 基准及依赖调用率指标,研究仓库级上下文对代码生成的影响,发现预训练模型正确性更优而指令微调模型上下文利用和调试能力更强。

摘要:

代码大语言模型(CodeLLMs)已在代码生成任务中获得广泛应用,但其处理具有复杂上下文依赖关系的仓库级代码生成能力仍未得到充分探索。我们的工作强调了利用仓库级上下文来生成可执行且功能正确的代码的至关重要性。我们提出了 RepoExec,一个专为评估仓库级代码生成而设计的新型基准,重点关注三个关键方面:可执行性、通过全面测试用例生成实现的功能正确性,以及跨文件上下文的准确利用。我们的研究考察了一个受控场景,在该场景中开发者指定必要的代码依赖(上下文),挑战模型有效地整合这些依赖。此外,我们引入了一个经过指令微调的数据集,以增强 CodeLLMs 利用依赖的能力,同时提出了一个新指标——依赖调用率(Dependency Invocation Rate, DIR),用于量化上下文利用程度。实验结果表明,虽然预训练大语言模型在正确性方面表现更优,但经过指令微调的模型在上下文利用和调试能力方面表现突出。RepoExec 提供了一个全面的评估框架,用于评估代码功能以及与开发者意图的一致性,从而推动开发更可靠的、适用于实际应用的 CodeLLMs。数据集和源代码可在 https://github.com/FSoft-AI4Code/RepoExec 获取。

英文摘要:

CodeLLMs have gained widespread adoption for code generation tasks, yet their capacity to handle repository-level code generation with complex contextual dependencies remains underexplored. Our work underscores the critical importance of leveraging repository-level contexts to generate executable and functionally correct code. We present RepoExec, a novel benchmark designed to evaluate repository-level code generation, with a focus on three key aspects: executability, functional correctness through comprehensive test case generation, and accurate utilization of cross-file contexts. Our study examines a controlled scenario where developers specify essential code dependencies (contexts), challenging models to integrate them effectively. Additionally, we introduce an instruction-tuned dataset that enhances CodeLLMs' ability to leverage dependencies, along with a new metric, Dependency Invocation Rate (DIR), to quantify context utilization. Experimental results reveal that while pretrained LLMs demonstrate superior performance in terms of correctness, instruction-tuned models excel in context utilization and debugging capabilities. RepoExec offers a comprehensive evaluation framework for assessing code functionality and alignment with developer intent, thereby advancing the development of more reliable CodeLLMs for real-world applications. The dataset and source code are available at https://github.com/FSoft-AI4Code/RepoExec.

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

↑