基于编程语言知识单元(KUs)评估和改进代码生成基准的代表性——一项实证研究
Assessing and Improving the Representativeness of Code Generation Benchmarks Using Knowledge Units (KUs) of Programming Languages -- An Empirical Study
AI总结:
本文通过分析编程语言知识单元(KUs)的覆盖情况,提出基于提示的框架改进代码生成基准的代表性,从而更准确评估LLM的代码生成能力。
摘要:
大型语言模型(LLMs)如GPT-4、Claude和LLaMA在代码生成任务中表现出色,通常通过基准(如HumanEval)进行评估。然而,有效的代码生成需要模型能够理解和应用广泛的语言概念。如果基准中测试的概念不具有现实项目中使用的概念的代表性,评估结果可能会不完整。尽管存在这一担忧,但代码概念在基准中的代表性尚未被系统性地研究。为解决这一差距,我们提出了第一项实证研究,通过知识单元(KUs)——由语言构造和API提供的连贯编程语言能力集合的视角,分析代码生成基准的代表性。我们分析了两个广泛使用的Python基准HumanEval和MBPP中的KU覆盖情况,并将其与30个现实世界的Python项目进行比较。我们的结果表明,每个基准仅覆盖了识别出的20个KUs中的50%,而项目则能够涵盖所有KUs并具有相对均衡的分布。相比之下,基准任务表现出高度偏斜的KU分布。为了缓解这种不匹配,我们提出了一种基于提示的LLM框架,该框架通过合成基于KU的任务来重新平衡基准的KU分布,并使其更符合现实世界的使用情况。使用该框架,我们生成了440个新任务并增强了现有基准。增强后的基准显著提高了KU覆盖度,并实现了分布对齐的60%以上改进。对最先进LLM在这些增强基准上的评估显示了一致且统计显著的性能下降(12.54-44.82%),表明现有基准由于KU覆盖有限而高估了LLM的性能。我们的发现为构建更现实的LLM代码生成能力评估提供了可操作的指导。
英文摘要:
Large Language Models (LLMs) such as GPT-4, Claude and LLaMA have shown impressive performance in code generation, typically evaluated using benchmarks (e.g., HumanEval). However, effective code generation requires models to understand and apply a wide range of language concepts. If the concepts exercised in benchmarks are not representative of those used in real-world projects, evaluations may yield incomplete. Despite this concern, the representativeness of code concepts in benchmarks has not been systematically examined. To address this gap, we present the first empirical study that analyzes the representativeness of code generation benchmarks through the lens of Knowledge Units (KUs) - cohesive sets of programming language capabilities provided by language constructs and APIs. We analyze KU coverage in two widely used Python benchmarks, HumanEval and MBPP, and compare them with 30 real-world Python projects. Our results show that each benchmark covers only half of the identified 20 KUs, whereas projects exercise all KUs with relatively balanced distributions. In contrast, benchmark tasks exhibit highly skewed KU distributions. To mitigate this misalignment, we propose a prompt-based LLM framework that synthesizes KU-based tasks to rebalance benchmark KU distributions and better align them with real-world usage. Using this framework, we generate 440 new tasks and augment existing benchmarks. The augmented benchmarks substantially improve KU coverage and achieve over a 60% improvement in distributional alignment. Evaluations of state-of-the-art LLMs on these augmented benchmarks reveal consistent and statistically significant performance drops (12.54-44.82%), indicating that existing benchmarks overestimate LLM performance due to their limited KU coverage. Our findings provide actionable guidance for building more realistic evaluations of LLM code-generation capabilities.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。