Stream of Search (SoS): Learning to Search in Language

Kanishk Gandhi, Denise H J Lee, Gabriel Grand, Muxin Liu, Winson Cheng, Archit Sharma, Noah Goodman

TL;DR

This paper introduces "Stream of Search" (SoS), a novel framework that teaches language models to perform complex search and planning by representing the entire search process, including mistakes and backtracking, as a flattened string. This approach significantly improves problem-solving capabilities, enabling LMs to tackle tasks previously out of reach and even discover new strategies.

What Problem Does This Paper Address?

Current language models (LMs) are trained primarily on successful outcomes, meaning they rarely see or learn from mistakes, exploration, or backtracking. This leads to a critical weakness: they struggle with planning and complex decision-making because they tend to "snowball" errors and lack the ability to look ahead and recover from missteps. This is particularly problematic for tasks requiring multi-step reasoning, where a single error can derail the entire process. The authors aim to bridge this gap by teaching LMs the process of search, not just the final answer.

Methods

The core innovation is the Stream of Search (SoS) framework. Instead of just learning the optimal path to a solution, SoS trains LMs on a serialized representation of the entire search process. This "stream" includes:

  • Current State: The current configuration of the problem.
  • Operations: The actions taken.
  • Exploration: How new states are generated.
  • Backtracking: How the model recovers from dead ends.
  • Goal Check: Verifying if the target is reached.

This unified language for search is then used to pretrain transformer-based LMs. To further enhance their capabilities, the authors employ two policy improvement techniques:

  • Self-Taught Reasoner (STaR): An expert iteration method where the model is finetuned on correct trajectories.
  • Advantage-Induced Policy Alignment (APA): An actor-critic reinforcement learning approach that uses a value network to guide policy improvement, aiming for both correctness and efficiency.

Datasets

The primary dataset used is a newly constructed Stream of Search (SoS) dataset for the game of Countdown. This dataset consists of approximately 500,000 search trajectories generated by diverse, and often suboptimal, symbolic search strategies (BFS and DFS with different heuristics). This contrasts with datasets that only provide optimal paths. For evaluation, the authors also use an Optimal Paths dataset containing only the correct solution trajectories.

Key Insights and Ideas

  • Learning from Mistakes is Crucial: Exposing LMs to the "messy" process of search, including errors and backtracking, is more effective for developing planning and reasoning skills than training solely on optimal solutions.
  • Unified Language for Search: Representing search components (exploration, backtracking, goal checks) as a unified language allows LMs to generalize across different search strategies.
  • Self-Improvement Beyond Training Data: Policy improvement methods (STaR and APA) enable SoS models to go beyond the strategies seen during pre-training, potentially discovering novel heuristics and more efficient search methods.
  • Internal World Model: SoS models learn an internal "world model" for search, simulating state transitions themselves, unlike traditional symbolic search that relies on explicit environment models.

Key Results

  • Pre-training Boost: SoS pre-training increased search accuracy by 25% compared to models trained only on optimal trajectories.
  • Solving Unseen Problems: Finetuned SoS models (with STaR and APA) solved 36% of problems that were previously unsolved by any symbolic search strategy.
  • Efficiency Gains: Policy improvement methods reduced the average number of states explored to reach a correct solution, indicating more efficient search.
  • Reduced Errors: APA significantly suppressed arithmetic errors, while both methods reduced exploration anomalies.
  • Emergent Strategies: Analysis of state visitation suggests that improved SoS models employ diverse search strategies, not strictly adhering to any single symbolic strategy from the training data.

Limitations and Future Work

  • Domain Specificity: The current work is demonstrated on the Countdown game. Future work could explore transferring SoS to more challenging, real-world tasks.
  • Implicit vs. Explicit Evaluation: While the paper focuses on representing search operations explicitly in language, state evaluation is currently implicit. Future work could explore explicitly representing state evaluations and other formalizable operations like subgoal setting and self-evaluation.
  • Combining Approaches: The authors suggest that SoS could be combined with other methods, such as Tree of Thoughts, to provide initial training data.
  • Search Strategy Transfer: An important open question is how well search abilities transfer between different domains and between formal and informal domains.

Summary updated

BibTeX
@inproceedings{gandhi2024stream,
  author = {Kanishk Gandhi and Denise H J Lee and Gabriel Grand and Muxin Liu and Winson Cheng and Archit Sharma and Noah Goodman},
  title = {{Stream of Search (SoS): Learning to Search in Language}},
  booktitle = {COLM},
  year = {2024},
  url = {https://openreview.net/forum?id=2cop2jmQVL},
}
Figure