LLM Basics
Lesson 3 of 6

Chain-of-Thought Prompting

Zero to GPT's sampling lesson covered how a model generates one token at a time, each new token attending back over everything already generated — including the tokens it just produced itself. Chain-of-thought (CoT) prompting exploits this directly: instead of asking for a final answer immediately, ask the model to reason out loud first. Every reasoning token it writes becomes part of the context the next token gets to attend to — effectively, the model is handing its future self extra scratch work instead of trying to leap straight to the answer in one shot.

Predict before you look

A multi-step percentage word problem. Before you look: do you expect the direct-answer version and the step-by-step version to land on the same final number?

They don't. Asked to answer immediately, the model got 31 — wrong (it's off by a step; the correct answer is 38). Asked to think step by step, it correctly computed 35% of 120 = 42 sold in the morning, added the 40 sold in the afternoon for 82 total, and subtracted from 120 to get 38. Same model, same question, same underlying weights — the only difference is whether it got to write out intermediate steps before committing to a final number.

This isn't universal — on a simpler problem (a juggler/golf-ball puzzle, try it in the widget above by imagining swapping the payload) both direct and step-by-step land on the same correct answer, because the problem doesn't need much intermediate work. CoT's advantage shows up specifically on multi-step problems where skipping straight to an answer skips real computation the model needed to do.

Why does writing out reasoning steps actually change a model's final answer, rather than just making the response longer?