Chain-of-Thought Prompting
Chain-of-thought prompting asks a model to reason step by step before giving a final answer.
Prerequisites
What Is Chain-of-Thought Prompting?
A model generates its answer one token at a time, and each token is conditioned on everything generated so far. Chain-of-thought prompting takes advantage of this by asking the model to write out its reasoning step by step before stating a final answer, rather than jumping straight to a conclusion.
Question
Starting PromptThe problem the model needs to solve.
Step-by-step reasoning
Written Out LoudThe model reasons before jumping to a conclusion.
Final Answer
Conditioned on ReasoningEach token builds on the reasoning already written.
Key Idea
Because each token is generated based on everything before it, writing out intermediate steps gives the model more relevant context to condition its final answer on — reasoning "out loud" can measurably change the outcome.
When It Helps
- Multi-step arithmetic or logic problems — where skipping straight to an answer is more likely to produce an arithmetic slip.
- Tasks with several dependent sub-decisions — where getting an early step wrong would cascade into a wrong final answer.
- Debugging model behavior — seeing the reasoning trail makes it easier to spot where a wrong answer went off track.
Warning
Chain-of-thought doesn't guarantee correct reasoning — a model can produce a fluent-sounding chain of steps that still reaches a wrong conclusion, or that doesn't actually reflect how it arrived at the answer.
How to Prompt for It
The simplest version is an explicit instruction, such as "think step by step before giving your final answer." A more reliable version combines this with few-shot examples that themselves show the reasoning steps, not just the final answer — demonstrating the pattern rather than only requesting it. Some applications also ask the model to clearly separate its reasoning from its final answer, so the final answer can be extracted programmatically without the reasoning text mixed in.
Common Mistakes
Assuming the written-out reasoning is always the true reasoning
A model's stated chain of thought is generated text, not a guaranteed trace of its actual internal computation — it can be a plausible-sounding narrative rather than the real cause of the answer.
Using chain-of-thought for simple, well-defined tasks
For straightforward classification or extraction, added reasoning steps mostly add cost and latency without improving accuracy.
Not separating reasoning from the final answer
If an application needs to parse only the final answer, mixing it with reasoning text makes that harder and more fragile.
Assuming chain-of-thought fixes hallucination
Step-by-step reasoning can still be built on a wrong or fabricated premise, producing a confidently wrong final answer.
Interview Question
What is chain-of-thought prompting, and why does it sometimes improve results?
Chain-of-thought prompting asks a model to write out its reasoning step by step before giving a final answer, instead of jumping straight to a conclusion. Because a model generates each token conditioned on everything before it, writing out intermediate steps gives it more relevant context to base the final answer on, which tends to help with multi-step arithmetic, logic, or tasks with several dependent decisions. It's not a guarantee of correct reasoning, though — a model can produce a fluent chain of steps that's wrong, or that doesn't actually reflect how it arrived at the answer, so it's most useful for genuinely multi-step tasks rather than simple ones.
What an interviewer may ask next
- Why might writing out reasoning steps change a model's final answer?
- Is a model's stated chain of thought guaranteed to reflect its actual reasoning process?
- When would chain-of-thought prompting be unnecessary or even counterproductive?
Explain It in 30 Seconds
Chain-of-thought prompting asks a model to reason step by step before stating a final answer, instead of answering immediately. Because each token is generated based on everything before it, spelling out intermediate steps gives the model more relevant context, which tends to help on multi-step arithmetic, logic, or tasks with several dependent decisions. It's not a guarantee of correct reasoning — the written-out steps are generated text, not a verified trace of what actually happened internally.