Planning with Language Models Through The Lens of Efficiency

Michael Katz, Harsha Kokel, Kavitha Srinivas, Shirin Sohrabi · DOI

Abstract

Recent advancements in Large Language Model (LLM) planning have focused on frameworks that utilize models as the primary search engine, such as Tree of Thoughts (ToT) and Reasoning via Planning (RAP). However, these methods often suffer from high computational costs, lack of formal guarantees, and state-tracking errors. This paper introduces Thought of Search (ToS), a paradigm shift that leverages LLMs to generate symbolic search components—specifically successor generators and goal tests in Python—rather than executing the search steps directly. By combining the flexible reasoning of LLMs with the efficiency of classical search algorithms, ToS achieves 100% accuracy on standard planning benchmarks while significantly reducing API costs and execution time.

Introduction

In the quest to solve complex reasoning and planning tasks, the AI community has increasingly relied on LLMs to simulate search processes. Frameworks like Tree of Thoughts (ToT) treat the LLM as a state-space explorer, calling the model at every node expansion to propose next steps and evaluate progress. While innovative, this approach introduces two critical vulnerabilities: inefficiency and a lack of formal reliability.

Calling an LLM hundreds of times for a single problem instance is not only prohibitively expensive and slow but also environmentally taxing. Furthermore, these methods are neither sound (they can produce invalid plans) nor complete (they are not guaranteed to find a solution even if one exists). This paper proposes Thought of Search (ToS) to bridge the gap between the intuitive reasoning of LLMs and the rigorous efficiency of classical symbolic search.

Methodology: Thought of Search (ToS)

The core philosophy of ToS is "thinking before searching." Instead of involving the LLM during the search process, ToS utilizes the model as a high-level code generator at the outset of the problem-solving phase.

1. Component Generation

The LLM is prompted to define the search space by writing two specific Python functions:

  • Successor Generator: A function that defines all valid moves from a given state.
  • Goal Test: A function that identifies whether a specific state satisfies the solution criteria.

2. Classical Search Integration

Once generated, these functions are integrated into a standard, non-probabilistic search algorithm, such as Breadth-First Search (BFS) or Depth-First Search (DFS). This ensures that the search process itself is systematic and exhaustive.

3. Iterative Refinement

To handle potential coding errors, ToS employs an iterative refinement loop. If the generated code triggers an exception (e.g., an IndexError), the error message is fed back to the LLM. The model then attempts to debug and fix the code, mimicking a standard software development workflow. By moving the LLM to this "meta" level, the system inherits the soundness and completeness of the underlying classical algorithm.

Experimental Setup

The authors evaluated ToS against four representative search and planning benchmarks:

  1. 24 Game: A mathematical puzzle requiring the manipulation of four integers to reach the result 24.
  2. Mini Crosswords: Solving 5x5 crossword puzzles based on horizontal and vertical clues.
  3. BlocksWorld: A classic AI planning domain involving the stacking of blocks into specific configurations.
  4. PrOntoQA: A synthetic dataset designed to test logical deduction and reasoning chains.

Key Insights

LLMs as Coders, Not Simulators

A primary finding of this research is that LLMs are significantly more effective at writing rules than they are at tracking state changes over long sequences. While models often suffer from the "lost in the middle" problem during step-by-step simulation, they excel at translating domain rules into functional code.

The Efficiency Gap

The economic and temporal advantages of ToS are substantial. Competing frameworks like Reasoning via Planning (RAP) or Language Agent Tree Search (LATS) can cost upwards of $16,000 in API fees to process a full dataset. In contrast, ToS solves the same problems for a few dollars because it only requires a handful of LLM calls to establish the code, after which the search runs locally and nearly instantaneously.

Soundness by Design

In traditional LLM-based planning, models frequently "hallucinate" invalid states or illegal moves. In ToS, once the successor generator is verified as correct, the search is mathematically guaranteed to produce only valid transitions. Additionally, classical search algorithms utilize a "Closed List" to track visited states, preventing the non-systematic backtracking and redundant explorations common in stochastic LLM search.

Results

ToS demonstrated superior performance across all metrics:

  • Accuracy: ToS achieved a perfect 100% accuracy across all four datasets. For context, the Tree of Thoughts approach achieved only 75% on the "24 Game."
  • Speed: To solve 1,362 instances of the "24 Game," ToS required between 1.9 and 6.8 seconds in total. Competing methods often require ~7 seconds for a single step of a single problem.
  • Minimal Invocations: ToS required an average of only 1.2 to 3.8 LLM calls per domain to generate functional code. This is a massive reduction compared to the hundreds of calls per problem instance required by other state-of-the-art frameworks.

Limitations and Future Directions

While ToS represents a significant leap in efficiency, the authors identify several areas for future work. Currently, the framework assumes a user can validate the generated code, suggesting that automated formal verification or property-based testing could be integrated to remove the human-in-the-loop requirement. Furthermore, while ToS uses uninformed search (BFS/DFS), extremely large state spaces may require the LLM to generate heuristic functions (e.g., for A* search) to guide the process. Finally, while highly effective for structured domains, fuzzy or open-ended tasks (like creative writing) may still benefit from LLM-in-the-loop approaches where rules are harder to codify.

Summary updated

BibTeX
@inproceedings{katz2024planning,
  author = {Michael Katz and Harsha Kokel and Kavitha Srinivas and Shirin Sohrabi},
  title = {{Planning with Language Models Through The Lens of Efficiency}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=lNCsyA5uS1},
}
Figure