Home Knowledge Base Tree of Thought (ToT)

Tree of Thought (ToT)

What is Tree of Thought? Tree of Thought extends Chain-of-Thought by exploring multiple reasoning paths in parallel, evaluating them, and searching for the best solution. Think of it like playing chess: looking ahead, evaluating positions, and backtracking from bad moves.

ToT vs CoT

Chain-of-Thought (Linear)

Problem ---> Step 1 ---> Step 2 ---> Step 3 ---> Answer

Single path, no backtracking.

Tree of Thought (Branching)

Problem
    Approach A
        Step A1 ---> Evaluate: promising
            Step A1a ---> Dead end, backtrack
            Step A1b ---> Solution found!
        Step A2 ---> Evaluate: unpromising, prune
    Approach B
        Step B1 ---> Still exploring...

Core Components

1. Thought Generation Generate multiple candidate thoughts at each step:

def generate_thoughts(state, n_candidates=3):
    prompt = f"Given current state: {state}. Generate {n_candidates} possible next steps."
    return llm.generate(prompt, n=n_candidates)

2. Thought Evaluation Score each thought for progress toward solution:

def evaluate_thought(state, thought):
    prompt = f"State: {state}. Proposed step: {thought}. Rate progress (1-10):"
    score = llm.generate(prompt)
    return float(score)

3. Search Algorithm Explore the tree systematically:

AlgorithmDescription
BFSExplore all thoughts at each level before going deeper
DFSGo deep first, backtrack on dead ends
Beam SearchKeep top-k most promising branches

Use Cases

Problem TypeWhy ToT Helps
Creative writingExplore different narrative directions
Game playingLook ahead, evaluate positions
Puzzle solvingTry multiple approaches, backtrack
PlanningEvaluate plan feasibility before committing

Performance Considerations

ToT is powerful for complex reasoning but should be reserved for problems where simpler methods fail.

tree of thoughtsearchplanning

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.