Chain-of-Thought Prompting Explained: How Step-by-Step Reasoning Improves LLM Answers

Chain-of-Thought Prompting Explained: How Step-by-Step Reasoning Improves LLM Answers

Chain-of-thought prompting explained simply: it is a technique where you ask a language model to show its working before giving a final answer. Instead of jumping straight to a result, the model writes out intermediate reasoning steps, which make it far more likely to get the right answer on problems that need real thinking. The central question is when this technique helps and when it wastes tokens: it helps most on multi-step reasoning, maths and logic, and least on simple lookups and creative writing.

The idea predates the hype, but it only became practical once models grew large enough to reason. Google researchers showed in 2022 that a few worked examples could unlock reasoning ability already latent inside a large model.

Key takeaways

  • Chain-of-thought prompting asks a model to reason step by step before answering, improving accuracy on multi-step problems.
  • Eight worked examples lifted PaLM 540B from 17.9% to 56.9% on the GSM8K maths benchmark (Wei et al., 2022).
  • It works best on large models; gains are small or absent below roughly 100 billion parameters.
  • Zero-shot chain of thought, self-consistency and structured reasoning suit different workloads.
  • Long chains cost more tokens and can introduce new errors, so measure quality per token first.

What chain-of-thought prompting actually is

Chain-of-thought prompting structures a prompt so the model produces intermediate reasoning before its final answer. In the few-shot version, you include examples in which each question is followed by a worked solution and then the answer. In the zero-shot version, you add a phrase such as “think step by step” and let the model generate its own chain.

A language model predicts the next token from everything that came before, so a bare question gives it only the question to work from. A chain of thought gives it a trail of intermediate results: subtotals, eliminated options, stated assumptions. Each step is a small, easy prediction, which is why the technique helps most where a problem breaks into parts.

It is not magic, and it is not the same as the model “thinking” the way a person does. The chain is text the model generates, and it can be wrong or confidently misleading. What changes is the shape of the task: instead of one hard leap from question to answer, the model makes many small hops. Best for: multi-step maths, logic puzzles, planning and any task where the answer depends on intermediate results.

The evidence: what the original research showed

Jason Wei and colleagues at Google Research introduced the technique in the 2022 paper “Chain-of-Thought Prompting Elicits Reasoning in Large Language Models”, presented at NeurIPS 2022. The team tested three large models on arithmetic, commonsense and symbolic reasoning benchmarks. Prompting PaLM 540B with just eight chain-of-thought exemplars achieved state-of-the-art accuracy on GSM8K, a benchmark of grade-school maths word problems, surpassing even a fine-tuned GPT-3 with a verifier.

On GSM8K, PaLM 540B scored 17.9% with standard prompting and 56.9% with eight chain-of-thought examples, more than tripling its accuracy. The full paper is on arXiv at arXiv:2201.11903.

The paper also found a limit that still matters. Chain-of-thought prompting is an emergent ability of scale: it does not help small models, and only yields gains on models of roughly 100 billion parameters or more. Best for: teams running frontier-scale models on reasoning-heavy workloads where accuracy justifies the token cost.

Few-shot chain of thought: worked examples in the prompt

Few-shot chain of thought is the original form, and it remains the most reliable. You write three to eight examples in which each question is followed by a short worked solution and then the answer, using the same format the model should follow. The examples teach the model the reasoning shape you want: how detailed each step should be and what the answer format looks like.

Good examples matter more than many examples. Each worked solution should be correct, concise and representative of real problems. If your examples all solve easy cases, the model will not know how to handle hard ones, and if they use inconsistent formats, the model will copy the inconsistency.

Few-shot chain of thought is also the most controllable form. Because you wrote the examples, you control the reasoning style, the level of detail and the output format.

That control is valuable in production, where the chain may be shown to a user or logged for audit. For the versioning side of that discipline, see our guide to AI prompt version control. Best for: production systems where reasoning style, format and auditability matter as much as accuracy.

Zero-shot chain of thought: “think step by step”

Zero-shot chain of thought needs no examples at all. You append a phrase such as “Let’s think step by step” to the question, and the model generates its own reasoning chain before answering. The approach was introduced by Kojima and colleagues in 2022: large models have already learned the pattern of step-by-step reasoning from training data, and the phrase simply triggers it.

The appeal is obvious: no examples to write, none consuming context. The cost is control.

The model chooses its own reasoning style, which may be verbose or skip steps you care about. Accuracy is usually lower than with well-written few-shot examples, although the gap has narrowed as models have improved.

Zero-shot chain of thought is the right default for exploratory work and for tasks where you do not yet know what good reasoning looks like. It is also the right choice when context is scarce, because few-shot examples can consume thousands of tokens before the real question appears. Start zero-shot, measure, and add examples only where the measurements show a gap. Best for: exploration and prototyping where example-writing effort would exceed the accuracy gain.

Self-consistency: sampling several chains and voting

Self-consistency, introduced by Wang and colleagues in 2022, builds on chain-of-thought prompting by sampling several different reasoning chains for the same question and taking the majority answer. A hard problem has many possible reasoning paths, and while any single path can go wrong, the correct answer is the one most paths converge on.

