Before you use the demo in the newer notebook, say what you expect to change.
Foundation reference
Tree Search for Language-Model Reasoning
Search can solve problems that a single left-to-right pass misses: on the Game of 24, GPT-4 with chain-of-thought prompting solved 4% of problems and with Tree of Thoughts 74% (Yao et al., 2023).
Study guide
Where to start
In the UCT rule, why does the exploration term shrink as an action is tried more often, and what happens if c is set too low or too high?
How to study this pagePredict · Check · Generalize · Continue
Compare what the notebook demo shows with the key equation here and with the papers cited below.
Identify the part of the idea that survives a change of notation or model, so you can recognize it in another paper or system.
The newer notebook covers the same concept and has an interactive demo.
Why It Matters for Modern Models
- Search can solve problems that a single left-to-right pass misses: on the Game of 24, GPT-4 with chain-of-thought prompting solved 4% of problems and with Tree of Thoughts 74% (Yao et al., 2023).
- LATS reached 92.7% pass@1 on the HumanEval programming benchmark with GPT-4 by combining tree search with the model's own value estimates and reflections (Zhou et al., 2024).
- Search spends extra computation at inference time, and it is only as good as the scores that guide it. MCTS itself comes from game playing and planning, where its behavior is well studied (Browne et al., 2012).
Questions to Think About
- When the same language model both proposes steps and scores them, which mistakes can search correct, and which will it repeat?
- For a fixed compute budget, when is it better to search a tree than to sample many independent solutions and take a majority vote?
Interactive Demo
The interactive demo for this concept is in the newer notebook.
Core Math
If you prefer intuition first, try the demo in the newer notebook, then come back for the math.
Instead of writing one chain of reasoning from left to right, tree search treats partial solutions as nodes of a tree. A node is the problem plus the steps written so far, an action is a next step proposed by the language model, and a value estimate says how promising a node is.
Tree of Thoughts has the model propose several candidate next steps and rate the resulting states, and explores the tree breadth-first or depth-first, backtracking from dead ends (Yao et al., 2023).
Monte Carlo tree search (MCTS) repeats four phases: select a path down the tree, expand a leaf with new candidate steps, evaluate the new node (by a rollout, a learned value or a verifier), and pass that value back up to every node on the path. The UCT rule selects the action with the best balance between estimated value and uncertainty (Kocsis & Szepesvári, 2006):
where is the average value found after taking in , counts visits, and sets how much to explore. LATS applies MCTS to language agents, using the model to propose actions, score states and reflect on failed attempts (Zhou et al., 2024).