Appearance
Module 2.2: Strategic Exploration β Tree of Thoughts (ToT) & Self-Consistency β
Curriculum Alignment: [
docs/plan/02_phase2_engineering_of_reasoning.md](file:///Users/huychau/Documents/working/training/ai/docs/plan/02_phase2_engineering_of_reasoning.md)
Topic Scope: Graph/Tree Search over Language States, Backtracking, Self-Consistency Voting, Step-Back & Meta-Prompting
Level: Senior Architect / Advanced AI Engineering
1. Architectural Mental Model: From Linear Sequences to Graph Search β
Standard CoT is fundamentally a greedy depth-first search (DFS) with a branching factor of 1 and zero backtracking:
If the model makes a minor logical error at
The Tree of Thoughts (ToT) Framework β
Tree of Thoughts elevates the generation loop into an explicit search problem over a state space:
The 4 Pillars of ToT: β
- Thought Decomposition: Partitioning the problem into manageable cognitive units (e.g. 1 architectural decision per step).
- Thought Generator (
): Generating candidate thoughts for the current state . - State Evaluator (
): A separate heuristic or LLM-as-a-Judge scoring each candidate path (e.g. Sure,Maybe,Impossibleor scores from). - Search Algorithm: Orchestrating tree traversal via Breadth-First Search (BFS) or Depth-First Search (DFS) with backtracking.
2. 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).
TIP
Engineering Trade-off: Self-Consistency increases reliability on mathematical and logical proofs by
3. Abstraction Techniques: Step-Back & Meta-Prompting β
Step-Back Prompting β
Before answering a detailed or convoluted query, the system instructs the model to "take a step back" and formulate the underlying high-level principles or governing laws.
- Detailed Query:
"How do we handle 50,000 webhook events/sec in Django without database locking?" - Step-Back Question:
"What are the fundamental architectural patterns for high-throughput write buffering and backpressure in relational storage?"
Meta-Prompting (The Meta-Refiner) β
In complex systems, end users write underspecified, ambiguous prompts. A Meta-Prompting engine uses an architect LLM to analyze the user's intent, identify missing constraints, and generate an optimized, fully delimited system prompt for a downstream worker LLM.
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 ("Reasoning in Detail"): Strategic search, tree exploration, and state evaluation. |
| 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 ( |
| Step-Back Paper | Take a Step Back: Evoking Reasoning via Abstraction (Zheng et al., 2023) | Deriving high-level first principles to anchor complex, detail-dense queries. |
| Advanced Guides | Patronus AI: Advanced Prompt Engineering | Meta-prompting design, automated prompt generation, and evaluator LLMs. |
5. Senior Exercises β
Exercise 2.2: The Multi-Path Planner β
- Goal: Build the conceptual blueprint for your Multi-Path Planner deliverable.
- Problem: Design a software feature implementation (e.g. migrating a monolithic payment service to asynchronous event-driven billing).
- Requirements:
- Brainstorm 3 distinct architectural approaches.
- Implement an evaluation rubric (Latency, Fault Tolerance, Operational Complexity).
- Formulate a final synthesis justifying the chosen path.