4.4.8 · D4Alignment, Prompting & RAG

Exercises — Self-consistency and tree-of-thought

2,879 words13 min readBack to topic

Prerequisites you may lean on: Chain-of-Thought Prompting, Monte Carlo Estimation, Ensemble Methods and Majority Voting, Temperature and Sampling in LLMs, Beam Search and BFS/DFS, Retrieval-Augmented Generation (RAG).

Throughout, we use these already-defined symbols from the parent note:

  • = number of independently sampled reasoning chains.
  • = probability a single chain reaches the correct final answer.
  • = the indicator: it equals when the statement inside is true, otherwise. (Think of it as a light switch that turns on only for a match.)
  • = " choose " = number of ways to pick which of the chains are the correct ones.

Level 1 — Recognition

L1.1

State, in one sentence each, what self-consistency (SC) changes about chain-of-thought, and whether it changes the prompt or the decoding.

Recall Solution

SC keeps the same chain-of-thought prompt but changes the decoding: instead of taking one chain, it samples chains at temperature and returns the majority-vote final answer. It is a decoding strategy, not a new prompt.

L1.2

Fill the blanks (cloze practice).

SC combines chains by majority vote, requires temperature greater than 0, and its cost scales as ==== the cost of one chain.

ToT combines partial thoughts by search + evaluation and its unique extra ability over CoT/SC is backtracking.

Recall Solution

Given inline above. Key checks: SC = majority vote, temp , cost . ToT = search/evaluation, and its distinctive power is backtracking (abandoning a dead branch).

L1.3

Match each method to its structure: CoT, SC, ToTbranching tree, one linear chain, N linear chains.

Recall Solution

CoT ↔ one linear chain. SC ↔ linear chains. ToT ↔ branching tree.


Level 2 — Application

L2.1

A single CoT chain is correct with probability . You sample chains and take the majority. Compute .

Recall Solution

Using the majority threshold : majority of 3 means at least 2 chains correct, i.e. . , . Accuracy rose from voting alone.

L2.2

Same but now . Confirm the parent note's figure of .

Recall Solution

Using the majority threshold : majority of 5 means at least 3 correct, . .

Sum . ✓

L2.3

A ToT run has depth , branching thoughts generated per state, and keeps beam width states per level. Using the parent's estimate, how many generate calls and how many evaluate calls does it make? Compare the total to an SC run with .

Recall Solution

