Chain-of-Thought Prompting: How It Works, With Examples
Chain-of-thought prompting asks a model to write out its intermediate steps before answering. Examples, variants, limits, reasoning models and templates.
Chain-of-thought prompting (CoT) is a prompting technique in which you ask an AI model to write out its solution path in intermediate steps before it gives the final answer. Instead of naming a result straight away, the model breaks the task down, calculates or weighs things up step by step and only then concludes. This helps most with tasks that need several calculation or reasoning steps, and it shows where an error arises. For simple tasks and for modern reasoning models, the technique adds little or nothing.
This article shows how chain-of-thought works, which variants exist, when the technique pays off and how it differs from the similar-sounding prompt chaining.
An example: with and without a chain of thought
The task: a customer orders 240 units at 12.50 each, net. From 200 units there is an 8% volume discount. For payment within ten days, a further 2% early-payment discount applies to the discounted amount. What is the net amount due if the customer pays after seven days?
Without chain-of-thought:
A customer orders 240 units at 12.50 each, net. From 200 units there is an
8% volume discount, and for payment within ten days a 2% early-payment
discount on the discounted amount. What is the net amount due if the
customer pays after seven days? Answer with the amount only.
The model has to name the result in one go. Typical errors: the two discounts are added up to 10%, or the early-payment discount is calculated on the original amount.
With chain-of-thought:
A customer orders 240 units at 12.50 each, net. From 200 units there is an
8% volume discount, and for payment within ten days a 2% early-payment
discount on the discounted amount. What is the net amount due if the
customer pays after seven days?
Work step by step: write each calculation step on its own line and give the
amount only at the end, on a line starting with "Result:".
A correct answer looks like this:
1. List price: 240 × 12.50 = 3,000.00
2. Volume discount applies (240 ≥ 200): 3,000.00 × 0.92 = 2,760.00
3. Early-payment discount applies (7 days ≤ 10 days): 2,760.00 × 0.98 = 2,704.80
Result: 2,704.80
The gain is twofold: the model makes fewer mistakes on multi-step tasks, and if it does make one, you see it at once in line 2 or 3.
Where the technique comes from
Chain-of-thought became known through the 2022 paper "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models" by Jason Wei and colleagues. They showed that language models solve arithmetic, commonsense and symbolic reasoning tasks better when the examples in the prompt contain not just question and answer but also the written-out reasoning. Shortly afterwards, Takeshi Kojima and colleagues showed in "Large Language Models are Zero-Shot Reasoners" that a single sentence before the answer is often enough: "Let's think step by step".
The variants
| Variant | What the prompt looks like | Good for |
|---|---|---|
| Zero-shot CoT | The task plus an instruction to work step by step | A quick try when direct answers are unreliable |
| Few-shot CoT | Two or three examples with written-out reasoning, then the new task | Recurring tasks whose solution path follows a fixed pattern |
| Guided chain of thought | You specify the steps: "1. Check … 2. Calculate … 3. Compare …" | Tasks with a known checking or calculation logic |
| Reason first, then decide | Fixed output fields: first "Reasoning", then "Decision" | Classifications and assessments that need to be traceable |
In a business setting, the guided variant is usually the best: you know how an expense claim is checked or a complaint is categorised, so you give the model exactly that order. For few-shot CoT, the rules for good examples from our article on few-shot prompting apply.
With "reason first, then decide", watch the order of the fields. If the decision comes first, the model has already committed, and the reasoning is only supplied afterwards.
When chain-of-thought helps
- Multi-step calculations: discounts, deadlines, commissions, conversions.
- Rules with conditions: "if A and not B, then C", such as goodwill rules or approval limits.
- Comparisons across several criteria: setting offers or applications side by side against a list of criteria.
- Classifications with borderline cases: the reasoning shows which feature tipped the balance.
- Debugging: when a prompt returns wrong results, the chain of thought shows where the model takes the wrong turn.
When it adds nothing or does harm
- Simple tasks. Translating, summarising briefly, fixing a salutation: here the chain of thought only makes the answer longer.
- Pure knowledge questions. If the model lacks the information, thinking does not help; it needs the source in the prompt. See how to reduce AI hallucinations.
- Strict output formats. If only JSON should come back, written-out text gets in the way. Put reasoning and result into separate fields or into two prompts.
- Reasoning models. See the next section.
Reasoning models: the chain of thought is built in
Many current models have a thinking mode in which they work through intermediate steps internally before answering. A different rule applies to them. OpenAI states in its reasoning best practices that prompts such as "think step by step" may not enhance performance and can sometimes hinder it, and recommends simple, direct prompts.
In practice:
- If you use a reasoning model, describe goal, context and criteria clearly and leave out step-by-step instructions.
- If you use a classic, faster model without a thinking mode, chain-of-thought remains a simple lever.
- If you are unsure, test both variants on ten to twenty real cases and compare the results, not the impression.
The guided variant keeps its value with reasoning models too, but for a different reason: it describes your business checking logic, not thinking as such.
Chain-of-thought vs. prompt chaining
The terms sound alike but mean different things.
| Chain-of-thought | Prompt chaining | |
|---|---|---|
| What is chained | Reasoning steps inside one answer | Several prompts in a row |
| Number of model calls | One | Several |
| Who sets the steps | The model, or you in the guided variant | You, in advance |
| Control between steps | None: the model writes straight through | Possible: check, correct, insert code |
| Typical use | One calculation, one trade-off, one classification | A process of extraction, checking and drafting |
The two combine well: in a prompt chain, the checking step can itself use chain-of-thought. Our article on prompt chaining shows how to build chains.
Cost and speed
A chain of thought consists of output tokens, and with most providers output costs more than input. An answer with ten lines of reasoning costs several times as much as an answer with one number, and it takes longer. For single requests that does not matter; for ten thousand classifications a month it does. LLM API pricing explained shows how the bill adds up. Limit the length ("five steps at most, one line each") and use the technique only where it measurably helps.
The limit: reasoning is not proof
The written-out steps are text the model generates. They can contain calculation errors, misstate a rule, or sound coherent and still lead to a wrong result. A long, confident explanation also tempts people to look less closely. For anything that matters:
- Have calculation steps recomputed by code or a spreadsheet, not confirmed by the model.
- Spot-check the reasoning, not just the result.
- Do not pass the reasoning on unchecked as an explanation to customers or affected people.
Three templates to copy
Guided invoice check
Check the invoice below against the purchase order.
Work in this order and write one line for each point:
1. Do items and quantities match?
2. Do the unit prices match the order?
3. Is the total arithmetically correct?
4. Are discount and payment terms as agreed?
Then write a line "Result:" with "approve" or "clarify" and, if "clarify",
the reason.
Purchase order: """[text]"""
Invoice: """[text]"""
Reason first, then classify
Assign the customer enquiry to one category: complaint, invoice query,
delivery status, other.
First state under "Reasoning:" in two sentences at most which wording in the
enquiry is decisive. Then name exactly one category under "Category:".
Enquiry: """[text]"""
Trade-off with criteria
Compare the two offers on these criteria: total price over three years,
notice period, support hours, data location.
Go criterion by criterion and cite where each detail appears in the offer.
Only then write a recommendation of three sentences at most. If an offer
does not state something, write "not stated" and do not guess.
Offer A: """[text]"""
Offer B: """[text]"""
You can assemble prompts like these with the AI prompt generator; the sequence of steps goes into the rules field.
Common mistakes
- Chain-of-thought by default. The technique costs tokens and time. Use it deliberately.
- Decision before reasoning. The order of the output decides whether the reasoning supports the answer or merely justifies it afterwards.
- Believing the text because it is long. Check numbers independently.
- Step-by-step instructions for reasoning models. Clear goals and criteria help more there.
- Expecting a chain where a source is missing. Thinking does not replace missing knowledge.
Checklist
- The task has several calculation or reasoning steps.
- You know whether your model is a reasoning model.
- The steps are specified if you know the checking logic.
- The reasoning comes before the result, and the result is on its own clearly marked line.
- The length of the reasoning is limited.
- Numbers are recomputed independently.
- You have compared on real cases whether the technique improves results.
For the overall method behind good prompts, see our prompt engineering guide for business.
Sources
- Wei et al. (2022): Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- Kojima et al. (2022): Large Language Models are Zero-Shot Reasoners
- OpenAI: Reasoning best practices
FAQ
What is chain-of-thought prompting?
A prompting technique in which the model is asked to write out its solution path in intermediate steps before giving the answer. With many models this improves tasks that need several reasoning or calculation steps, and it makes the path to the answer checkable.
What is the difference between chain-of-thought and prompt chaining?
Chain-of-thought happens inside a single prompt: the model reasons step by step within one answer. Prompt chaining spreads a task across several prompts, where the output of one is the input of the next.
Does "think step by step" work with every model?
No. With classic language models the instruction often helps. Reasoning models already reason internally; OpenAI's documentation advises against step-by-step instructions for them, because these may not improve performance and can sometimes hinder it.
Is the written reasoning proof that the answer is right?
No. The reasoning is text the model generates. It can contain errors itself or sound more convincing than it is. It makes checking easier but does not replace it.
Related articles
- Prompt Chaining: What It Is, Examples and PatternsPrompting11 min
- Prompt Engineering for Business: A Practical GuidePrompting8 min
- Few-Shot Prompting: When and How to Use ExamplesPrompting7 min