4.4.7 · D1Alignment, Prompting & RAG

Foundations — Chain-of-thought prompting

2,871 words13 min readBack to topic

This page builds every symbol, letter, and idea the parent note Chain-of-Thought Prompting leans on — starting from "what is a language model even doing" and ending with the voting formula. Nothing is assumed. If you meet a symbol below that you've seen before, good; if not, we build it here.


0. What is a language model, in pictures?

Before any symbol, the object itself.

Think of it as a very well-read autocomplete. You type "The capital of France is" and it leans toward "Paris".

Figure — Chain-of-thought prompting

Look at Figure 1: text flows in on the left, the model is the box in the middle, and one new word pops out on the right. That single-word-at-a-time habit is the whole reason Chain-of-Thought matters — hold onto it.

Why do we even need this word? Because the entire argument for CoT is measured in tokens: more tokens written = more thinking done. We'll make that precise in §4.


1. , , and the arrow

The parent's very first line writes . Let's earn each piece.

The picture: is what goes into the box in Figure 1; is (eventually) what comes out. Standard prompting is the naive hope that the box jumps straight from to in one leap.


2. The reasoning steps

Now the star of the show.

The picture: this is the scratch paper. Each is one scribbled line before you circle the final answer.

Figure — Chain-of-thought prompting

Compare the two rows in Figure 2. Top row (standard prompting): one giant, terrifying jump . Bottom row (Chain-of-Thought): the same distance, but broken into small hops . Same start, same finish — but each hop is short enough to actually land.


3. Few-shot vs zero-shot: the word "shot"

The parent splits CoT into few-shot and zero-shot. That word "shot" needs a picture.

The picture: few-shot is handing the model a couple of answered homework problems as a template before giving it the new one. Zero-shot is handing it the new problem with only the instruction "show your working."

This idea comes straight from Few-shot In-context Learning — the model learns the format purely from examples inside the prompt, without any retraining. CoT is that trick, but the examples include reasoning, not just answers.


4. "Fixed computation per token" — the engine argument

This is the deepest assumption in the parent, and it uses no formula — so let's give it one clear picture.

Now the payoff: each reasoning token the model writes is fed back in as new input. So writing buys another forward pass to write , which buys another for

Figure — Chain-of-thought prompting

Read Figure 3 as a staircase. Standard prompting stands at the bottom and must jump to the answer in one step (the huge dashed arrow). CoT climbs — each stair is one token, one forward pass, one small amount of new thinking that the next stair gets to build on. Same height reached, but by climbing instead of leaping.

This is why the tool "write intermediate tokens" is the right tool: the bottleneck was compute-per-answer, and writing tokens is the only knob that adds compute at inference time without retraining.


5. The probability symbols: and the sum

The parent's key equation is . Every piece, from zero.

The picture: is the model's confidence in an answer after reading the question but before writing any working. is its confidence after it has already written the full chain of working — much sharper, because the hard part is done on paper.

Why this tool — a sum? Because there isn't one correct chain of working; there are many roads to the same answer. To get the total chance of landing on answer , you must collect the probability from every road, and "collect over all cases" is exactly what a sum does.

Figure — Chain-of-thought prompting

Figure 4 shows the question node splitting into several complete reasoning paths (violet), each carrying a bit of probability, all of them pouring into the same answer node. The total arriving at that answer is the sum. A correct answer (right side) collects from many fat paths; a wrong answer collects from a few thin, scattered ones — which is the whole reason voting works.


6. Self-consistency symbols: , , ,

The parent's voting formula is . Let's decode it fully.

Put together in plain words: "Count the votes for each possible answer; return the answer with the most votes." That's it — the intimidating formula is just majority vote, exactly as in Self-Consistency Decoding.


7. How it all connects

Language model predicts next token

One token equals one forward pass fixed depth

Token equals a word piece

More tokens buy more compute plus memory

Question q and answer a

Standard prompting q to a

Reasoning steps r1 to rk

Chain of thought q to steps to a

Shot equals worked exemplar

Probability p and the given bar

Sum over reasoning paths

Indicator plus argmax equals majority vote

Self consistency samples N chains

Follow the arrows: the humble "one token = one forward pass" fact feeds the whole idea, and the sum-over-paths feeds both the why of CoT and the voting of self-consistency. Everything on this page is a prerequisite for the parent note Chain-of-Thought Prompting, and it opens the door to Tree of Thoughts, ReAct, and Emergent Abilities of LLMs.


Equipment checklist

Cover the right side and answer each before moving on.

What does an LM output each step, and how much computation does that cost?
One token, using one forward pass of fixed layer-depth — though the cost of that pass grows with context length.
In , what are , , and ?
= the question/prompt, = the -th line of working, = the final answer.
What does the subscript in mean?
Pure counting — it's the third reasoning step, no operation implied.
What does a bare (no subscript) mean in ?
The entire reasoning path as one bundle, not a single step.
What does the symbol mean?
"Approximately equal to" — close but not exactly equal.
What is a "shot" / exemplar?
A fully solved example (question + working + answer) shown in the prompt as a pattern.
Why do written reasoning tokens make the model "smarter" at inference?
Each token is another forward pass fed back in — buying more compute and external memory.
Read in plain English.
The probability of answer , given both the reasoning and the question .
What does the bar mean?
"Given that" / "assuming."
Which two probability rules give ?
Law of total probability (sum over all chains) then the multiplication/chain rule ().
What does the indicator evaluate to?
if the bracketed statement is true, if false.
What does return?
The answer that makes the following quantity largest — here, the most-voted answer.
What does the hat in signify?
It marks as our chosen estimate of the answer.