mlsanityData to 7 Oct 2026

NExT: Teaching Large Language Models to Reason about Code Execution

arXiv 2404.14662 ↗First posted 23 Apr 2024cs.LG cs.CL cs.PLcited by 60

On the map: LLM reasoning → Reasoning for agents, planning and code

Abstract (arXiv)

A fundamental skill among human developers is the ability to understand and reason about program execution. As an example, a programmer can mentally simulate code execution in natural language to debug and repair code (aka. rubber duck debugging). However, large language models (LLMs) of code are typically trained on the surface textual form of programs, thus may lack a semantic understanding of how programs execute at run-time. To address this issue, we propose NExT, a method to teach LLMs to inspect the execution traces of programs (variable states of executed lines) and reason about their run-time behavior through chain-of-thought (CoT) rationales. Specifically, NExT uses self-training to bootstrap a synthetic training set of execution-aware rationales that lead to correct task solutions (e.g., fixed programs) without laborious manual annotation. Experiments on program repair tasks based on MBPP and HumanEval demonstrate that NExT improves the fix rate of a PaLM 2 model, by 26.1% and 14.3% absolute, respectively, with significantly improved rationale quality as verified by automated metrics and human raters. Our model can also generalize to scenarios where program traces are absent at test-time.

Key facts. Cited by 60 papers in the map (data through 7 Oct 2026). Placed in Reasoning for agents, planning and code, one of 17 directions in LLM reasoning. Builds on 65 of its 87 references that are in the map. First posted on arXiv 23 Apr 2024.

Builds on

65 of 87 references.

Closest ancestors · 3

Same direction, newest first

  1. 2023Teaching Large Language Models to Self-Debug11 Apr
  2. 2023LEVER: Learning to Verify Language-to-Code Generation with Execution16 Feb
  3. 2022Reasoning Like Program Executors27 Jan

Other references · 62

  1. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
  2. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
  3. 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,355
  4. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  5. 2023Let's Verify Step by Stepcited by 3,598
  6. 2021Program Synthesis with Large Language Modelscited by 3,509
  7. 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,317
  8. 2022Scaling Instruction-Finetuned Language Modelscited by 2,997
  9. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  10. 2024Mixtral of Expertscited by 1,785
  11. 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
  12. 2023PaLM 2 Technical Reportcited by 1,154