The trade-off is pure cost. Self-consistency multiplies token spend by the number of samples, and latency too, unless samples run in parallel.

It also needs a task with a definite answer: voting works for maths and multiple choice, but not for open-ended writing. Used blindly, it is the most expensive way to buy a modest accuracy gain.

Use it selectively, on the questions where accuracy matters most. Run a single chain first, and only sample more chains when the first answer looks uncertain or the question is flagged as high-stakes. That keeps the average cost low while spending heavily exactly where it pays. Best for: high-stakes questions with a single correct answer, such as grading, pricing and compliance checks.

Comparing chain-of-thought prompting styles

Style How it works Accuracy Token cost Control
Few-shot chain of thought Worked examples in the prompt Highest of the three High, examples consume context Full control of style and format
Zero-shot chain of thought “Think step by step” trigger Good, below few-shot Low, no examples needed Model chooses its own style
Self-consistency Many chains, majority vote Best on definite-answer tasks Highest, multiplied by samples Same as the base style
Structured chain of thought Reasoning in a fixed schema Good, easier to verify Medium, schema adds tokens Strong, machine-readable output

There is no single best style, only a best fit for the workload. Few-shot wins where control matters, zero-shot wins where effort and context are scarce, and self-consistency wins where a wrong answer is expensive. Structured chains, where the model reasons inside a fixed format such as JSON, trade a little fluency for output a system can parse and check automatically.

A person at a desk working through a multi-step maths problem on paper beside a laptop showing a chat interface
Writing out intermediate steps turns one hard leap into a series of small, checkable hops, and that is exactly what chain-of-thought prompting does for a language model.

When chain of thought helps, and when it hurts

Chain of thought helps most on tasks with a verifiable answer and a decomposable path: arithmetic, logic, code debugging, planning and multi-hop question answering. It helps moderately where the reasoning is the product, such as explaining a decision. It helps least where there is nothing to reason about: factual recall, translation, summarisation and creative writing, where the extra tokens buy nothing.

It can also hurt. A long chain gives the model more chances to make a mistake, and an early error can poison everything that follows.

Models can also produce chains that sound rigorous but are post-hoc rationalisations, which is dangerous when the chain is shown to users as evidence. On simple tasks the overhead is pure waste: a model asked to think step by step about a one-word answer spends ten times the tokens for the same result.

Apply chain of thought where the task is hard and the answer is checkable, and skip it everywhere else. A support bot classifying intent does not need it; the same bot working out a refund that depends on three policy clauses does. Measure per task, not per model. Best for: teams that measure accuracy and cost per task instead of applying one prompting style to everything.

Cost, latency and the token bill

Every reasoning step is output tokens, and output tokens are the expensive kind. A chain-of-thought prompt that triples accuracy can also triple or quadruple the tokens per request, and latency grows with it, because tokens are generated one at a time.

Manage the cost by shortening the examples, capping reasoning length, and using a smaller model for easy cases, routing only the hard ones to a large model with chain of thought. Prompt caching helps when the few-shot examples are identical across requests. For the broader cost picture, see our guide to estimating LLM spend before you ship.

Do not decide any of this on instinct. Log tokens per request, latency per request and accuracy per task, then compare the chain-of-thought variant against the direct-answer variant on the same test set. If the accuracy gain is worth the cost, keep it; if not, drop it. Best for: production teams that treat prompting as an engineering decision with a measured return, not a stylistic preference.

Chain-of-thought prompting checklist

  • The task needs multi-step reasoning and has a checkable answer.
  • The model is large enough for the technique to help, roughly 100 billion parameters or more.
  • Few-shot examples are correct, concise and representative of real inputs.
  • The chain is capped in length so cost and latency stay within budget.
  • Outputs are logged so reasoning can be inspected when an answer goes wrong.
  • Accuracy, cost and latency are measured against a direct-answer baseline.
  • Self-consistency is reserved for high-stakes, definite-answer questions, not applied by default.

Frequently asked questions

What is chain-of-thought prompting?

It is a prompting technique where a language model is asked to produce intermediate reasoning steps before giving its final answer. The steps can come from worked examples or from a trigger phrase such as “think step by step”.

Does chain-of-thought prompting always improve accuracy?

No. It improves accuracy substantially on multi-step reasoning with large models, but it helps little on simple factual or creative tasks, and it can hurt small models.

How many examples should a few-shot chain-of-thought prompt include?

Three to eight examples is the usual range; the original paper used eight. More examples help up to a point, but each one consumes context and tokens, so stop when accuracy stops improving.

What is the difference between chain of thought and self-consistency?

Chain of thought is a single reasoning path; self-consistency samples many paths and takes the majority answer. Self-consistency costs more but is more accurate on tasks with a single correct answer.

Can I see the model’s chain of thought in production?

Yes, if you log the full output, but treat it with care. A chain of thought can contain sensitive reasoning or post-hoc rationalisation, so log it for debugging and audit, and decide separately what to show users. For the tracing side, see our guide to LLM tracing for multi-step applications.

Latest articles

Scroll to Top