Prompt Engineering Tutorial 0/120 lessons ~6 min read Lesson 33
Tree of Thoughts
Tree of Thoughts (ToT) generalises CoT into a search — at each step the model proposes multiple 'thoughts', evaluates them, and explores the most promising branch.
Course progress0%
Focus
6 guided sections
Practice signal
Examples included
Career prep
Foundation builder
Introduction
Tree of Thoughts (ToT) generalises CoT into a search — at each step the model proposes multiple 'thoughts', evaluates them, and explores the most promising branch. It tackles problems where CoT alone gets stuck.
Beginner analogy: Solving a maze by trying multiple paths and backtracking — not just charging forward.
Understanding the topic
Core concepts to understand:
- Generate K thoughts at each step.
- Evaluate each branch (model self-rates or external scorer).
- Expand the best branch; prune the rest.
- Used for: planning, code synthesis, complex puzzles.
- Much more expensive than CoT; reserve for hard problems.
Syntax reference
Visual workflow / architecture:
bash
Root/ | \A B C ← generate/| /| /|...evaluate each...▼pick best, expand again
Real-world use
Used in research-grade prompting (Google's ToT paper) and high-stakes agent planning. Tools like LangGraph implement ToT-style flows.
Best practices
- Use only when CoT and self-consistency aren't enough.
- Cap depth and branching to control cost.
- Score branches with a fast cheap model.
Hands-on exercise
Interview preparation — practice these questions:
- Q1. ToT vs CoT?
- Q2. How do you evaluate branches?
- Q3. Cost concerns?
- Q4. When is ToT overkill?
Ready to mark this lesson complete?Track your journey across the entire course.