38 more
  1. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
  2. 2022STaR: Bootstrapping Reasoning With Reasoningcited by 895
  3. 2023Math-Shepherd: Verify and Reinforce LLMs Step-by-step without Human Annotationscited by 895
  4. 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 871
  5. 2022Solving math word problems with process- and outcome-based feedbackcited by 871
  6. 2023StarCoder: may the source be with you!cited by 790
  7. 2023The Flan Collection: Designing Data and Methods for Effective Instruction Tuningcited by 734
  8. 2014Neural Turing Machinescited by 630
  9. 2023Textbooks Are All You Needcited by 561
  10. 2023Orca: Progressive Learning from Complex Explanation Traces of GPT-4cited by 369
  11. 2019Explain Yourself! Leveraging Language Models for Commonsense Reasoningcited by 367
  12. 2022Teaching Small Language Models to Reasoncited by 279
  13. 2023Specializing Smaller Language Models towards Multi-Step Reasoningcited by 249
  14. 2017Thinking Fast and Slow with Deep Learning and Tree Searchcited by 245
  15. 2023OctoPack: Instruction Tuning Code Large Language Modelscited by 178
  16. 2019SPoC: Search-based Pseudocode to Codecited by 176
  17. 2020Unsupervised Commonsense Question Answering with Self-Talkcited by 161
  18. 2023Orca 2: Teaching Small Language Models How to Reasoncited by 157
  19. 2018SequenceR: Sequence-to-Sequence Learning for End-to-End Program Repaircited by 144
  20. 2022Practical Program Repair in the Era of Large Pre-trained Language Modelscited by 133
  21. 2023An Analysis of the Automatic Bug Fixing Performance of ChatGPTcited by 108
  22. 2014Learning to Executecited by 105
  23. 2022Automating Code Review Activities by Large-Scale Pre-trainingcited by 98
  24. 2023The Programmer's Assistant: Conversational Interaction with a Large Language Model for Software Developmentcited by 95
  25. 2022Natural Language to Code Generation in Interactive Data Science Notebookscited by 86
  26. 2023Impact of Code Language Models on Automated Program Repaircited by 85
  27. 2022Less Training, More Repairing Please: Revisiting Automated Program Repair via Zero-shot Learningcited by 76
  28. 2023ReCEval: Evaluating Reasoning Chains via Correctness and Informativenesscited by 76
  29. 2022Automated Repair of Programs from Large Language Modelscited by 71
  30. 2018Memory Augmented Policy Optimization for Program Synthesis and Semantic Parsingcited by 57
  31. 2018Robust Text-to-SQL Generation with Execution-Guided Decodingcited by 51
  32. 2023Training Chain-of-Thought via Latent-Variable Inferencecited by 46
  33. 2023Explainable Automated Debugging via Large Language Model-driven Scientific Debuggingcited by 40
  34. 2020Synthesize, Execute and Debug: Learning to Repair for Neural Program Synthesiscited by 39
  35. 2022Learning Math Reasoning from Self-Sampled Correct and Partially-Correct Solutionscited by 38
  36. 2020Learning to Execute Programs with Instruction Pointer Attention Graph Neural Networkscited by 35
  37. 2021Latent Execution for Neural Program Synthesiscited by 35
  38. 2016Programming with a Differentiable Forth Interpretercited by 33

50 most cited of 62 All 62 (JSON)

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 11; 2025: 30; 2026: 19.

60 papers.

Sort:

By area:

  1. 2024Training Language Models to Self-Correct via Reinforcement Learningcited by 405
  2. 2025A Survey on Test-Time Scaling in Large Language Models: What, How, Where, and How Well?cited by 215
  3. 2024Lingma SWE-GPT: An Open Development-Process-Centric Language Model for Automated Software Improvementcited by 57
  4. 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMscited by 47
  5. 2024From Code to Correctness: Closing the Last Mile of Code Generation with Hierarchical Debuggingcited by 46
  6. 2026Code as Agent Harnesscited by 40
  7. 2025Teaching Language Models to Critique via Reinforcement Learningcited by 38
  8. 2025Mitigating Overthinking in Large Reasoning Models via Manifold Steeringcited by 32
  9. 2026Group-Evolving Agents: Open-Ended Self-Improvement via Experience Sharingcited by 32
  10. 2024Surveying the Effects of Quality, Diversity, and Complexity in Synthetic Data From Large Language Modelscited by 31
  11. 2024What Makes Large Language Models Reason in (Multi-Turn) Code Generation?cited by 29
  12. 2025Multi-Turn Code Generation Through Single-Step Rewardscited by 27
