Appearance
Module 2.2: Strategic Exploration β
Curriculum Alignment:
docs/plan/02_phase2_engineering_of_reasoning.md
Topic Scope: Tree of Thoughts (ToT), Decision Trees & Backtracking, Self-Consistency Voting, LLM-as-a-Judge
Level: Advanced AI Engineering / Architecture
1. Why Linear Sequences Fail: The Need for Graph Search β
Standard Chain-of-Thought is fundamentally a greedy search with a branching factor of 1 and zero backtracking:
If the model makes a single calculation or assumption error at step
2. The Tree of Thoughts (ToT) Framework β
Tree of Thoughts (ToT) elevates language model inference into a deliberate search algorithm over a state space:
The 4 Pillars of ToT: β
- Thought Decomposition: Partitioning the complex problem into discrete, evaluable reasoning units (e.g. one design decision or logical constraint per node).
- Thought Generator (
): Emitting distinct candidate thoughts for the current state . - State Evaluator (
): A separate heuristic or evaluator LLM scoring the viability of each path (e.g. Sure,Maybe,Impossibleor scores from). - Search Algorithm: Orchestrating tree traversal via Breadth-First Search (BFS) or Depth-First Search (DFS) with explicit backtracking when a node evaluates poorly.
3. Self-Consistency: Stochastic Ensembling β
When solving problems with a single ground truth, greedy decoding (
Self-Consistency replaces greedy decoding with ensemble sampling:
- Sample
independent reasoning paths using a moderate temperature ( ). - Extract the final answer from each reasoning path.
- Compute the majority vote (or use an LLM judge to reconcile discrepancies).
Majority Vote vs. LLM-as-a-Judge β
- Majority Vote: Appropriate for deterministic, discrete outputs (integers, exact dates, predefined category strings).
- LLM-as-a-Judge: Prompts an independent evaluator model to review divergent reasoning chains, weigh trade-offs, and arbitrate which logical justification is soundest.
TIP
Engineering Trade-off: Self-Consistency increases reliability on mathematical and logical proofs by
Conceptual Mindmap: Strategic Exploration β
4. Curated Reading & Canonical References β
| Resource | Canonical Reference & Link | Specific Focus Areas |
|---|---|---|
| Primary Curriculum Book | AI Agents and Applications (Google Drive) | Chapter 2, Section 2.5 (p. 74): "Beyond Chain of Thought: Tree of Thought" β overcoming token-by-token greedy forward generation through state evaluation and multi-path branching. |
| Foundational ToT Paper | Tree of Thoughts: Deliberate Problem Solving (Yao et al., 2023) | Search heuristics ( |
| Self-Consistency Paper | Self-Consistency Improves Chain of Thought (Wang et al., 2022) | Majority voting consensus over stochastic sampling trajectories ( |
5. Active Recall (Module 2.2 Flashcards) β
Strategic SearchClick or press Space to flip βΊ
How does Tree of Thoughts (ToT) solve the 'compounding hallucination' problem of standard CoT?
Strategic Search β’ AnswerClick to flip back β»
Standard CoT uses greedy search with branching factor 1; if a mistake is made at step 1, every subsequent token reinforces the error. ToT explicitly generates multiple candidate thoughts per state, evaluates their viability with an evaluator model, and backtracks when a path is deemed unviable.
π‘ Architect Takeaway: ToT transforms generation from linear prediction into a search problem over a state tree.
Consensus MechanicsClick or press Space to flip βΊ
Why does Self-Consistency sample at temperature T=0.7 instead of greedy T=0.0?
Consensus Mechanics β’ AnswerClick to flip back β»
At T=0.0, the model is completely deterministic and produces identical reasoning paths every time (diversity = 0). Sampling at T=0.6-0.8 generates diverse, independent reasoning chains; taking a majority vote across diverse correct paths filters out idiosyncratic stochastic errors.
π‘ Architect Takeaway: Self-Consistency leverages diversity to find consensus on high-probability truths.
6. Hands-on Engineering Exercises β
Exercise 2.2: The Multi-Path Planner Drill β
- Goal: Build the conceptual blueprint for your Multi-Path Planner deliverable.
- Problem: Design a software feature implementation (e.g. designing a high-reliability distributed idempotency layer or job scheduling engine).
- Requirements:
- Brainstorm 3 distinct implementation approaches using Tree of Thoughts.
- Implement an evaluation rubric (Latency, Fault Tolerance, Complexity) scored by an evaluator LLM.
- Formulate a final synthesis justifying the chosen path.