Paper commentary
Tree of Thoughts: Deliberate Problem Solving with Large Language Models
- Problem Left-to-right token decoding commits to each step without exploring alternatives or looking ahead, which limits performance on tasks that need planning or search.
- Method Tree of Thoughts treats a problem as a search over a tree of intermediate thoughts, where the language model proposes candidate thoughts, scores partial states, and runs breadth-first or depth-first search over them.
- Results On Game of 24, ToT with breadth limit 5 reached a 74% success rate, against 4.0% for chain-of-thought prompting.

Table 2 : Game of 24 Results.
Original paper · CC BY 4.0 · Shunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran, Thomas L. Griffiths, Yuan Cao, Karthik Narasimhan · Tree of Thoughts: Deliberate Problem Solving with Large Language Models · Original paper figure · Extracted the figure area from page 6 of the original PDF.Why left-to-right decoding limits search
Current language models produce text one token at a time, moving from left to right, and each choice is settled before the next one is considered. The authors ask whether this mechanism can carry a model toward a general problem solver, and which alternative mechanisms would be needed if it cannot. They draw on dual-process accounts of human thinking, in which a fast associative mode is supplemented by a slower deliberate one, and they argue that token-level generation resembles the fast mode.
That suggests a planning layer that keeps several options open, judges where it stands, and looks ahead or backs up when a path fails.
Prompting baselines that ToT generalizes
Input-output prompting samples an output from the model conditioned on the input, optionally wrapped with task instructions or a few few-shot examples. Chain-of-thought prompting inserts intermediate thoughts between the input and the output, each conditioned on the earlier ones, so the whole chain is produced as one continuous sequence. Where one thought ends and the next begins is left unspecified in this setup, and no step is explored locally before the chain moves on.
Self-consistency with CoT samples several independent chains and returns the most frequent final answer. That majority vote only makes sense when the output space is small, such as multiple-choice answers, and the chains still do not branch inside a single reasoning path.
Building a tree of thoughts
ToT treats each problem as a search over a tree in which every node is a state made of the input and the thoughts produced so far. Building an instance requires four decisions: how to split the process into thoughts, how to generate candidate thoughts, how to evaluate states, and which search algorithm to run.
The size of a thought is a trade-off, since a thought must be small enough for sampled alternatives to differ and large enough for the model to judge how promising it is. The generator has two options: independent samples from a chain-of-thought prompt, which suits rich spaces such as paragraphs, or a single propose prompt that yields several thoughts in one context so they do not repeat, which suits constrained spaces such as single words or equations.
The state evaluator either values each state on its own, by a score or a class such as sure, maybe or impossible, or votes across the frontier and picks the most promising state. Because the language model does the evaluating, the heuristic is written in language rather than programmed or learned from data.
Breadth-first search keeps a fixed number of the most promising states at each step, and it is used where the tree is shallow and the first thoughts can be pruned to a small set. Depth-first search explores the best state first, prunes a subtree when its value falls below a threshold, and backtracks to the parent state. IO, CoT, CoT-SC and self-refinement can be seen as ToT with trees of limited depth and breadth, and no extra training is needed beyond a pre-trained language model.
Game of 24: where lookahead pays off
Game of 24 asks the model to combine four numbers with basic arithmetic operations to reach 24, so a single wrong early step ends the attempt. The test games are drawn from 4nums.com, which contains 1,362 games sorted by human solving time, and the subset indexed 901-1,000 is used for testing.
The IO baseline uses 5 in-context examples, and the CoT baseline adds three intermediate equations per example, each operating on two of the remaining numbers. CoT-SC takes the majority output from 100 CoT samples, and iterative refinement reflects on up to 10 earlier answers, using ground-truth feedback about equation correctness. In the ToT version the task is split into three equation steps, and a propose prompt generates candidate next steps from the remaining numbers.
A breadth-first search keeps the best 5 candidates per step, and the model labels each candidate as sure, maybe or impossible, with each thought sampled three times.
IO prompting reached a 7.3% success rate and CoT prompting 4.0%, while CoT-SC reached 9.0%. ToT with breadth 1 reached 45%, and breadth 5 reached 74%. Best-of-k oracle baselines do better than the single-sample ones but still fall short, at 33% for IO and 49% for CoT over the best 100 samples, and iterative refinement reached 27%.
CoT scales better than IO as more samples are drawn, but drawing more nodes in ToT, across breadths 1 to 5, gives higher success than the best-of-100 CoT samples. Around 60% of CoT samples already failed after the first step, which the authors attribute to the limits of direct left-to-right decoding.
Creative Writing: coherence from planning
Creative Writing gives the model four random sentences and asks for a passage of four paragraphs that end with those sentences in order. The average standard deviation across the five GPT-4 scores is around 0.56.
IO and CoT are both zero-shot, with 10 samples each per task, and the CoT prompt first writes a short plan that serves as the intermediate thought. The ToT version has depth 2 and breadth 1: it samples 5 plans and votes for one, then samples 5 passages from that plan and votes again.
Averaged over 100 tasks, GPT-4 scores were 7.56 for ToT, 6.93 for CoT and 6.19 for IO. Human judges preferred ToT over CoT in 41 of 100 pairs, preferred CoT in 21, and found 38 pairs similarly coherent. The authors acknowledge that the automatic score may be noisy, so the human comparison carries much of the argument for ToT over CoT.
Iterative refinement raised the IO score from 6.19 to 7.67, and the ToT score from 7.56 to 7.91. The authors read this as a third way to generate thoughts, in which new thoughts come from revising earlier ones instead of independent or sequential sampling.
Mini Crosswords: backtracking and pruning
The task fills a 5x5 grid of 25 letters from 5 horizontal and 5 vertical clues, and it is scored at the level of letters, words and whole games. The data come from GooBix, which contains 156 games, and 20 games with indices 1, 6, ..., 91, 96 are used for testing.
The IO prompt includes 5 example pairs, the CoT prompt also lists intermediate words, and each prompt is run for 10 samples. The ToT search is a depth-first search that keeps extending the most promising clue, and later thoughts may not overwrite filled letters, which caps the search at 10 intermediate steps. Candidate fills are proposed 5 times per state with confidence levels, and a state is pruned when some remaining clue is judged impossible to fill; the search stops after 100 steps.
IO and CoT both reach a word-level success rate below 16%, while ToT reaches 60% at the word level and solves 4 of the 20 games. Table 3 reports 78 at the letter level for ToT, against 38.7 for IO and 40.6 for CoT.
Using the oracle best DFS state instead of the heuristically chosen one raises ToT to 7 of 20 games. Removing the pruning lowers the table scores to 65.4 letter-level and 41.5 word-level, though that variant finds a correct solution for 4 of 20 games, while its output is chosen heuristically, and three of those games are ones the pruned version cannot solve within 100 steps.
Placing ToT among planning and self-reflection methods
Language models already carry enough commonsense to propose plans, and ToT extends such planning by keeping several feasible plans alive at each step. Unlike methods that train reward or policy models, ToT uses the language model itself to provide value estimates, and RAP, a concurrent method, uses a Monte Carlo tree search over a similar idea but on simpler tasks and without a modular search interface.
Self-eval guided decoding also searches a tree and lets the model evaluate leaves, but it represents thoughts as code, which the authors say makes creative writing hard to handle. Another approach expands a search tree with external paragraphs rather than the model's own thoughts and has no reflection or voting step.
The authors also relate ToT to A* search, where the heuristic at each node comes from the model's self-assessment, and to NeuroLogic A*esque decoding, which is limited to sentence generation.
Limits of the evidence
Search methods such as ToT need more resources, such as GPT-4 API cost, than sampling methods to improve task performance. The modular design lets users trade performance against cost, and the authors expect open-source models to lower these costs.
The main study covers three relatively simple tasks chosen to challenge GPT-4, and deliberate search may not be needed for tasks GPT-4 already handles well. The crossword pruning heuristic is imperfect, since the state evaluator sometimes rejects words in games it can still solve, so better pruning is needed. The Creative Writing ranking rests on an automatic score that the authors say may be noisy, alongside a human comparison.
Paper info
- Authors
- Shunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran, Thomas L. Griffiths, Yuan Cao, Karthik Narasimhan
- Venue
- arXiv · Preprint
- First published
- 2023-5-17
- Added
- 2026-10-20
- Updated
- 2023-12-3
- Version
- v2
- arXiv
- 2305.10601
- Category
- cs.CL · cs.AI · cs.LG
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Abstract
Language models are increasingly being deployed for general problem solving across a wide range of tasks, but are still confined to token-level, left-to-right decision-making processes during inference. This means they can fall short in tasks that require exploration, strategic lookahead, or where initial decisions play a pivotal role. To surmount these challenges, we introduce a new framework for language model inference, Tree of Thoughts (ToT), which generalizes over the popular Chain of Thought approach to prompting language models, and enables exploration over coherent units of text (thoughts) that serve as intermediate steps toward problem solving. ToT allows LMs to perform deliberate decision making by considering multiple different reasoning paths and self-evaluating choices to decide the next course of action, as well as looking ahead or backtracking when necessary to make global choices. Our experiments show that ToT significantly enhances language models' problem-solving abilities on three novel tasks requiring non-trivial planning or search: Game of 24, Creative Writing, and Mini Crosswords. For instance, in Game of 24, while GPT-4 with chain-of-thought prompting only solved 4% of tasks, our method achieved a success rate of 74%. Code repo with all prompts: https://github.com/princeton-nlp/tree-of-thought-llm.
Quote from the paper
Shunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran, Thomas L. Griffiths, Yuan Cao, Karthik Narasimhan (2023). Tree of Thoughts: Deliberate Problem Solving with Large Language Models. arXiv:2305.10601v2. https://arxiv.org/abs/2305.10601v2
BibTeX
@misc{yao2023tree,
title = {{Tree of Thoughts: Deliberate Problem Solving with Large Language Models}},
author = {Shunyu Yao and Dian Yu and Jeffrey Zhao and Izhak Shafran and Thomas L. Griffiths and Yuan Cao and Karthik Narasimhan},
year = {2023},
eprint = {2305.10601},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2305.10601v2}
}