现有大模型代码生成能力强,但理解执行流程能力弱。
CoCoNUT: Structural Code Understanding does not fall out of a tree
- 用真实调用路径测试模型执行追踪能力
- 顶级模型仅正确追踪47%的代码路径
- 对递归、多线程、面向对象等结构几乎无法理解
大型语言模型在代码生成、修复和补全等任务上表现优异,部分模型性能已接近甚至超过人类。本文通过提取HumanEval基准中模型生成的代码,并利用测试集中函数调用采样构建执行路径,评估七种先进LLM在追踪代码执行路径方面的能力。结果显示,尽管模型能生成语义正确的代码,但在追踪复杂控制流时表现有限,尤其面对长路径和特定结构时。即使是表现最佳的Gemini模型,也仅能完全准确生成47%的HumanEval任务执行路径。此外,本文新增了包含递归、并行处理及面向对象编程(含继承、多态)的子集,发现这些结构下模型准确率均低于5%。基于此,我们提出CoCoNUT数据集,用于衡量模型对代码执行路径的追踪与理解能力,涵盖高级结构成分。研究结论指出,当前大模型在代码推理能力上仍有显著提升空间,期待该数据集助力相关研究。
原文摘要 · Abstract (English)
Large Language Models (LLMs) have shown impressive performance across a wide array of tasks involving both structured and unstructured textual data. Recent results on various benchmarks for code generation, repair, or completion suggest that certain models have programming abilities comparable to or even surpass humans. In this work, we demonstrate that high performance on such benchmarks does not correlate to humans' innate ability to understand structural control flow in code. To this end, we extract solutions from the HumanEval benchmark, which the relevant models perform strongly on, and trace their execution path using function calls sampled from the respective test set. Using this dataset, we investigate the ability of seven state-of-the-art LLMs to match the execution trace and find that, despite their ability to generate semantically identical code, they possess limited ability to trace execution paths, especially for longer traces and specific control structures. We find that even the top-performing model, Gemini, can fully and correctly generate only 47% of HumanEval task traces. Additionally, we introduce a subset for three key structures not contained in HumanEval: Recursion, Parallel Processing, and Object-Oriented Programming, including concepts like Inheritance and Polymorphism. Besides OOP, we show that none of the investigated models achieve an accuracy over 5% on the relevant traces. Aggregating these specialized parts with HumanEval tasks, we present CoCoNUT: Code Control Flow for Navigation Understanding and Testing, which measures a model's ability to trace execution of code upon relevant calls, including advanced structural components. We conclude that current LLMs need significant improvement to enhance code reasoning abilities. We hope our dataset helps researchers bridge this gap.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。