Tree of Thoughts: Deliberate Problem Solving with Large Language Models
Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023))
Subscriber deck — free during early access
15 cards
1 Introduction
- What limitation of language model inference does Tree of Thoughts address?Generation makes token-level decisions one at a time, left to right, so models fall short on tasks needing exploration, strategic lookahead, or where early decisions are pivotal; e.g. GPT-4 with chain-of-thought solved only 4% of hard Game of 24 problems.
- Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §1
- Which ideas from cognitive science and early AI inspire Tree of Thoughts?Dual-process theory: token-by-token generation resembles fast, associative “System 1” and could be complemented by deliberate “System 2” planning. And Newell, Shaw and Simon’s view of problem solving as search through a combinatorial problem space represented as a tree.
- Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §1
2 Background
- How do IO prompting, chain-of-thought and self-consistency fall short, according to Yao et al.?IO maps input to output directly; CoT samples one chain of intermediate thoughts left to right; CoT-SC samples several chains and takes the majority answer. None explores alternative steps within a chain, and majority voting only works when the output space is small.
- Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §2
3 Tree of Thoughts: Deliberate Problem Solving with LM
- What is a “thought” in Tree of Thoughts, and how big should it be?A coherent language sequence that is an intermediate step toward a solution: a few words (crosswords), one equation (Game of 24), or a paragraph-long plan (creative writing). It should be small enough to generate diverse, promising candidates, but big enough for the model to judge its promise.
- Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §3
- What four questions define an instance of Tree of Thoughts?How to decompose the process into thought steps; how to generate candidate thoughts from a state; how to evaluate states heuristically; and which search algorithm to use. A state \(s = [x, z_{1 \ldots i}]\) is the input plus the thoughts so far.
The model proposes next steps and judges each state; the search expands only promising ones (invented Game of 24 example) - Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §3
- What two ways of generating thoughts does Tree of Thoughts use, and when does each fit?Sampling i.i.d. thoughts from a CoT prompt, good when the thought space is rich (e.g. paragraphs) so samples differ; or proposing several thoughts at once with a “propose prompt”, good when the space is constrained (a word or an equation) so independent samples would duplicate.
- Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §3
- How does Tree of Thoughts evaluate states, and why is this new?The language model itself reasons about states, either valuing each (e.g. a score, or sure/maybe/impossible, via quick lookahead and commonsense such as “1 2 3 are too small to reach 24”) or voting for the most promising among several. Earlier search heuristics were either programmed (Deep Blue) or learned (AlphaGo).
- Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §3
- Which search algorithms does Tree of Thoughts use?Breadth-first search keeping the \(b\) best states per step (shallow trees: Game of 24, creative writing), and depth-first search exploring the most promising state first, pruning subtrees judged impossible and backtracking (crosswords). A* and MCTS are left for future work.
- Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §3
- Why do Yao et al. say Tree of Thoughts generalizes earlier prompting methods?IO, CoT, CoT-SC and self-refinement are special cases: trees of limited depth and breadth. The model, decomposition, generation, evaluation and search can each be varied independently, and no training is needed.
- Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §3
4.1 Game of 24
- How did Tree of Thoughts perform on Game of 24?With GPT-4 on 100 hard games: IO 7.3%, CoT 4.0%, CoT-SC (100 samples) 9.0%, best of 100 CoT samples 49%; ToT with breadth 1 reached 45% and with breadth 5, 74%.
- Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §4.1
- What did the Game of 24 error analysis reveal about left-to-right decoding?About 60% of CoT samples were already doomed after the first step (the first three words, e.g. “4 + 9”): committing early without exploring alternatives is the main failure.
- Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §4.1
4.2 Creative writing
- How was Tree of Thoughts applied to creative writing, and with what result?Task: write four paragraphs ending in four given random sentences. ToT generated 5 plans, let the model vote on the best, then wrote 5 passages from it and voted again. GPT-4 rated coherence 7.56 vs 6.93 for CoT and 6.19 for IO; humans preferred ToT over CoT 41 times to 21 out of 100.
- Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §4.2
4.3 Mini crosswords
- How did Tree of Thoughts solve 5×5 mini crosswords?Depth-first search filling one clue at a time, ordering candidate words by the model’s confidence and pruning a state if any remaining clue seemed impossible given its letters. Word-level success rose from under 16% (IO, CoT) to 60%, solving 4 of 20 games.
- Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §4.3
- What did the crossword ablations show?Backtracking matters: a greedy version without it got only 20% of words right. Pruning matters too but is imperfect: GPT-4 sometimes pruned correct states because of rare or obsolete words it didn’t recognize; outputting the best explored state instead of the heuristic choice solved 7 of 20.
- Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §4.3
6 Discussion
- What are Tree of Thoughts’ main limitations?Deliberate search is unnecessary for many tasks GPT-4 already handles; it costs many more model calls than sampling; and it uses an off-the-shelf model, though fine-tuning models for such high-level deliberation might improve problem solving further.
- Yao et al., 2023, Tree of Thoughts (Advances in Neural Information Processing Systems 36 (NeurIPS 2023)), §6
Source
- Shunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran, Thomas L. Griffiths, Yuan Cao and Karthik Narasimhan. 2023. Tree of Thoughts: Deliberate Problem Solving with Large Language Models. In Advances in Neural Information Processing Systems 36 (NeurIPS 2023). https://papers.nips.cc/paper_files/paper/2023/hash/271db9922b8d1f4dd7aaef84ed5ac703-Abstract-Conference.html