Patterns
๐ŸŒณ

Tree-of-Thought(ToT)

Explores multiple reasoning paths through branching and backtracking

Complexity: highReasoning Techniques

๐ŸŽฏ 30-Second Overview

Pattern: Explore multiple reasoning paths through branching tree structure with evaluation and pruning

Why: Enables backtracking, lookahead, and exploration of alternatives for complex problem-solving

Key Insight: Generate K candidates โ†’ Evaluate โ†’ Prune weak paths โ†’ Expand promising ones โ†’ Repeat until solution

โšก Quick Implementation

1Define Tree:Set branching factor K & max depth
2Generate:Create K candidate thoughts per node
3Evaluate:Score each candidate (rubrics/verifier)
4Prune:Keep top candidates, discard weak paths
5Search:BFS/DFS/beam until solution found
Example: Problem โ†’ [Branch 1, Branch 2, Branch 3] โ†’ Evaluate โ†’ Prune โ†’ Expand best โ†’ Solution

๐Ÿ“‹ Do's & Don'ts

โœ…Use small branching factor (K=3-5) to control costs
โœ…Implement explicit evaluation criteria/rubrics
โœ…Cache and deduplicate equivalent states
โœ…Set budget limits (max tokens/time) with fallbacks
โœ…Use beam search for balanced exploration
โŒAllow unlimited branching (combinatorial explosion)
โŒSkip evaluation steps (leads to random exploration)
โŒUse for simple problems (overkill vs CoT)
โŒIgnore cycles/loops in reasoning paths
โŒOver-prune early promising paths

๐Ÿšฆ When to Use

Use When

  • โ€ข Complex problems with multiple solution paths
  • โ€ข Strategic planning requiring lookahead
  • โ€ข Creative tasks needing exploration
  • โ€ข Puzzles with critical early decisions
  • โ€ข When backtracking adds value

Avoid When

  • โ€ข Simple linear reasoning tasks
  • โ€ข Real-time/low-latency requirements
  • โ€ข Tight computational budgets
  • โ€ข Tasks without clear evaluation criteria
  • โ€ข When CoT already works well

๐Ÿ“Š Key Metrics

Solution Quality
Accuracy vs CoT baseline
Search Efficiency
Nodes explored per solution
Token Cost
Total tokens vs linear approaches
Path Diversity
Unique reasoning strategies explored
Evaluation Accuracy
Pruning quality (keep good, discard bad)
Budget Utilization
% of max depth/tokens used

๐Ÿ’ก Top Use Cases

Game of 24: Explore different operator combinations โ†’ evaluate validity โ†’ prune impossible paths
Strategic Planning: Generate scenario branches โ†’ assess outcomes โ†’ select optimal strategy
Creative Writing: Develop plot alternatives โ†’ evaluate narrative coherence โ†’ pursue best storylines
Math Puzzles: Try multiple solution approaches โ†’ verify correctness โ†’ backtrack if needed
Code Architecture: Explore design patterns โ†’ evaluate trade-offs โ†’ select best approach

References & Further Reading

Deepen your understanding with these curated resources

Contribute to this collection

Know a great resource? Submit a pull request to add it.

Contribute

Patterns

closed

Loading...

Built by Kortexya