Lesson 4: Chain-of-Thought: Making AI Show Its Reasoning
Learning goals:
- Understand how chain-of-thought works and why it helps
- Learn to guide AI reasoning with "let's think step by step"
- Recognize which task types are a good fit for CoT
Prerequisites: << Lesson 3: Few-Shot Learning | Next: Lesson 5 >>
When AI Gives the Right Answer but the Wrong Reasoning
You ask AI a math word problem and it answers "42." You check it, and the answer is right. But swap in a similar problem and the answer comes out wrong. What happened? The model may have guessed, or followed a broken reasoning path that happened to land on the right number.
For tasks that need multi-step reasoning (math problems, logic puzzles, complex analysis), having AI show its reasoning steps is more reliable than asking for the answer directly1 2. That's the core idea behind chain-of-thought (CoT) prompting: break the conclusion into intermediate steps you can actually check.
What Is Chain-of-Thought
Chain-of-thought (CoT) prompting is a technique that has the model lay out intermediate reasoning steps before it gives a final answer1. In the words of the research, chain-of-thought prompting "enables complex reasoning capabilities through intermediate reasoning steps"1. The intuition is simple: "Chain of Thought prompting encourages the model to think through the problem in a step-by-step manner, which is supposed to mimic how humans break down complex problems"2. It's the same thing you do when you list equations and intermediate results on scratch paper to solve a math problem.
Compare the two approaches:
Answering Directly (Error-Prone)
❌ Without CoT:
AI might just output:
If the answer is wrong, you have no idea which step went off.
Showing the Reasoning Steps (More Reliable)
✅ With CoT:
AI outputs:
Every step is visible, so if one is wrong you can spot it right away and fix the prompt.
Research shows that on tasks involving multi-step reasoning, CoT lifts accuracy substantially1; on some tasks, pairing CoT with worked demonstrations raises accuracy by up to another 28.2%2.
Two Ways to Use CoT
Method 1: Zero-Shot CoT (Simplest)
Add one line to the end of your prompt: "let's think step by step"1 2.
That single line triggers the model's step-by-step reasoning mode. You don't provide any examples; the model breaks the problem down on its own.
Method 2: Few-Shot CoT (More Controllable)
Give one or two examples that include the full reasoning process1 2.
The example shows the reasoning format and how detailed the steps should be, and the model imitates that style.
What Tasks Suit CoT
CoT is best for tasks that need multi-step reasoning2:
✅ Math and logic reasoning
- Word problems
- Ratio and proportion calculations
- Multi-step formula derivations
✅ Causal analysis
- "Why does X cause Y?"
- "What's the root cause of this bug?"
✅ Planning and decisions
- "Should I do A first or B first?"
- "What are the pros and cons of this approach?"
✅ Code debugging
- "Why does this code fail?"
- "Which step is the performance bottleneck?"
Where it doesn't fit:
❌ Simple fact lookups: "When was Python first released?" — no reasoning needed
❌ Creative writing: poems, stories — reasoning steps break the creative flow
❌ Format conversion: JSON → CSV — a mechanical operation, no reasoning needed
Rule of thumb: if you'd reach for scratch paper to list out steps when doing the task yourself, it's a good fit for CoT.
Worked Examples: Analyzing Problems with CoT
Scenario 1: Code Performance Analysis
Without CoT (conclusion you can't trust):
Just a conclusion, with no reason why.
With CoT (clear reasoning):
AI shows:
Every reasoning step is checkable, so if one is wrong you can see it immediately.
Scenario 2: A Logic Puzzle
Problem:
AI output:
Laying out this step-by-step elimination makes it much easier to check whether the logic is airtight.
Common CoT Patterns
Pattern 1: Problem Decomposition
Break a complex problem into a few sub-problems.
Pattern 2: Hypothesis Testing
List the hypotheses, then check them one by one.
Pattern 3: Arguing Both Sides
List the reasons for and against, then reach a conclusion.
The Limits of CoT
CoT isn't a cure-all. It has a few limits:
1. It adds length and time
Showing reasoning steps makes the output longer, burns more tokens, and takes longer to respond.
When it's worth it: on complex tasks, spending 2-3x the tokens to gain accuracy is a good trade.
When it isn't: on simple tasks ("what day is it today"), the reasoning steps are pure waste.
2. The reasoning steps can themselves be wrong
The steps AI shows can look reasonable but still have a hole in the logic. You still need to check whether the reasoning is correct.
The value of CoT is that it makes errors visible. When AI answers directly, the error hides in a black box; when the steps are shown, the error surfaces at some step and is easier to find and fix.
3. It doesn't suit tasks that rely on intuition
Some tasks (creative writing, evaluating art) lean on an overall feel, and forcing them into steps breaks the whole.
Recap
Chain-of-thought prompting has AI show its reasoning steps instead of jumping straight to an answer. By adding "let's think step by step" to a prompt, or by providing examples that include the reasoning, you can substantially raise accuracy on multi-step reasoning tasks.
CoT fits math reasoning, logic analysis, causal inference, complex decisions — anything that needs multiple steps of thought. It makes the reasoning visible and checkable. It does add output length, but on complex tasks the payoff far outweighs the cost.
The next lesson covers how to debug and improve prompts: when AI's output doesn't match what you expected, how to systematically find the problem and fix it.
Next lesson Debugging and Improving Prompts >>