[Paper Review] Reasoning Runtime Behavior of a Program with LLM: How Far Are We?
This paper proposes $ρ$Eval, a framework to evaluate code reasoning in large language models (LLMs) by analyzing program execution behavior, including runtime states, execution paths, and code coverage. Despite using chain-of-thought prompting, most models perform poorly—achieving only 44.4% average accuracy on Runtime Behavior Reasoning and 10.3 average Incremental Consistency (IC) score—highlighting a critical gap in LLMs' ability to reason logically about program execution.
Large language models for code (i.e., code LLMs) have shown strong code understanding and generation capabilities. To evaluate the capabilities of code LLMs in various aspects, many benchmarks have been proposed (e.g., HumanEval and ClassEval). Code reasoning is one of the most essential abilities of code LLMs, but existing benchmarks for code reasoning are not sufficient. Typically, they focus on predicting the input and output of a program, ignoring the evaluation of the intermediate behavior during program execution, as well as the logical consistency (e.g., the model should not give the correct output if the prediction of execution path is wrong) when performing the reasoning. To address these problems, in this paper, we propose a framework, namely REval, for evaluating code reasoning abilities and consistency of code LLMs with program execution. We utilize existing code benchmarks and adapt them to new benchmarks within our framework. A large-scale empirical study is conducted and most LLMs show unsatisfactory performance on both Runtime Behavior Reasoning (i.e., an average accuracy of 44.4%) and Incremental Consistency Evaluation (i.e., an average IC score of 10.3). Evaluation results of current code LLMs reflect the urgent need for the community to strengthen the code reasoning capability of code LLMs. Our code, data, and ewname leaderboard are available at https://r-eval.github.io.
Motivation & Objective
- To address the lack of evaluation for code LLMs' reasoning about dynamic program behavior during execution.
- To identify shortcomings in current benchmarks that ignore intermediate execution states like control flow and variable states.
- To propose a comprehensive evaluation framework that measures both runtime behavior reasoning and logical consistency in sequential reasoning tasks.
- To reveal the limited reasoning capabilities of current code LLMs through large-scale empirical evaluation.
- To guide future improvements in training and prompting strategies for better code reasoning in LLMs.
Proposed method
- The framework, $ρ$Eval, evaluates code LLMs using four runtime behavior reasoning tasks: Code Coverage Prediction (CCP), Program State Prediction (PSP), Execution Path Prediction (EPP), and Output Prediction (OP).
- It introduces Incremental Consistency Evaluation (ICE) to assess logical consistency across sequential reasoning tasks, ensuring predictions align with execution semantics.
- The framework adapts existing benchmarks (HumanEval and ClassEval) into new evaluation sets focused on execution dynamics and consistency.
- It employs chain-of-thought (CoT) prompting to elicit reasoning traces from LLMs, enabling structured analysis of their reasoning process.
- A large-scale empirical study evaluates 10 popular code LLMs across multiple models and benchmarks to measure performance on reasoning and consistency.
- The study uses manual rule-based criteria to select representative statements and variables for evaluation, ensuring task relevance and challenge.
Experimental results
Research questions
- RQ1How well can code LLMs reason about intermediate program execution states such as code coverage, variable states, and execution paths?
- RQ2To what extent do code LLMs maintain logical consistency when reasoning about sequentially dependent execution behaviors?
- RQ3What is the performance gap between state-of-the-art code LLMs and human-level reasoning in dynamic program behavior understanding?
- RQ4Can existing benchmarks like HumanEval and ClassEval effectively capture runtime behavior reasoning capabilities?
- RQ5What factors contribute to the poor reasoning and inconsistency in current code LLMs?
Key findings
- Most code LLMs achieve only 44.4% average accuracy on Runtime Behavior Reasoning, indicating weak understanding of program execution dynamics.
- The average Incremental Consistency (IC) score across models is just 10.3, revealing severe logical inconsistencies in sequential reasoning tasks.
- Even GPT-4-Turbo, the strongest performer, achieves only 42.5 IC score, underscoring the persistent challenge in maintaining reasoning consistency.
- The results suggest that current LLMs lack sufficient knowledge about program execution behavior, likely due to insufficient training data on runtime semantics.
- Chain-of-thought prompting improves reasoning but is insufficient to overcome fundamental reasoning and consistency limitations.
- The study reveals a critical need for training with execution behavior and improved prompting strategies to enhance code reasoning in LLMs.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.