mlsanityData to 7 Oct 2026

RethinkMCTS: Refining Erroneous Thoughts in Monte Carlo Tree Search for Code Generation

arXiv 2409.09584 ↗First posted 15 Sep 2024cs.SE cs.CLcited by 25

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

Abstract (arXiv)

Tree search methods have demonstrated impressive performance in code generation. Previous methods combine tree search with reflection that summarizes past mistakes to achieve iterative improvement. However, these methods face significant challenges. First, they search directly within the code language space, neglecting the underlying reasoning process critical for effective code generation. Second, reflection-based approaches merely accumulate historical errors in memory without providing correct reasoning pathways, making it difficult for subsequent search iterations to identify optimal solutions, resulting in decreased search quality. In this work, we propose RethinkMCTS, a framework that systematically explores and refines the reasoning process for code generation. Specifically, we employ MCTS to search for thoughts before code generation and integrate MCTS with a refinement mechanism called rethink, which incorporates fine-grained code execution feedback to refine erroneous thoughts during the search. It ensures the search path aligns with better reasoning, improving overall search quality. Through extensive experiments, we demonstrate that RethinkMCTS outperforms previous search-based and feedback-enhanced code generation baselines.

Key facts. Cited by 25 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 32 of its 51 references that are in the map. First posted on arXiv 15 Sep 2024.

Builds on

32 of 51 references.

Closest ancestors · 2

Same direction, newest first

  1. 2023Language Agent Tree Search Unifies Reasoning Acting and Planning in Language Models6 Oct
  2. 2023Reasoning with Language Model is Planning with World Model24 May

Other references · 30

  1. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
  2. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  3. 2023Reflexion: Language Agents with Verbal Reinforcement Learningcited by 4,064
  4. 2021Program Synthesis with Large Language Modelscited by 3,509
  5. 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,317
  6. 2023Tree of Thoughts: Deliberate Problem Solving with Large Language Modelscited by 3,155
  7. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  8. 2023Large Language Models Cannot Self-Correct Reasoning Yetcited by 965
  9. 2021Measuring Coding Challenge Competence With APPScited by 879
  10. 2023StarCoder: may the source be with you!cited by 790
  11. 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
  12. 2017Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithmcited by 723
18 more
  1. 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
  2. 2023Alphazero-like Tree-Search can Guide Large Language Model Decoding and Trainingcited by 291
  3. 2024CodeAgent: Enhancing Code Generation with Tool-Integrated Agent Systems for Real-World Repo-level Coding Challengescited by 278
  4. 2023Using an LLM to Help With Code Understandingcited by 222
  5. 2023Planning with Large Language Models for Code Generationcited by 179
  6. 2019SPoC: Search-based Pseudocode to Codecited by 176
  7. 2024Self-Organized Agents: A LLM Multi-Agent Framework toward Ultra Large-Scale Code Generation and Optimizationcited by 84
  8. 2024Planning In Natural Language Improves LLM Search For Code Generationcited by 79
  9. 2023CodeScore: Evaluating Code Generation by Learning Code Executioncited by 66
  10. 2023Large Language Models are In-Context Semantic Reasoners rather than Symbolic Reasonerscited by 63
  11. 2024Iterative Refinement of Project-Level Code Context for Precise Code Generation with Compiler Feedbackcited by 45
  12. 2024LLM-A*: Large Language Model Enhanced Incremental Heuristic Search on Path Planningcited by 44
  13. 2024Make Every Move Count: LLM-based High-Quality RTL Code Generation Using MCTScited by 42
  14. 2024Uncertainty of Thoughts: Uncertainty-Aware Planning Enhances Information Seeking in Large Language Modelscited by 37
  15. 2024AST-T5: Structure-Aware Pretraining for Code Generation and Understandingcited by 32
  16. 2024LiteSearch: Efficacious Tree Search for LLMcited by 30
  17. 2024Enhancing LLM-Based Coding Tools through Native Integration of IDE-Derived Static Contextcited by 10
  18. 2024Let the Code LLM Edit Itself When You Edit the Codecited by 8

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 4; 2025: 15; 2026: 6.

