4.4.8 · D2Alignment, Prompting & RAG

Visual walkthrough — Self-consistency and tree-of-thought

2,072 words9 min readBack to topic

Prerequisites we will lean on and re-build as needed: Chain-of-Thought Prompting, Temperature and Sampling in LLMs, Monte Carlo Estimation, Ensemble Methods and Majority Voting.


Step 1 — One chain is a single risky walk

WHAT. A language model, asked to "think step by step," writes ONE line of reasoning — a chain — and lands on ONE final answer. We call that answer (just a label for "the thing the model concluded", e.g. the number ).

WHY. Before we can argue that many chains help, we must see clearly what one chain is: a walk that starts at the question and takes one step after another, each step depending on the last. If step 2 goes wrong, every later step inherits the mistake. There is no undo.

WHAT IT LOOKS LIKE. The figure shows the walk as a path across a field of possible reasonings. The single green dot is where this one chain ends up. Notice there is nothing else on the picture — one sample, one guess, no way to tell if it was lucky.


Step 2 — There are many roads, and errors scatter

WHAT. Now sample the model again with a little randomness turned on (this is what temperature does — it lets the model pick slightly different words, so a fresh chain appears each time). We collect several chains

Reading that notation: the little superscript in just means "the -th sample". It is a counter, nothing more. is "the third chain we drew."

WHY. The key empirical fact from the parent note: correct chains agree on the answer; wrong chains each fail differently. Right answers pile up on one spot; wrong answers scatter to many spots. If that is true, then the most crowded spot is a strong bet for the truth.

WHAT IT LOOKS LIKE. Many paths now cross the field. Several green dots cluster tightly on the true answer . The red dots (wrong chains) are sprinkled all over, each alone. Your eye already wants to pick the cluster — that instinct is the algorithm.


Step 3 — What we actually want: the answer marginal

WHAT. We want the probability of an answer , no matter which reasoning produced it. Written out:

Term by term:

  • — the number we want: how probable is answer given the question.
  • — "add up over every possible chain ." The big-sigma is just "total these."
  • — how likely the model is to write chain .
  • — given that chain, does it conclude ? (In practice a chain is deterministic once written, so this is or .)

WHY. The reasoning is a nuisance variable — something we must account for but do not care about. The universal move for removing a nuisance variable is to sum the joint probability over all its values. That is exactly the sum above; this operation is called marginalizing.

WHAT IT LOOKS LIKE. Picture every chain that ends at answer dropping a coloured chip into the bucket labelled . The height of each bucket is . We want the tallest bucket.


Step 4 — We can't sum over all chains, so we sample (Monte Carlo)

WHAT. The sum has astronomically many terms — every essay the model could ever write. We cannot list them. Instead we draw chains at random in proportion to how likely the model is to write them, and count.

The tool we reach for is Monte Carlo Estimation: to estimate an average you cannot compute, replace it by an average over random samples. We use it precisely because the exact sum is impossible and sampling is what temperature already gives us for free.

The estimate of a bucket's height is

Term by term:

  • — the little hat means "estimate of" .
  • — how many chains we sampled.
  • — the indicator: it equals if the -th chain's answer equals , else . It is a light-switch that turns on only for matches.
  • — add up the switches and divide by : literally the fraction of chains that voted for .

WHY. This fraction is an honest estimate of the true bucket height, and it gets more accurate as grows (the law of large numbers). So counting votes = estimating the marginal.

WHAT IT LOOKS LIKE. The smooth "true" bucket bars from Step 3 are now approximated by tally marks — one stroke per sampled chain. With more samples the tally silhouette hugs the true bars.


Step 5 — Edge case: temperature collapses the vote

WHAT. Turn the randomness off (temperature ). The model then always writes its single most probable chain. All samples become identical.

WHY. A vote needs disagreement to be informative. If every chain is a photocopy, the tally has exactly one bucket with all votes — you learn nothing you didn't get from one call, but you paid .

WHAT IT LOOKS LIKE. Left panel: all arrows land on the same dot — one tall bucket, zero diversity. Right panel: temperature spreads the chains so the true cluster can actually form. Diversity is the fuel; without it the engine stalls.


Step 6 — Why the vote actually beats one chain (the Condorcet count)

WHAT. Suppose each single chain is correct with probability , and the many wrong answers are scattered (no single wrong answer rivals the correct one). The majority is correct whenever more than half the chains are correct. The probability of that is

Term by term:

  • — accuracy of one chain (e.g. ).
  • — how many of the chains happen to be correct.
  • — the number of ways to choose which of the are the correct ones (counts the combinations).
  • — probability of one specific pattern with correct and wrong.
  • — add all cases where correct-count is a strict majority. is "just over half, rounded up" ( when ).

WHY. This is the majority-vote (Condorcet) theorem: if each voter is better than a coin flip (), the crowd's majority beats any individual, and the gap grows with — the probability of majority-correct marches toward .

WHAT IT LOOKS LIKE. The binomial bars for : bars at (shaded — a correct majority) clearly outweigh . The shaded area is : accuracy leapt from to by voting alone.


Step 7 — Degenerate case: a two-way tie

WHAT. What if two answers get exactly the same number of votes (e.g. even, split evenly)?

WHY. Our rule is ; when two buckets tie there is no unique maximum. In practice you break ties by a fixed rule (e.g. prefer the answer whose chains had higher model probability, or simply raise to an odd number so a strict majority must exist).

WHAT IT LOOKS LIKE. Two equal-height buckets with a dashed "?" between them. Bumping from to tilts the scale so one bucket wins — a concrete reason odd is convenient.


The one-picture summary

Everything above compressed: sample many chains → correct ones cluster, wrong ones scatter → tally the answers → take the tallest bucket → its correctness rises toward as long as one chain beats a coin flip and the temperature keeps the chains diverse.

Recall Feynman: the whole walkthrough in plain words

One friend solving a hard problem might slip up, and you'd never know. So you ask forty friends but you shuffle their thinking a little (that's temperature ) so they don't all copy each other. The friends who understand it mostly land on the same right answer; the confused ones each blunder in their own weird way, so their answers are all over the place. You don't read anyone's working — you just count the final answers and go with the crowd's favourite. Counting votes is secretly the same as estimating "how probable is each answer?", because you couldn't possibly list every way to reason, so you sample instead (Monte Carlo). And here's the magic: as long as any one friend is even slightly better than a coin flip, the crowd's majority gets more and more certainly right the more friends you ask. That is self-consistency — one risky guess turned into a confident vote.


Recall Quick self-check

Why sum over in ? ::: is a nuisance variable; marginalizing (summing the joint over all its values) removes it and leaves the answer probability. What does the indicator do? ::: Returns when chain 's answer matches , else — so the average counts the vote fraction. Why must temperature be ? ::: At all chains are identical, the vote has no diversity, and you gain nothing. For , majority-correct probability? ::: (sum of binomial terms). What condition makes voting help rather than hurt? ::: Single-chain accuracy ; then majority accuracy as grows.