38 more
  1. 2024PyBench: Evaluating LLM Agent on various real-world coding taskscited by 24
  2. 2025EquiBench: Benchmarking Large Language Models' Reasoning about Program Semantics via Equivalence Checkingcited by 23
  3. 2025cAST: Enhancing Code Retrieval-Augmented Generation with Structural Chunking via Abstract Syntax Treecited by 17
  4. 2025Learning to Generate Unit Tests for Automated Debuggingcited by 16
  5. 2025CodeARC: Benchmarking Reasoning Capabilities of LLM Agents for Inductive Program Synthesiscited by 15
  6. 2025CodeCrash: Exposing LLM Fragility to Misleading Natural Language in Code Reasoningcited by 14
  7. 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligencecited by 13
  8. 2025RepoST: Scalable Repository-Level Coding Environment Construction with Sandbox Testingcited by 12
  9. 2025What I cannot execute, I do not understand: Training and Evaluating LLMs on Program Execution Tracescited by 11
  10. 2024LLMs as Continuous Learners: Improving the Reproduction of Defective Code in Software Issuescited by 10
  11. 2024Coffee-Gym: An Environment for Evaluating and Improving Natural Language Feedback on Erroneous Codecited by 9
  12. 2024CodeNav: Beyond tool-use to using real-world codebases with LLM agentscited by 8
  13. 2025CoCoNUT: Structural Code Understanding does not fall out of a treecited by 7
  14. 2025HoarePrompt: Structural Reasoning About Program Correctness in Natural Languagecited by 7
  15. 2025Agent That Debugs: Dynamic State-Guided Vulnerability Repaircited by 7
  16. 2024CodeLutra: Boosting LLM Code Generation via Preference-Guided Refinementcited by 6
  17. 2025A Tool for In-depth Analysis of Code Execution Reasoning of Large Language Modelscited by 6
  18. 2025The KoLMogorov Test: Compression by Code Generationcited by 5
  19. 2025L0-Reasoning Bench: Evaluating Procedural Correctness in Language Models via Simple Program Executioncited by 5
  20. 2025LLMs Lean on Priors, Not Programming Language Semanticscited by 5
  21. 2026ExecVerify: White-Box RL with Verifiable Stepwise Rewards for Code Execution Reasoningcited by 5
  22. 2025The Hitchhiker's Guide to Program Analysis, Part II: Deep Thoughts by LLMscited by 4
  23. 2025CodeReasoner: Enhancing the Code Reasoning Ability with Reinforcement Learningcited by 4
  24. 2025Towards Verified Code Reasoning by LLMscited by 4
  25. 2026Aletheia: What Makes RLVR For Code Verifiers Tick?cited by 4
  26. 2025Gradient-Based Program Repair: Fixing Bugs in Continuous Program Spacescited by 3
  27. 2025Do Code Semantics Help? A Comprehensive Study on Execution Trace-Based Information for Code Large Language Modelscited by 3
  28. 2025Think Socially via Cognitive Reasoningcited by 2
  29. 2026Towards AGI A Pragmatic Approach Towards Self Evolving Agentcited by 2
  30. 2024Morescient GAI for Software Engineering (Extended Version)cited by 1
  31. 2025Investigating Execution-Aware Language Models for Code Optimizationcited by 1
  32. 2025Replacing thinking with tool usage enables reasoning in small language modelscited by 1
  33. 2026Rethinking Code Similarity for Automated Algorithm Design with LLMscited by 1
  34. 2026Towards a Neural Debugger for Pythoncited by 1
  35. 2026Agentic MIP Research: Accelerated Constraint Handler Generationcited by 1
  36. 2026StepCodeReasoner: Aligning Code Reasoning with Stepwise Execution Traces via Reinforcement Learningcited by 1
  37. 2025Why Stop at One Error? Benchmarking LLMs as Data Science Code Debuggers for Multi-Hop and Multi-Bug Errorscited by 0
  38. 2025Generating Verifiable Chain of Thoughts from Exection-Tracescited by 0

50 most cited of 60 All 60 (JSON)

Similar, not cited

Close in wording, no citation either way

  1. 2024SemCoder: Training Code Language Models with Comprehensive Semantics Reasoning
  2. 2025Chain of Execution Supervision Promotes General Reasoning in Large Language Models
  3. 2025Demystifying Errors in LLM Reasoning Traces: An Empirical Study of Code Execution Simulation
  4. 2026Can LLMs Reason About Runtime Behavior? A Repository-Level Dynamic Benchmark
  5. 2025Code Execution as Grounded Supervision for LLM Reasoning
  6. 2025Towards Effectively Leveraging Execution Traces for Program Repair with Code LLMs
  7. 2026CodeEval: A pedagogical approach for targeted evaluation of code-trained Large Language Models
  8. 2025PACIFIC: a framework for generating benchmarks to check Precise Automatically Checked Instruction Following In Code