Reasoning

Tree of Thoughts

Search over a tree of partial reasoning states with explicit lookahead, evaluation, and backtracking.

Problem

Chain-of-thought produces a single linear reasoning trace and never reconsiders. If the first decision is wrong, the model has no machinery to back up, compare that decision against alternatives, or prune dead-end branches. It cannot weigh several candidate moves against each other at any node, which is exactly what is needed on tasks where the best opening is not obvious. The team needs explicit search vocabulary — lookahead, evaluation, backtracking — layered on top of reasoning so the model can recover from wrong commitments.

Solution

Decompose the problem into thought steps. At each node, sample several candidate next thoughts. Evaluate each (model self-evaluation or programmatic check). Apply BFS/DFS/beam to explore the tree. Backtrack from dead ends. Return the best leaf.

When to use

  • Problems benefit from exploring alternatives rather than committing to one chain (puzzles, planning, creative writing).
  • Each thought step can be evaluated by the model or a programmatic check.
  • Compute budget allows BFS, DFS, or beam search over thought nodes.

Open the full interactive page

Diagram, neighbourhood map, code examples, related patterns and full provenance.

Related