Why an evaluate step costs a full call. The state evaluator is itself an LLM prompt: you feed the model the partial reasoning and ask it to score the state ("sure / maybe / impossible" or a number). That is a separate API round-trip with its own tokens, so we count it as one LLM call, on par with a generate call. (If a cheap heuristic evaluator were used instead of the LLM, evaluate calls would be nearly free — but the parent's estimate assumes an LLM evaluator, which is the usual ToT setup.) Parent estimate: generate calls and evaluate calls . Total LLM calls. SC with makes calls. So ToT here is roughly the SC cost — exactly the "" regime the parent warns about. On the "". This is an upper-bound-flavoured order estimate: it holds when every kept state generates a full children at each of levels and every child is evaluated. Real runs are usually cheaper — pruning kills branches early (fewer than survivors at some levels), and early solutions can terminate the search before depth . So read as "roughly this many, and rarely more," not an exact count.


Level 3 — Analysis

L3.1

Explain, with the Condorcet logic, why raising helps only when , and what happens to majority accuracy when . Read the figure carefully before answering.

Figure — Self-consistency and tree-of-thought
Recall Solution

Reading the figure. The horizontal axis is (number of chains, odd values), the vertical axis is . There are three curves, each for a fixed single-chain accuracy :

  • the red solid curve is (the case ),
  • the black dashed curve is (the case ),
  • the black dotted curve is (the borderline).

Now the logic:

  • When (red solid, upper curve), each chain is more often right than wrong, so aggregating more of them pushes the majority toward the correct answer: the curve rises toward 1.
  • When (black dashed, lower curve), each chain is more often wrong, so the majority increasingly agrees on a wrong answer: the curve falls toward 0.
  • At exactly (black dotted, flat near the middle) voting adds nothing — it's a coin flip regardless of .

So SC is an accuracy amplifier, not a fixer: it magnifies whatever tendency the single chain already has. You need a base learner that beats chance.

L3.2

Show that SC is a Monte-Carlo estimate of , and explain why sampling with temperature is what draws .

Recall Solution

The target is the marginal over hidden reasoning : We cannot enumerate all , so we draw samples ; each deterministically yields answer . The Monte-Carlo estimate of the marginal is the sample frequency and is exactly the majority vote. Why temperature recovers the model's distribution. At each step the model produces a raw score (logit) for every candidate token . Temperature rescales these before converting to probabilities:

  • At this is the model's native next-token distribution — sampling from it draws genuine samples .
  • As the largest logit dominates the ratio, so collapses onto the single argmax token: decoding becomes deterministic, every chain is identical, and you have one point, not a sample.
  • Values like keep the ordering but soften it enough to draw diverse reasoning paths — which is exactly the diversity the vote needs.

So "temperature " is precisely the knob that makes decoding a draw from a distribution rather than a fixed choice.

L3.3

You run SC with . The four extracted answers are . Give and . Then explain why (an even number) is a slightly awkward choice. (Recall: are estimators — quantities read off our finite sample, per the definition at the top.)

Recall Solution

Counts: appears times, once. The estimator (the sample mode) is , with (our sample estimate of ). Even risks ties (e.g. ), which have no unique majority and force an arbitrary tie-break. Odd guarantees a strict winner between two options, so odd is the safer default.


Level 4 — Synthesis

L4.1

You have three candidate systems for a math-word-problem benchmark: plain CoT, SC (), and ToT (). For each, state (a) approximate LLM-call cost, (b) whether it can backtrack, and (c) the one task property that most favours it.

Recall Solution

Why ToT's cost doubles the generate count. As in L2.3, ToT with an LLM evaluator makes one generate call and one evaluate call per candidate state, and each evaluate is a full API round-trip — so we multiply the generate estimate by . (With a free heuristic evaluator the factor would drop toward .) The counts below are the same order-estimate "" as in L2.3: they assume full branching with no early termination and so are near-upper-bounds; real pruning makes them cheaper.

System (a) Cost (calls) (b) Backtrack? (c) Favoured when…
CoT No task is easy / budget is tiny
SC No single-chain accuracy already ; want cheap lift
ToT Yes task has dead-ends needing prune/undo (puzzles, planning)

Cost of ToT here is calls vs SC's — the "" regime. Choose ToT only when the problem genuinely needs search, not just voting.

L4.2

Design a hybrid: at each ToT leaf you run self-consistency on the final step. Sketch why this is sensible, and estimate the cost if ToT reaches leaves and each does SC with votes.

Recall Solution

Sensible because: ToT's search finds promising complete reasoning skeletons (it prunes dead-ends), but the final numeric answer at a leaf can still be noisy. Running SC over the last step at each surviving leaf denoises that final answer via majority vote — search for the structure, vote for the answer. Cost: ToT search cost (generate + evaluate, same order-estimate caveat as above) plus final-answer samples. So total calls. Concretely with : calls.

L4.3

A colleague proposes averaging the raw token probabilities of the chains and picking the highest-probability answer string, calling it "self-consistency." Explain what's wrong and what SC actually aggregates.

Recall Solution

SC does not average token/confidence probabilities. It marginalizes over reasoning paths by voting over discrete final answers: two chains with completely different reasoning but the same answer each contribute one vote. Averaging token probabilities instead (a) mixes surface form with answer, and (b) lets one over-confident chain dominate — the opposite of the "wisdom of many independent noisy sensors" that makes SC robust. The correct aggregation is .


Level 5 — Mastery

L5.1

Prove that for majority voting with odd and independent chains of accuracy , the majority accuracy satisfies whenever for , by direct comparison. (Do it concretely for , then state the general condition.)

Recall Solution

For , threshold : . At : . ✓ General: . Factor it: . For : , , → product of three positive factors . Hence exactly when . This is the Condorcet result made concrete.

L5.2

Extend the Game-of-24 reasoning: given numbers , find one valid expression reaching , and explain which ToT step (generate / evaluate / prune / backtrack) does the heavy lifting.

Recall Solution

One valid solution: Which step matters: the evaluate-and-prune step. A greedy CoT that commits early to, say, leaves , which cannot reach ; CoT gets stuck. ToT's evaluator labels such states "impossible" and prunes them before wasting depth, while backtracking lets the search return to try instead. Generation supplies candidates; evaluation + pruning is what turns a hopeless greedy walk into a solvable search.

L5.3

You must ship a system under a hard budget of 30 LLM calls per query for a benchmark where single-chain accuracy is and problems are not combinatorial dead-end puzzles. Choose SC vs ToT, choose the parameter, and justify with numbers.

Recall Solution

The task has no dead-ends, so ToT's backtracking buys little — and ToT would blow the budget fast ( grows quickly). Choose SC. With , voting amplifies accuracy, and the whole -call budget can go to votes. Use the largest odd : . Sanity check the direction of the gain at a small odd (threshold ): ✓ Already a lift at ; pushing to climbs further toward the Condorcet limit. Verdict: SC with (odd, within budget), no ToT.


Recall One-line self-test before you leave

SC amplifies accuracy by voting (needs , temp , cost ); ToT searches a tree with generate/evaluate/prune/backtrack (cost , wins on dead-end tasks).