Tree of Thoughts
Branching reasoning
The Problem: Some problems have many possible paths, and the first one you try might be wrong. How can AI explore multiple approaches and backtrack when needed?
The Solution: Think Like a Chess Player
Tree of Thoughts (ToT) lets the AI explore multiple reasoning branches, evaluate each one, and prune dead ends. Instead of committing to one path, it considers several options at each step, like a chess player thinking several moves ahead. It extends Chain-of-Thought into a tree structure, and while Self-Consistency picks the best final answer, ToT evaluates at every step.
Think of it like a chess player planning moves:
- 1. Generate options: "I could move the knight, bishop, or queen..."
- 2. Evaluate each: "Knight looks promising, queen seems risky..."
- 3. Explore deeper: "If knight, then opponent might... then I could..."
- 4. Backtrack if needed: "That path leads to checkmate against me, try another"
Where Is This Used?
- Puzzles: Sudoku, 24 game, logic puzzles
- Creative Writing: Exploring different plot directions
- Planning: Finding optimal paths through complex decisions
- Code Architecture: Evaluating different design approaches
Fun Fact: Tree of Thoughts increased success rate on the Game of 24 (making 24 from 4 numbers) from 4% with standard prompting to 74%! The ability to backtrack and try different paths is incredibly powerful.
Try It Yourself!
Use the interactive example below to see how Tree of Thoughts explores multiple branches and finds the best solution path.
Try it yourself
Interactive demo of this technique
Three friends (Ann, Bob, Vicky) take three places (1, 2, 3). Ann is not first. Bob is not next to Vicky. Who is in which place?
Ann — 2, Bob — 1, Vicky — 3
Step 1: All possible arrangements (6 options) 1-2-3: ABV, AVB, BAV, BVA, VAB, VBA
Step 2: Ann is not first (remove A in 1st place) ❌ ABV, ❌ AVB ✓ BAV, ✓ BVA, ✓ VAB, ✓ VBA Remaining: 4 options
Step 3: Bob is not next to Vicky BAV: B(1)-V(3) not adjacent ✓ BVA: B(1)-V(2) adjacent ❌ VAB: V(1)-B(3) not adjacent ✓ VBA: V(1)-B(2) adjacent ❌
Step 4: Remaining options
- Bob-Ann-Vicky (BAV)
- Vicky-Ann-Bob (VAB)
Answer: Two solutions! Both are valid.
Tree of Thoughts systematically explores all options. Without ToT, the model gave one answer and missed the second solution.
Create a free account to solve challenges
4 AI-verified challenges for this lesson
This lesson is part of a structured LLM course.
My Learning Path