[论文解读] EvoCodeBench: An Evolving Code Generation Benchmark Aligned with Real-World Code Repositories
EvoCodeBench 是一个与真实代码仓库对齐的代码生成基准,拥有全面的注释和不断演进的流水线,在对 10 个语言模型进行仓库级代码生成评估。
How to evaluate Large Language Models (LLMs) in code generation is an open question. Existing benchmarks demonstrate poor alignment with real-world code repositories and are insufficient to evaluate the coding abilities of LLMs. This paper proposes a new benchmark - EvoCodeBench to address the preceding problems, which has three primary advances. (1) EvoCodeBench aligns with real-world repositories in multiple dimensions, e.g., code distributions and dependency distributions. (2) EvoCodeBench offers comprehensive annotations (e.g., requirements, reference code, and reference dependencies), and robust evaluation metrics (e.g., Pass@k and Recall@k). (3) EvoCodeBench is an evolving benchmark to avoid data leakage. We build an automatic pipeline to update EvoCodeBench from the latest repositories. We release the first version - EvoCodeBench-2403, containing 275 samples from 25 real-world repositories. Based on EvoCodeBench, we propose repository-level code generation and evaluate 10 popular LLMs (e.g., gpt-4, gpt-3.5, DeepSeek Coder, StarCoder 2, CodeLLaMa, Gemma, and Qwen 1.5). Our experiments reveal the coding abilities of these LLMs in real-world repositories. For example, the highest Pass@1 of gpt-4 only is 20.73% in our experiments. We also analyze failed cases and summarize the shortcomings of existing LLMs in EvoCodeBench. We release EvoCodeBench, all prompts, and LLMs' completions for further community analysis.
研究动机与目标
- 论证现有基准与真实世界代码仓库的对齐度较差。
- 提出具有真实世界分布、全面注释和鲁棒指标的 EvoCodeBench。
- 引入一个演化的基准流水线以缓解数据泄漏并使基准保持最新。
- 将仓库级代码生成定义为真实的评估场景。
- 评估流行的语言模型以揭示它们在真实仓库中的优势与局限。
提出的方法
- 从真实世界的Python仓库构建 EvoCodeBench,确保代码分布和依赖分布的对齐。
- 用需求、参考代码、参考依赖和仓库上下文(包含依赖路径)对样本进行注释。
- 将 Pass@k 作为功能正确性指标,将 Recall@k 用于评估依赖召回。
- 采用半自动需求生成并定期更新的演化基准流水线。
- 在多种上下文设置下评估一组 10 个语言模型(如 GPT-4、GPT-3.5、StarCoder 2、CodeLLaMa、Gemma、Qwen 1.5、DeepSeek Coder)。
- 定义仓库级代码生成任务,在给定需求和上下文时模拟在仓库内编写代码。
实验结果
研究问题
- RQ1 EvoCodeBench 如何与真实世界仓库中发现的分布(代码与依赖)对齐?
- RQ2相比独立函数基准,仓库级代码生成能否更好地反映开发者的编码过程?
- RQ3当前语言模型在仓库级代码生成上的性能与失败模式是什么?
- RQ4来自仓库的上下文(本地文件、跨文件依赖)是否提升了语言模型在仓库级任务中的表现?
- RQ5像 Pass@k 和 Recall@k 这样的评估指标如何反映语言模型在真实仓库中的能力与局限?
主要发现
- EvoCodeBench-2403 包含来自 25 个真实仓库的 275 个样本,并与 500 个真实世界仓库中观察到的分布保持一致。
- 基准提供全面的注释,包括需求、参考代码、参考依赖,以及带有依赖路径的仓库上下文。
- 10 个主流语言模型在 EvoCodeBench-2403 上的 Pass@k 得分明显低于传统基准(例如 GPT-4 的 Pass@1 从 HumanEval 的最高 88.4 降至 EvoCodeBench-2403 的 7.27)。
- 来自本地文件的上下文信息显著提升性能;对 GPT-4,在特定设置下 Pass@1 提高最多约 152%。
- Recall@k 突显依赖召回的挑战,跨文件依赖从本地上下文获益但仍易出现不匹配或遗漏。
- 使用检索增强生成(Retrieval-Augmented Generation)与类似函数能够提高 Pass@1 与 Recall@1,显示在利用仓库级上下文方面的价值。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。