25 papers.

Sort:

By area:

  1. 2025Towards Reasoning Era: A Survey of Long Chain-of-Thought for Reasoning Large Language Modelscited by 381
  2. 2025From System 1 to System 2: A Survey of Reasoning Large Language Modelscited by 319
  3. 2025S*: Test Time Scaling for Code Generationcited by 95
  4. 2025ReSo: A Reward-driven Self-organizing LLM-based Multi-Agent System for Reasoning Taskscited by 30
  5. 2024Agentic Information Retrievalcited by 19
  6. 2025Generative AI Act II: Test Time Scaling Drives Cognition Engineeringcited by 14
  7. 2025Navigating the Alpha Jungle: An LLM-Powered MCTS Framework for Formulaic Factor Miningcited by 13
  8. 2026MMSkills: Towards Multimodal Skills for General Visual Agentscited by 13
  9. 2024SRA-MCTS: Self-driven Reasoning Augmentation with Monte Carlo Tree Search for Code Generationcited by 9
  10. 2025Optimizing Prompt Sequences using Monte Carlo Tree Search for LLM-Based Optimizationcited by 9
  11. 2025From Large to Small: Transferring CUDA Optimization Expertise via Reasoning Graphcited by 9
  12. 2025ARCS: Agentic Retrieval-Augmented Code Synthesis with Iterative Refinementcited by 6
13 more
  1. 2025LLM-First Search: Self-Guided Exploration of the Solution Spacecited by 5
  2. 2025NL-Debugging: Exploiting Natural Language as an Intermediate Representation for Code Debuggingcited by 4
  3. 2024Seed-CTS: Unleashing the Power of Tree Search for Superior Performance in Competitive Coding Taskscited by 3
  4. 2024Thinking Before Running! Efficient Code Generation with Thorough Exploration and Optimal Refinementcited by 3
  5. 2025Boost, Disentangle, and Customize: A Robust System2-to-System1 Pipeline for Code Generationcited by 2
  6. 2025Monte Carlo Tree Diffusion with Multiple Experts for Protein Designcited by 2
  7. 2026Policy of Thoughts: Scaling Test-Time Training for LLM Reasoning via Online Policy Evolutioncited by 2
  8. 2026Plan-MCTS: Plan Exploration for Action Exploitation in Web Navigationcited by 2
  9. 2025Towards Stepwise Domain Knowledge-Driven Reasoning Optimization and Reflection Improvementcited by 0
  10. 2025DebugTA: An LLM-Based Agent for Simplifying Debugging and Teaching in Programming Educationcited by 0
  11. 2026LogitsCoder: Towards Efficient Chain-of-Thought Path Search via Logits Preference Decoding for Code Generationcited by 0
  12. 2026ROSUM-MCTS: Monte Carlo Tree Search-Inspired HDL Code Summarization with Structural Rewardscited by 0
  13. 2026ReMCTS: Reflection-Enhanced Monte Carlo Tree Search for Code Generationcited by 0

Similar, not cited

Close in wording, no citation either way

  1. 2025RPM-MCTS: Knowledge-Retrieval as Process Reward Model with Monte Carlo Tree Search for Code Generation
  2. 2025MCTS-Judge: Test-Time Scaling in LLM-as-a-Judge for Code Correctness Evaluation
  3. 2025Let's Revise Step-by-Step: A Unified Local Search Framework for Code Generation with LLMs
  4. 2024THOUGHTSCULPT: Reasoning with Intermediate Revision and Search
  5. 2026GraphAHA: Graph-Based Adaptive Search with Heterogeneous Actions for Test-Time Code Generation
  6. 2025SELF-REDRAFT: Eliciting Intrinsic Exploration-Exploitation Balance in Test-Time Scaling for Code Generation
  7. 2026ExeCRE: Execution-Consistency Guided Reliability Estimation for Self-Correcting Code Generation
  8. 2026Are you Synthesizing or Recalling? Evaluating LLMs on Algorithmic Code Retrieval