Large Language Models (LLMs) have been widely used to automate programming tasks. Their capabilities have been evaluated by assessing the quality of generated code through tests or proofs. The extent to which they can reason about code is a critical question revealing important insights about their true capabilities. This paper introduces CodeMind, a framework designed to gauge the code reasoning abilities of LLMs through the following explicit and implicit code reasoning tasks: Independent Execution Reasoning (IER), Specification Reasoning (SR) and Dynamic Semantics Reasoning (DSR). The first evaluates the abilities of LLMs to simulate the execution of given inputs to a code and predict the output (IER). The second assesses the abilities of LLMs to incorporate the simulation of test data in the specification into code generation (SR). Finally, CodeMind evaluates LLMs' abilities to understand overall code semantics only given a specific input/output (DSR). Our extensive evaluation of ten LLMs across four widely used benchmarks using CodeMind shows that LLMs, depending on their size and training strategy, can reason about some dynamic aspects of code. However, their performance drops for code with higher complexity, non-trivial logical and arithmetic operators, non-primitive types, and API calls. We show that these reasoning tasks evaluate LLMs differently, and a comprehensive evaluation of code reasoning requires them all. Finally, we show that the performance of LLMs in bug repair is not correlated with any of the code reasoning tasks, and except for advanced frontier models, other LLMs do not incorporate code reasoning when performing bug repair.


翻译:大型语言模型(LLMs)已被广泛应用于编程任务的自动化。其能力通常通过测试或证明来评估生成代码的质量。而模型能在多大程度上对代码进行推理,是揭示其真实能力的关键问题。本文介绍了CodeMind,一个旨在通过以下显式和隐式代码推理任务来衡量LLMs代码推理能力的框架:独立执行推理(IER)、规格推理(SR)和动态语义推理(DSR)。第一项任务评估LLMs模拟给定输入执行代码并预测输出的能力(IER);第二项评估LLMs将规格中的测试数据模拟整合到代码生成中的能力(SR);最后,CodeMind评估LLMs在仅给定特定输入/输出的情况下理解整体代码语义的能力(DSR)。我们使用CodeMind对十个LLMs在四个广泛使用的基准上进行的广泛评估表明,LLMs(取决于其规模和训练策略)能够对代码的某些动态方面进行推理。然而,在处理复杂度更高、包含非平凡逻辑和算术运算符、非原始类型以及API调用的代码时,其性能会有所下降。我们还发现,这些推理任务对LLMs的评估方式各不相同,因此对代码推理的全面评估需要涵盖所有任务。最后,我们指出,LLMs在错误修复中的表现与任何代码推理任务均无相关性,且除先进的前沿模型外,其他LLMs在执行错误修复时并未融入代码推理能力。

0
下载
关闭预览

相关内容

评估大语言模型在科学发现中的作用
专知会员服务
19+阅读 · 2025年12月19日
通过逻辑推理赋能大语言模型:综述
专知会员服务
32+阅读 · 2025年2月24日
大语言模型中的逻辑推理:综述
专知会员服务
48+阅读 · 2025年2月15日
《大型语言模型代码生成》综述
专知会员服务
70+阅读 · 2024年6月4日
大型语言模型高效推理综述
专知会员服务
64+阅读 · 2024年4月23日
「大型语言模型推理」综述
专知会员服务
95+阅读 · 2022年12月24日
自然语言处理中的语言模型预训练方法
PaperWeekly
14+阅读 · 2018年10月21日
深度学习文本分类方法综述(代码)
中国人工智能学会
28+阅读 · 2018年6月16日
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
12+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
Arxiv
0+阅读 · 3月4日
Arxiv
12+阅读 · 2023年5月31日
VIP会员
相关主题
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
7+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
8+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
6+阅读 · 6月17日
相关VIP内容
评估大语言模型在科学发现中的作用
专知会员服务
19+阅读 · 2025年12月19日
通过逻辑推理赋能大语言模型:综述
专知会员服务
32+阅读 · 2025年2月24日
大语言模型中的逻辑推理:综述
专知会员服务
48+阅读 · 2025年2月15日
《大型语言模型代码生成》综述
专知会员服务
70+阅读 · 2024年6月4日
大型语言模型高效推理综述
专知会员服务
64+阅读 · 2024年4月23日
「大型语言模型推理」综述
专知会员服务
95+阅读 · 2022年12月24日
相关基金
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
12+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
Top
微信扫码咨询专知VIP会员