EvoCodeBench: An Evolving Code Generation Benchmark Aligned with Real-World Code Repositories

📄 arXiv: 2404.00599v1 📥 PDF

作者: Jia Li, Ge Li, Xuanming Zhang, Yihong Dong, Zhi Jin

分类: cs.CL, cs.AI, cs.SE

发布日期: 2024-03-31

备注: Data: https://github.com/seketeam/EvoCodeBench


💡 一句话要点

提出EvoCodeBench以解决现有代码生成基准不足的问题

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 代码生成 大型语言模型 基准测试 真实世界代码库 自动更新 评估指标

📋 核心要点

  1. 现有的代码生成基准与真实代码库的对齐程度较差,无法有效评估大型语言模型的编码能力。
  2. 本文提出EvoCodeBench基准,通过与真实代码库的多维对齐、全面的注释和稳健的评估指标来解决上述问题。
  3. 实验表明,gpt-4在我们的测试中最高Pass@1仅为20.73%,并分析了现有LLMs的不足之处。

📝 摘要(中文)

如何评估大型语言模型(LLMs)在代码生成中的能力仍然是一个开放性问题。现有基准与真实世界代码库的对齐程度较差,无法充分评估LLMs的编码能力。本文提出了新的基准EvoCodeBench,以解决这些问题,具有三个主要创新点:(1)EvoCodeBench在多个维度上与真实代码库对齐;(2)提供全面的注释和稳健的评估指标;(3)构建自动更新管道以避免数据泄露。我们发布了首个版本EvoCodeBench-2403,包含来自25个真实世界代码库的275个样本,并评估了10个流行的LLMs。实验结果揭示了这些LLMs在真实代码库中的编码能力。

🔬 方法详解

问题定义:本文旨在解决现有代码生成基准与真实代码库对齐不足的问题,导致无法有效评估大型语言模型的编码能力。现有方法在代码分布和依赖分布等方面存在明显缺陷。

核心思路:EvoCodeBench通过与真实世界代码库在多个维度上对齐,提供全面的注释和评估指标,构建了一个动态更新的基准,以确保其有效性和时效性。

技术框架:EvoCodeBench的整体架构包括数据收集、注释生成、评估指标设计和自动更新管道。数据收集从最新的真实代码库中提取样本,注释生成提供了需求、参考代码和依赖信息。

关键创新:EvoCodeBench的最大创新在于其动态更新机制,避免了数据泄露,并确保基准的持续有效性。这一设计与静态基准的本质区别在于其适应性和实时性。

关键设计:在参数设置上,EvoCodeBench采用了Pass@k和Recall@k等评估指标,确保评估的全面性和准确性。网络结构方面,虽然未详细描述,但注重与真实代码库的对齐是其设计的核心。

🖼️ 关键图片

fig_0
fig_1

📊 实验亮点

实验结果显示,gpt-4在EvoCodeBench中的最高Pass@1仅为20.73%,揭示了当前大型语言模型在真实代码生成任务中的局限性。通过对比10个流行的LLMs,本文总结了它们在真实代码库中的表现和不足之处,为后续研究提供了重要参考。

🎯 应用场景

EvoCodeBench的研究成果具有广泛的应用潜力,特别是在软件开发、自动代码生成和代码审查等领域。通过提供更准确的评估标准,开发者可以更有效地利用大型语言模型,提高代码生成的质量和效率。此外,随着基准的不断更新,未来的研究和应用将更加贴近真实世界的需求。

📄 摘要(原文)

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.