TL;DR
Standard prompting makes a language model write its answer one token at a time, left to right, with no way to back up. Tree of Thoughts (ToT) treats the model's intermediate steps as nodes in a tree. The model proposes several next steps, judges them itself, and a search procedure decides which to expand or drop. On three hard tasks with GPT-4, this beats chain-of-thought prompting by a wide margin.
Where you'll see it: problem-solving prompts that need planning or backtracking, such as arithmetic puzzles, word games and constrained writing, and as a template for building search on top of a language model without extra training.
The problem
Chain-of-thought (CoT) prompting gets a model to write out intermediate reasoning before the answer. It still samples one chain. If an early step is wrong, nothing in the procedure notices or revisits it. Self-consistency runs several chains and takes the most common answer, but each chain still has no local exploration of different next steps. The vote also works only when the answers can be compared directly, such as multiple choice.
The paper argues that these limits come from the decoding mechanism itself. A language model makes token-level choices in a single left-to-right pass, the way a fast, automatic process would. Hard problems often need a slower process that tries options, compares them and backs up. The authors take the framing from Newell, Shaw and Simon's work from the 1950s, which treated problem solving as search through a combinatorial problem space represented as a tree.
Key idea
ToT makes a problem a search over a tree. Each node is a state: the original input together with the partial solution written so far. Each edge adds one thought, a coherent piece of text that is a meaningful intermediate step. The authors name four design decisions for any ToT instance.
- Decomposition. How to split the solution into thought steps.
- Generation. How to produce candidate next thoughts from a state.
- Evaluation. How to score states, using the language model as the heuristic.
- Search. Which algorithm chooses which states to expand.
The framework covers existing methods as special cases. IO prompting, CoT, CoT with self-consistency and iterative refinement are all trees of limited depth or breadth. The authors also list modularity as a benefit: the base model, the decomposition, the generator, the evaluator and the search can each be changed on its own. No extra training is needed, because a pretrained model supplies all of the parts.
The method
Thought decomposition
The thought size depends on the task. In Game of 24 a thought is one intermediate equation. In Creative Writing it is a short plan for a paragraph. In crosswords it is a candidate word for a clue. The authors' guideline is that a thought should be small enough for the model to produce diverse, promising candidates, and large enough for the model to judge whether it is promising. A single token is too small to judge. A whole book is too big to be coherent.
Thought generation
Two strategies produce k candidates for the next step.
- Sample. Draw k independent thoughts from a CoT-style prompt. This suits rich thought spaces, such as paragraphs, where independent samples give diversity.
- Propose. Ask for k thoughts in one prompt, so the model sees its earlier proposals and avoids repeats. This suits constrained spaces, such as single equations or words.
State evaluation
The evaluator gives the search a heuristic. The authors use the language model to do this, instead of a programmed rule or a learned value model. Two forms are used.
- Value. Score each state on its own. The prompt asks the model to reason about the state and output a number, for example 1 to 10, or a label such as sure, maybe or impossible. In Game of 24 the prompt checks whether the remaining numbers can still reach 24.
- Vote. Show the model several states together and ask which is most promising. This suits tasks where a single state is hard to value directly, such as the coherence of a passage.
Each judgement can be sampled several times and aggregated, trading compute for a more robust score.
Search
The paper uses two simple algorithms and leaves more advanced ones, such as A* and Monte Carlo tree search, for future work.
- Breadth-first search (BFS). Keep the b most promising states at each depth. Used for Game of 24 and Creative Writing, which have depth at most 3, and where the first thoughts can be pruned to a small set.
- Depth-first search (DFS). Expand the most promising state first. Stop when a solution is reached, or when the evaluator scores a state at or below a threshold, prune its subtree, and backtrack to the parent. Used for crosswords.
The BFS variant is close to Beam Search. The paper's contribution is the language-model evaluator and the thought design, not the search procedure.
Results
All results are the paper's and use GPT-4.
Game of 24. The task is to combine four numbers with arithmetic to reach 24. The test set is 100 hard games, indexed 901 to 1,000 of a set sorted by human solving time. Success rates are IO prompting 7.3 percent, CoT 4.0 percent and CoT self-consistency 9.0 percent. ToT with breadth 1 reaches 45 percent, and with breadth 5 reaches 74 percent. Figure 3 shows that about 60 percent of CoT samples already fail after their first step, a sign that left-to-right decoding commits too early.
Creative Writing. The input is four random sentences, and the output is a four-paragraph passage that ends with them in order. Scores are GPT-4 ratings from 1 to 10, averaged over 100 tasks: ToT 7.56, CoT 6.93, IO 6.19. Human raters preferred ToT over CoT in 41 of 100 pairs, CoT over ToT in 21, and called 38 similarly coherent. The paper calls this an automatic metric that may be noisy, and it reports the human result alongside it.
Mini crosswords. The 5 by 5 puzzles are harder, since a wrong word can block later clues. Word-level success is under 16 percent for IO and CoT and 60 percent for ToT with depth-first search. ToT solves 4 of 20 games, and 7 of 20 when the output is taken from the oracle best state, which the paper reports as a sign that its output heuristic could be improved.
Cost. ToT is much more expensive. On Game of 24, one ToT case costs about 0.74 dollars and uses about 5.5k completion tokens, against about 0.13 dollars for IO best-of-100 and about 0.47 dollars for CoT best-of-100. ToT's success is 74 percent, against 33 and 49 percent for those baselines (Table 7). On Creative Writing, ToT uses 4k completion tokens against 0.9k for IO and CoT, at about 0.32 dollars per case against 0.06 and 0.07. The paper says ToT could need 5 to 100 times more generated tokens than CoT, depending on prompts and search.
Why it mattered
The paper's claims are narrow. It shows that deliberate search with a language model's own thoughts and judgements beats single-chain and sampled-chain prompting on three tasks that were hard for GPT-4 at the time. It also shows that ToT is a general framing that contains the earlier methods. The authors list their limitations. Deliberate search might not be necessary for many tasks that GPT-4 already handles well, and the cost is high. They note that the beam size, the number of votes and the choice of model give a tradeoff between performance and cost.
Reading guide
Read the paper in this order. Each prerequisite is linked where it first matters.
- Section 1, Introduction. In-Context Learning for the few-shot prompting that every baseline uses. Tree Search for the classical search view the authors draw from Newell, Shaw and Simon.
- Section 2, Background. Chain-of-Thought Prompting for CoT and the self-consistency variant. Read the definitions of IO and CoT here, since the rest of the paper compares against them.
- Section 3, Tree of Thoughts. Tree Search for states, expansion and pruning. Value Function for the state evaluator as a heuristic. Beam Search for the BFS variant, which keeps the b best states at each step.
- Section 4, Experiments. Beam Search again for the Game of 24 setup, and Tree Search for the depth-first search used in crosswords.
- Section 5, Related work. Monte Carlo Tree Search for the classical search methods the paper relates to, which it leaves for future work when used as the search algorithm (Section 3).
- Section 6, Discussion and cost. No new prerequisites. Appendix B.3 is the source for the cost comparison.
Check yourself
QuestionIn your own words, what are the four decisions that define a Tree of Thoughts method, and which of them does the language model make a heuristic choice about?Show answer
The four decisions are how to decompose the solution into thoughts, how to generate candidate next thoughts, how to evaluate states, and which search algorithm to run. The evaluator is the part where the model acts as the heuristic: it reasons about a state and returns a value, or votes across states. The search algorithm is then a standard procedure, such as BFS or DFS, that uses those scores.
QuestionIn Game of 24 the search keeps b = 5 states at each BFS step and samples each thought's value 3 times. Suppose, for illustration, the propose prompt returns 8 candidate thoughts per kept state. How many value calls does one step make, and why sample each value several times?Show answer
With 5 kept states and 8 candidates each there are 40 candidates, and 3 value samples per candidate gives 120 calls (the count of 8 is illustrative, not from the paper). Prompting the model several times and aggregating is the paper's way to get a more robust heuristic, at the price of more compute.
QuestionToT beat CoT on Game of 24 with success 74 percent against 4.0 percent for CoT, yet best-of-100 CoT reached 49 percent in the cost table. Why do the two numbers disagree, and which comparison is fair?Show answer
The two numbers measure different things. The 4.0 percent is the average over single CoT samples. The 49 percent in Table 7 is an oracle best-of-100 rate, where a game counts as solved if any of 100 independent CoT samples is a valid answer. That oracle needs the success check, which a deployed system does not have. The paper's fair cost comparison is Table 7, where ToT's 74 percent is set against best-of-100 CoT at about 0.47 dollars per case. Even then, ToT is more expensive per case, and the paper says so.
QuestionWhy does a depth-first search with pruning help on mini crosswords, where a wrong word blocks later clues, but would be a poor fit for a shallow task like Creative Writing?Show answer
In crosswords the tree is deep, up to about 10 intermediate steps, and a filled word constrains the clues that follow. DFS commits to the most promising word, finds out quickly that some clue is impossible, prunes that subtree and backtracks, which is the behavior the task needs. Creative Writing has depth 2 and a single kept choice per step: the model generates several plans and votes for one, then does the same for passages. That is a short, fixed-depth search with nothing to backtrack to, so depth-first search gains little there.
Sources
- Yao, S. et al. (2023). Tree of Thoughts: Deliberate Problem Solving with Large Language Models. https://arxiv.org/abs/2305.10601
- Wei, J. et al. (2022). Chain-of-Thought Prompting Elicits Reasoning in Large Language Models. https://arxiv.org/abs/2201.11903