Scattered Forest Search: Smarter Code Space Exploration with LLMs
On the map: LLM reasoning → Reasoning for agents, planning and code
Abstract (arXiv)
We frame code generation as a black-box optimization problem within the code space and demonstrate how optimization-inspired techniques can enhance inference scaling. Based on this perspective, we propose SCATTERED FOREST SEARCH (SFS), a novel approach that improves solution diversity and better exploits feedback during evolutionary search. Our theoretical analysis illustrates how these methods help avoid local optima during optimization, leading to more efficient exploration. Extensive experiments on HumanEval, MBPP, APPS, CodeContests, and Leetcode reveal significant performance gains. For instance, our method achieves a pass@1 rate of 67.1% on HumanEval+ and 87.2% on HumanEval with GPT-3.5, marking improvements of 8.6% and 4.3% over the state-of-the-art, while also halving the iterations needed to find the correct solution. Furthermore, our approach scales more efficiently than existing search techniques, including tree search, line search, and repeated sampling.
Key facts. Cited by 10 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 53 of its 63 references that are in the map. First posted on arXiv 22 Oct 2024.
Builds on
53 of 63 references.
Closest ancestors · 5
Same direction, newest first
- 2024MapCoder: Multi-Agent Code Generation for Competitive Problem Solving18 May
- 2023Language Agent Tree Search Unifies Reasoning Acting and Planning in Language Models6 Oct
- 2023Reasoning with Language Model is Planning with World Model24 May
- 2023Teaching Large Language Models to Self-Debug11 Apr
- 2022Competition-Level Code Generation with AlphaCode8 Feb
Other references · 48
- 2022Training language models to follow instructions with human feedbackcited by 15,712
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2021Training Verifiers to Solve Math Word Problemscited by 9,743
- 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,355
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 7,916
- 2023Reflexion: Language Agents with Verbal Reinforcement Learningcited by 4,064
- 2023Let's Verify Step by Stepcited by 3,598
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,317
- 2023Tree of Thoughts: Deliberate Problem Solving with Large Language Modelscited by 3,155
- 2022Constitutional AI: Harmlessness from AI Feedbackcited by 2,950
36 more
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2024Scaling LLM Test-Time Compute Optimally can be More Effective than Scaling Model Parameterscited by 1,928
- 2023MetaGPT: Meta Programming for A Multi-Agent Collaborative Frameworkcited by 1,761
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
- 2024Large Language Monkeys: Scaling Inference Compute with Repeated Samplingcited by 946
- 2021Measuring Coding Challenge Competence With APPScited by 879
- 2023Graph of Thoughts: Solving Elaborate Problems with Large Language Modelscited by 873
- 2022Solving math word problems with process- and outcome-based feedbackcited by 871
- 2023Large Language Models as Optimizerscited by 830
- 2017Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithmcited by 723
- 2022CodeT: Code Generation with Generated Testscited by 369
- 2023Alphazero-like Tree-Search can Guide Large Language Model Decoding and Trainingcited by 291
- 2024Inference Scaling Laws: An Empirical Analysis of Compute-Optimal Inference for Problem-Solving with Language Modelscited by 282
- 2024CodeAgent: Enhancing Code Generation with Tool-Integrated Agent Systems for Real-World Repo-level Coding Challengescited by 278
- 2024TextGrad: Automatic "Differentiation" via Textcited by 250
- 2023Is Self-Repair a Silver Bullet for Code Generation?cited by 191
- 2023Planning with Large Language Models for Code Generationcited by 179
- 2024AlphaMath Almost Zero: Process Supervision without Processcited by 160
- 2023Beyond Chinchilla-Optimal: Accounting for Inference in Language Model Scaling Lawscited by 155
- 2024Stream of Search (SoS): Learning to Search in Languagecited by 141
- 2023CodePlan: Repository-level Coding using LLMs and Planningcited by 139
- 2024MAGIS: LLM-Based Multi-Agent Framework for GitHub Issue Resolutioncited by 132
- 2024Toward Self-Improvement of LLMs via Imagination, Searching, and Criticizingcited by 123
- 2023Large Language Models as Evolutionary Optimizerscited by 122
- 2023Self-planning Code Generation with Large Language Modelscited by 121
- 2024Planning In Natural Language Improves LLM Search For Code Generationcited by 79
- 2023Using Large Language Models for Hyperparameter Optimizationcited by 71
- 2023CodeChain: Towards Modular Code Generation Through Chain of Self-revisions with Representative Sub-modulescited by 58
- 2024Large Language Models As Evolution Strategiescited by 57
- 2024Code Repair with LLMs gives an Exploration-Exploitation Tradeoffcited by 50
- 2024When is Tree Search Useful for LLM Planning? It Depends on the Discriminatorcited by 46
- 2023ALGO: Synthesizing Algorithmic Programs with LLM-Generated Oracle Verifierscited by 41
- 2023Language Models as Black-Box Optimizers for Vision-Language Modelscited by 36
- 2023LLM-Assisted Code Cleaning For Training Accurate Code Generatorscited by 27
Built on by
Citing papers per year: 2024: 1; 2025: 7; 2026: 2.
10 papers.
- 2025Towards Reasoning Era: A Survey of Long Chain-of-Thought for Reasoning Large Language Modelscited by 381
- 2025HardTests: Synthesizing High-Quality Test Cases for LLM Codingcited by 22
- 2025DISC: Dynamic Decomposition Improves LLM Inference Scalingcited by 9
- 2025Scoring Verifiers: Evaluating Synthetic Verification for Code and Reasoningcited by 8
- 2025TDRM: Smooth Reward Models with Temporal Difference for LLM RL and Inferencecited by 8
- 2024Generating Diverse Hypotheses for Inductive Reasoningcited by 6
- 2025LLMPC: Large Language Model Predictive Controlcited by 4
- 2026AdaExplore: Failure-Driven Adaptation and Diversity-Preserving Search for Efficient Kernel Generationcited by 3
- 2025Visualising Policy-Reward Interplay to Inform Zeroth-Order Preference Optimisation of Large Language Modelscited by 1
- 2026Shockingly Simple Self-retrospection Improves Agentic Models Without RLcited by 0
- 2026Shockingly Simple Self-retrospection Improves Agentic Models Without RL28 Sep 2026
- 2026AdaExplore: Failure-Driven Adaptation and Diversity-Preserving Search for Efficient Kernel Generation17 Apr 2026
- 2025TDRM: Smooth Reward Models with Temporal Difference for LLM RL and Inference18 Sep 2025
- 2025HardTests: Synthesizing High-Quality Test Cases for LLM Coding30 May 2025
- 2025Towards Reasoning Era: A Survey of Long Chain-of-Thought for Reasoning Large Language Models12 Mar 2025
- 2025Visualising Policy-Reward Interplay to Inform Zeroth-Order Preference Optimisation of Large Language Models5 Mar 2025
- 2025DISC: Dynamic Decomposition Improves LLM Inference Scaling23 Feb 2025
- 2025Scoring Verifiers: Evaluating Synthetic Verification for Code and Reasoning19 Feb 2025
- 2025LLMPC: Large Language Model Predictive Control5 Jan 2025
- 2024Generating Diverse Hypotheses for Inductive Reasoning18 Dec 2024
Similar, not cited
Close in wording, no citation either way
- 2026GraphAHA: Graph-Based Adaptive Search with Heterogeneous Actions for Test-Time Code Generation
- 2025Let's Revise Step-by-Step: A Unified Local Search Framework for Code Generation with LLMs
- 2024Thinking Before Running! Efficient Code Generation with Thorough Exploration and Optimal Refinement
- 2026Simple Baselines are Competitive with Code Evolution
- 2024Seed-CTS: Unleashing the Power of Tree Search for Superior Performance in Competitive Coding Tasks
- 2026Idea Search: Guiding Tree Search with Ideas to Explore Diverse Scientific Methods
- 2024Search-Based LLMs for Code Optimization
- 2026Code Generation by Differential Test Time Scaling