让代码库生成可运行,通过环境对齐提升成功率
Toward Executable Repository-Level Code Generation via Environment Alignment

- 将代码库可执行性建模为环境对齐问题,联合优化依赖与引用
- 在三个主流大模型上测试,功能正确率提升5.72至5.87个百分点
- 适合需要生成可运行多文件项目的研究者和开发者
大型语言模型在代码生成方面表现强劲,但现有方法在可执行验证下的仓库级代码生成仍面临挑战。在此评估设置中,成功与否取决于生成的多文件仓库能否被成功安装、依赖项与内部引用能否解析、能否启动并真实运行。为此,我们提出EnvGraph框架,将仓库可执行性建模为环境对齐问题。该框架联合建模外部依赖满足与仓库内引用解析两个关键条件,采用双层环境表示,利用执行证据进行基于证据的归因,并在迭代对齐循环中通过统一的目标修订机制引导生成。我们在三个代表性骨干LLM上评估EnvGraph,对比了具有环境感知性和仓库级基线方法。实验结果表明,EnvGraph在这些仓库级基准测试中始终表现最佳,相较于最强非EnvGraph基线,在功能正确性上提升5.72至5.87个百分点,在非功能性质量上提升4.58至8.66个百分点。
原文摘要 · Abstract (English)
Large language models (LLMs) have achieved strong performance on code generation, but existing methods still struggle with repository-level code generation under executable validation. Under this evaluation setting, success is determined not by the plausibility of isolated code fragments, but by whether a generated multi-file repository can be successfully installed, have its dependencies and internal references resolved, be launched, and be validated in a real execution environment. To address this challenge, we propose EnvGraph, a framework for repository-level code generation that formulates repository executability as an environment alignment problem. EnvGraph jointly models two coupled conditions for successful repository execution, namely external dependency satisfaction and repository-internal reference resolution. It maintains a dual-layer environment representation, uses execution evidence to perform execution-evidence-based attribution, and guides repository generation through a unified targeted revision mechanism within an iterative alignment loop. We evaluate EnvGraph on repository-level code generation with three representative backbone LLMs and compare it against representative environment-aware and repository-level baselines. Experimental results show that EnvGraph consistently achieves the best performance on these repository-level benchmarks. In particular, it outperforms the strongest non-EnvGraph baseline by an absolute margin of 5.72--5.87 percentage points in Functional Correctness and 4.58--8.66 percentage points in Non-Functional Quality.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。