Chain-of-Thought

Chain-of-Thought Prompting
Make the AI reason step by step before it answers — for higher accuracy on complex problems.
What Is Chain-of-Thought Prompting?
Chain-of-Thought (CoT) prompting asks the model to show its reasoning step by step before delivering a final answer. Instead of jumping straight to a conclusion, the model works through the problem out loud — one logical step at a time.
This simple shift dramatically improves accuracy on tasks that require multiple steps: math, logic puzzles, word problems, and complex decision-making. By "thinking before answering," the model catches mistakes it would otherwise make in a single leap.
A Simple Analogy
It's the difference between a student who blurts out an answer and one who "shows their working." When you write out each step of a math problem, you're far less likely to make a careless error — and so is the AI.
Reasoning vs. Direct Answer
The same question can produce very different results depending on whether you let the model reason.
Direct (often wrong)
- Jumps straight to an answer
- No visible reasoning
- Careless errors slip through
- Hard to spot where it went wrong
Step-by-Step (more accurate)
- Breaks the problem into steps
- Reasons through each one
- Reaches the correct final answer
- Easy to audit the logic
Example: Triggering Chain-of-Thought
The simplest form — Zero-Shot CoT — is just adding one magic phrase to your prompt:
Question: A shop sells pens at 12 for 60 rupees.
How much do 5 pens cost?
Let's think step by step, then give the Final Answer.
The model now reasons before answering, instead of guessing:
Step 1: Find the price of one pen.
60 / 12 = 5 rupees per pen.
Step 2: Multiply by 5 pens.
5 x 5 = 25 rupees.
Final Answer: 25 rupees.
Few-Shot Chain-of-Thought
For harder tasks, show one or two worked examples that include the reasoning. The model imitates the reasoning pattern, not just the answer format:
Q: The cafe had 23 muffins. It sold 15 and baked 30 more. How many now?
A: Start with 23. Sold 15 -> 23 - 15 = 8. Baked 30 -> 8 + 30 = 38.
Final Answer: 38.
Q: A tank holds 50 litres. 18 litres leak out, then 25 are added. How much now?
A:
Variations to Know
Zero-Shot CoT
The fastest trigger.
Simply add "Let's think step by step" — no examples needed.
Few-Shot CoT
Show the reasoning pattern.
Provide worked examples that include each reasoning step.
Self-Consistency
Vote for the best answer.
Sample multiple reasoning paths and take the majority answer.
Tree-of-Thought
Explore and compare.
Branch into several reasoning paths, then pick the strongest.
When to Use Chain-of-Thought
- Math and arithmetic problems
- Logic puzzles and multi-step reasoning
- Complex decisions with several factors
- Word problems that hide the calculation
- Any task where you want to audit how the answer was reached
Direct vs. Chain-of-Thought at a Glance
| Aspect | Direct Prompt | Chain-of-Thought |
|---|---|---|
| Reasoning shown | None | Step by step |
| Accuracy on hard tasks | Lower | Higher |
| Best for | Simple, one-step tasks | Math, logic, multi-step problems |
| Token cost | Low | Higher (reasoning adds length) |
| Auditability | Hard to debug | Easy to trace errors |
Common Pitfalls to Watch Out For
Why Step-by-Step Improves Accuracy
A multi-step problem can be seen as a chain of dependent sub-steps. If each step is solved correctly with probability \( p \), then answering directly risks compounding errors, while reasoning explicitly through each step keeps the model focused on one sub-problem at a time:
$$ P(\text{correct}) \;=\; \prod_{i=1}^{n} p_i $$
By making each \( p_i \) explicit and visible, Chain-of-Thought reduces the chance of a hidden mistake collapsing the whole answer.
Key Takeaway
Chain-of-Thought turns guessing into reasoning. For any math, logic, or multi-step task, add "think step by step", let the model reason, and isolate a clear Final Answer — accuracy will climb.