arXiv:2510.26130cs.SEcs.AI2025-10被引 12

真实项目代码生成能力远低于测试基准,模型泛化能力有限。

Beyond Synthetic Benchmarks: Evaluating LLM Performance on Real-World Class-Level Code Generation

  • 用真实开源项目构建类级别生成评测集,分已见与未见代码库
  • 模型在真实任务中正确率仅25%-34%,远低于合成数据的84%-89%
  • 检索增强能提升4-7%正确率,但文档帮助微弱

大语言模型在函数级代码生成基准上表现优异,但现代软件开发更需在真实项目上下文中整合多方法、属性与依赖的类级实现。这一基准性能与实际应用间的差距,引发对模型是否具备生产级代码辅助能力的质疑,尤其其跨熟悉与陌生代码库的泛化能力。本文基于真实开源仓库构建评测集,将类分为已见与未见两部分,系统评估输入完整度与检索增强生成对多个主流LLM在类级正确性上的影响。结果表明:尽管模型在合成基准上正确率达84%-89%,在真实类任务中仅为25%-34%,且在熟悉与新代码库间无明显差异。全面文档仅带来1%-3%改善,而检索增强通过提供具体实现模式,带来4%-7%提升。错误分析显示,AttributeError、TypeError和AssertionError是主要失败模式,且真实场景中的错误模式与合成场景不同。这些发现为改进上下文建模、文档策略及检索集成提供了实践启示。

原文摘要 · Abstract (English)

Large language models (LLMs) have demonstrated strong performance on function-level code generation benchmarks, yet real-world software development increasingly demands class-level implementations that integrate multiple methods, attributes, and dependencies within authentic project contexts. This gap between benchmark performance and practical utility raises critical questions about LLMs' readiness for production code assistance, particularly regarding their ability to generalize across familiar and novel codebases. We introduce a benchmark derived from real-world open-source repositories, comprising classes divided into seen and unseen partitions to evaluate generalization under practical conditions. We systematically examine how input specification completeness and retrieval-augmented generation affect class-level correctness across multiple state-of-the-art LLMs. Our evaluation reveals a substantial performance gap: while LLMs achieve 84 to 89% correctness on synthetic benchmarks, they attain only 25 to 34% on real-world class tasks, with minimal distinction between familiar and novel codebases. Comprehensive documentation provides marginal improvements (1 to 3%), whereas retrieval augmentation yields greater gains (4 to 7%) by supplying concrete implementation patterns. Error analysis identifies AttributeError, TypeError, and AssertionError as dominant failure modes, with distinct patterns between synthetic and real-world scenarios. These findings provide actionable insights for enhancing context modelling, documentation strategies, and retrieval integration in production code assistance tools.

代码生成真实场景泛化能力检索增强

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。