These strategies compound core styles (Chapter 02) to increase reliability, factual grounding, or exploration depth. Use them selectively—each adds latency, cost, or complexity.
Run the same structured reasoning prompt K times with temperature > 0, collect answers + rationales, then select by majority, scoring, or aggregation.
# Pseudocode answers = [] for i in range(K): r = call_model(prompt, temperature=0.7) answers.append(parse_answer(r)) final = majority(answers)
Tradeoff: Linear cost; diminishing returns after ~7 samples.
Model emits alternating Thought / Action / Observation steps calling tools.
You are an agent. Use Thought / Action / Observation. Tools: search(query), calc(expr) Question: How many hours between local noon in Paris and 3pm in Tokyo next Friday? Thought: Need time difference. I'll search. Action: search("Paris Tokyo time difference") Observation: Paris UTC+1, Tokyo UTC+9. Thought: Tokyo 15:00 vs Paris ? 15 - (9-1) = 7. Final Answer: 7 hours.
Key: Enforce strict action schema; server must supply real observations.
Generalizes Chain‑of‑Thought to search. Branches = alternative partial solutions; controller keeps top B.
frontier = [root] for depth in range(D): pool = [] for state in frontier: children = propose_next(state, N) # model call scored = score(children) pool.extend(scored) frontier = select_top(pool, B) return best(frontier)
Heuristics: constraint satisfaction, numerical plausibility, partial reward models.
Retrieves external passages to ground generation and cite sources.
[SYSTEM] Cite only from provided sources as [S#]. If unknown, say you cannot answer. S1: ... S2: ... Question: ... Answer:
Common issue: Query drift → add query expansion or multi-vector retrieval.
Opposing roles enumerate strongest arguments, then a synthesis phase reconciles.
Topic: Adopt Rust for backend? Role A (Advocate): list 3 strongest benefits. Role B (Skeptic): list 3 strongest risks. Synthesis: Balanced recommendation citing each side.
Tip: Seed explicit divergent priors to avoid echoing.
Need | Strategy | Why |
---|---|---|
Reduce stochastic error | Self‑Consistency | Majority dampens outliers |
Need tools / APIs | ReAct | Structured tool invocation |
Branching reasoning | Tree‑of‑Thoughts | Explores alternatives |
Factual grounding | RAG | Inject external sources |
Surface bias | Debate | Contrasting priors |