动态代码基准评测大模型生成能力,防记忆陷阱更真实。
DynaCode: A Dynamic Complexity-Aware Code Benchmark for Evaluating Large Language Models in Code Generation
- 构建动态生成的代码问题库,按复杂度分层设计
- 12个大模型平均性能下降16.8%至45.7%,复杂度越高越差
- 结合调用图分析模型对嵌套函数的处理偏好
大语言模型在代码生成任务中表现不断提升,但现有基准数据集静态固定,易导致模型记忆测试样例而非泛化,引发数据污染和评估失真。为此,我们提出DynaCode,一个动态、复杂度感知的代码生成评估基准。该基准通过复杂度与调用图结构双重指标系统评估模型,生成多达1.89亿个唯一嵌套代码问题,涵盖四个复杂度层级和16类调用图。在12个最新大模型上测试显示,相比静态基准MBPP+,平均性能下降16.8%至45.7%,且复杂度越高性能越低,验证了其区分能力。进一步分析揭示模型对嵌套函数间交互的偏好。代码与数据集已开源于https://github.com/HWH-2000/DynaCode。
原文摘要 · Abstract (English)
The rapid advancement of large language models (LLMs) has significantly improved their performance in code generation tasks. However, existing code benchmarks remain static, consisting of fixed datasets with predefined problems. This makes them vulnerable to memorization during training, where LLMs recall specific test cases instead of generalizing to new problems, leading to data contamination and unreliable evaluation results. To address these issues, we introduce DynaCode, a dynamic, complexity-aware benchmark that overcomes the limitations of static datasets. DynaCode evaluates LLMs systematically using a complexity-aware metric, incorporating both code complexity and call-graph structures. DynaCode achieves large-scale diversity, generating up to 189 million unique nested code problems across four distinct levels of code complexity, referred to as units, and 16 types of call graphs. Results on 12 latest LLMs show an average performance drop of 16.8% to 45.7% compared to MBPP+, a static code generation benchmark, with performance progressively decreasing as complexity increases. This demonstrates DynaCode's ability to effectively differentiate LLMs. Additionally, by leveraging call graphs, we gain insights into LLM behavior, particularly their preference for handling subfunction interactions within nested code. Our benchmark and evaluation code are available at https://github.com/HWH-2000/DynaCode.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。