Last updated:
Tree of Thoughts: Deliberate Problem Solving with Large Language Models
Shunyu Yao et al.
In collections: Agentic approach Reasoning
Language models are increasingly being deployed for general problem solving across a wide range of tasks, but during inference they are still confined to token-level, left-to-right decision-making processes. This means they can fail on tasks that require exploration, strategic lookahead, or where initial decisions play a pivotal role. To overcome these challenges, we introduce a new reasoning framework for language models, Tree of Thoughts (ToT), which generalizes 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 solving a problem. ToT allows models to make deliberate decisions by considering multiple different reasoning paths and self-evaluating choices to decide on the next action, as well as looking ahead or backtracking when necessary to make global decisions. 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.
Strategies from the report:
Tree of Thoughts architecture (Tree of Thoughts): Instead of a single, linear path to an answer, the model branches its reasoning into a web of different variants (a tree). It generates several possible next steps from one point, creating alternative scenarios for solving the problem.
Built-in self-evaluation of states (Self-Evaluation): A key mechanism in which the artificial intelligence itself checks, at every step, whether its assumptions so far make sense. It rates the generated "thoughts" as promising, doubtful or wrong before spending resources on continuing them.
Graph search and backtracking (Search Algorithms & Backtracking): A technique of applying search algorithms known from computer science (breadth-first or depth-first). When the model runs into a contradiction or decides a branch is wrong, it stops that line of thought and "backtracks" to an earlier correct decision point to explore a different branch.
Good practices:
Defining the right scale of a "Thought": A reasoning step for the model should be big enough to be substantively meaningful for evaluating the final solution, but small enough that many precise variants of it can be generated.
Varying the voting methods (Flexible Evaluation Methods): The choice of self-evaluation method should depend on the task. For analytical tasks (math, programming) it is better to flatly reject contradictions; for creative ones, continuous evaluation (e.g. assigning points/stars to individual ideas).
Strategic lookahead (Lookahead): When a problem is complex, it is worth asking the model, before it makes a final decision about the path, to briefly simulate where a given path would ultimately lead it and what obstacles may arise.
What to avoid?
A linear approach to tasks with difficult planning (Left-to-Right Limits): Avoid forcing the model to solve games and complicated multi-step problems with traditional methods that generate the result straight ahead with no option to correct, so that a single mistake cascades and ruins everything else.
Blindly pushing on into hallucinations with no pauses for evaluation: What we avoid is relying on a continuous stream of generation in which we give the artificial intelligence no clear checkpoint for reflection: "does what I just wrote make sense?".
Overusing ToT on trivial tasks: The Tree of Thoughts framework uses a very large number of tokens and significantly lengthens the time needed to generate an answer. You shouldn't use complex branching instructions for trivial informational requests.
Support this project by buying me a coffee ;)