LearnAI home

Core Techniques ยท Lesson 6

Chain-of-Thought: Show Your Work

Make the model reason step by step before answering.

Why blurting fails

Quick: a bat and a ball cost 1.10 dollars together. The bat costs 1 dollar more than the ball. How much is the ball?

If "10 cents" jumped into your head, congratulations: you just blurted. (It's 5 cents: the bat is 1.05, and 1.05 plus 0.05 is 1.10.) Humans get this wrong when answering on reflex and right when working it through. Language models are eerily similar.

A model generates text one token at a time, each token building on the ones before it. If you push it to answer immediately, the answer leans on reflex, the statistically likely-looking response. But if the model writes out its reasoning first, every step becomes context that the final answer can build on. Reasoning first, answer last. That's chain-of-thought prompting.

The magic phrase

The classic version is almost embarrassingly simple: add "think step by step" (or "show your reasoning before answering") to your prompt.

โŒ Weak prompt

Prompt

A cafe sells coffee for 4 dollars and pastries for 3 dollars. On Tuesday they sold 27 items total and made 89 dollars. How many coffees did they sell? Answer with just the number.

Output

15

Wrong, and confidently so. Forced to blurt a single number, the model grabbed something plausible-looking. 'Answer with just the number' accidentally banned the thinking that produces the right number.

โœ… Good prompt

Prompt

A cafe sells coffee for 4 dollars and pastries for 3 dollars. On Tuesday they sold 27 items total and made 89 dollars. How many coffees did they sell? Think step by step, then give the final answer.

Output

Let c be coffees and p be pastries. Then c plus p equals 27, and 4c plus 3p equals 89. From the first equation, p equals 27 minus c. Substituting: 4c plus 3 times (27 minus c) equals 89, so 4c plus 81 minus 3c equals 89, so c equals 8. Check: 8 coffees is 32 dollars, 19 pastries is 57 dollars, total 89. Final answer: 8 coffees.

Same model, same problem. Now it sets up equations, solves, and even checks its work. Each written step became solid ground for the next one to stand on.

When to reach for chain-of-thought

  • Math and logic: word problems, unit conversions, anything with steps
  • Multi-constraint decisions: "pick a venue that fits 40 people, is under 500 dollars, and is near a train station"
  • Analysis: "is this contract clause risky?" benefits from listed considerations before a verdict
  • Debugging: "walk through this code line by line before saying what's wrong"

And when to skip it: simple lookups, creative writing, casual chat. Asking for step-by-step reasoning on "write a haiku about soup" just gets you a weird essay about soup, then a haiku.

Many modern models now do hidden or built-in reasoning automatically. Some even have a dedicated "thinking" or "reasoning" mode. The principle still matters: for hard problems, make sure reasoning happens somewhere before the answer. And a visible chain has a bonus: you can check the steps and spot exactly where things went sideways.

A template you can steal

Reason-then-answer template

[Your question or problem here]

Before answering:

  1. List the relevant facts and constraints.
  2. Work through the problem step by step.
  3. Double-check the result against the constraints. Then give your final answer on its own line, starting with "Final answer:".

That last line is a pro move: it gives you structured reasoning and an easy-to-find answer, so you don't have to fish the number out of a paragraph.

A confident chain of reasoning is not proof of a correct answer; models can write beautiful step-by-step nonsense. The chain makes errors visible and checkable, which is the real win. Always sanity-check step math on anything that matters.

Checkpoint

Chain-of-thought means asking the model to reason before answering: each written step becomes context the final answer builds on, which beats blurting on multi-step problems.

๐Ÿ“ Quiz

Question 1 of 4

Why does 'think step by step' improve answers on multi-step problems?

Found this useful? Pass it on.