Tree of Thoughts (ToT)
Explore how LLMs can deliberately solve problems by exploring and evaluating multiple lines of thought like branches on a tree.
Tree of Thoughts (ToT)
Tree of Thoughts (ToT) is a sophisticated prompting framework that elevates the reasoning process beyond a single Chain-of-Thought. Instead of following one linear path, ToT allows a Large Language Model to explore multiple different reasoning paths simultaneously, like branches on a tree. 🌳
It's a more deliberate and robust problem-solving method. The model can evaluate the progress along different branches, backtrack from dead ends, and pursue the most promising lines of thought.
How It Works

The ToT framework involves a multi-step process that mimics human problem-solving:
Decomposition: The problem is broken down into smaller steps or "thoughts."
Generation: For each step, the model generates multiple potential next steps or "thoughts," creating a tree-like structure.
Evaluation: A separate "evaluator" prompt or function assesses the quality and viability of each potential thought. It asks, "Is this reasoning path promising? Is it leading to a solution?"
Search & Pruning: The system uses search algorithms (like breadth-first or depth-first search) to navigate the tree of thoughts. It discards unpromising branches (pruning) and focuses its efforts on the most viable ones.
This process continues until a final solution is reached.
When to Use It
ToT is more complex and computationally expensive than simple CoT, so it's best reserved for highly complex problems where exploration is key.
Strategic Planning: Tasks that require planning several steps ahead, like solving a puzzle or planning a complex project.
Creative Writing: Generating stories with multiple branching plotlines and choosing the most compelling one.
Complex Problem-Solving: For problems where the solution path is not straightforward and requires exploring different hypotheses.
Example: The "24 Game"
A classic example is the "24 Game," where you must use the numbers 4, 5, 6, and 8 to make the number 24.
A simple CoT might try one path and fail. A ToT system would explore many paths at once:
Branch 1: Starts with
8 * 5 = 40
. Evaluates this path.40
is far from 24 and hard to reduce with4
and6
. This branch is ranked low.Branch 2: Starts with
6 * 4 = 24
. Evaluates this path. We've already hit 24, but we haven't used8
and5
. This branch is invalid.Branch 3: Starts with
8 - 6 = 2
. Evaluates this path.2
is a useful intermediate number.Sub-branch 3a:
2 * 5 = 10
. What can we do with10
and4
?10 + 4 = 14
. Not 24. Low rank.Sub-branch 3b:
4 - 2 = 2
. We now have2
and5
. No path to 24. Low rank.
Branch 4: Starts with
6 - 5 = 1
. Evaluates this path.1
is a very useful number.Sub-branch 4a:
8 + 1 = 9
. We have9
and4
. No path to 24.Sub-branch 4b:
4 - 1 = 3
. We now have3
and8
.3 * 8 = 24
. Solution found!
The ToT framework systematically explores and prunes these branches until it finds a valid solution, making it a much more powerful problem-solver.
Last updated