Tree-of-Thought Exploration
Branching and evaluating thoughts.
From Chains to Trees
Tree-of-Thought (ToT, Yao et al., 2023) generalizes chain-of-thought from a single linear path to a search tree of partial solutions. Each node is a coherent intermediate thought; branches explore alternative continuations.
This lets the model deliberate: generate multiple next-steps, evaluate them, keep the promising ones, and backtrack from dead ends, mimicking systematic problem solving rather than committing to the first idea.
class ThoughtNode:
def __init__(self, state, parent=None):
self.state = state # partial solution / reasoning so far
self.parent = parent
self.children = []
self.value = None # evaluator scoreThe Four ToT Components
A ToT system has four design choices: thought decomposition (what is a step), the thought generator (how to propose next steps), the state evaluator (how to score partial solutions), and the search algorithm (BFS, DFS, or best-first).
Each is a separate prompt or policy. Designing ToT means specifying all four for your task.
tot = {
'decompose': step_definition, # e.g. one equation, one move
'generate': propose_thoughts, # sampling or proposal prompt
'evaluate': score_state, # value/vote prompt
'search': bfs_with_beam, # BFS | DFS | best-first
}All lessons in this course
- Chain-of-Thought Prompting
- Self-Consistency Sampling
- Tree-of-Thought Exploration
- When Reasoning Prompts Help