Skip to content

Chain-of-Thought

Getting a language model to write out intermediate reasoning steps before its final answer, which markedly improves results on math and logic problems.

Also CoT · step-by-step reasoning · let's think step by step · scratchpad

Fig. / How it works
QuestionQuestionStep 1Step 1Step 2Step 2Step 3Step 3AnswerAnswer
Role · kind
Using and applyingTechnique
Level
Intermediate

Wei et al., 2022

If you solve 17 × 24 in your head you may slip up. Write the steps on paper and you get it right. Letting the model 'write on paper' helps it the same way.

Where it fits

+All relationships as a list

Is a kind of / part of

See it on the full map

How it works

An LLM produces each token with a fixed amount of computation. If a question needs several reasoning steps, jumping straight to the answer leaves too little room to compute it.

Chain-of-thought prompting asks the model to show its work:

Q: A cafe had 23 apples. It used 20 for lunch and bought 6 more. How many does it have? A: It started with 23 and used 20, leaving 3. Then it bought 6, so 3 + 6 = 9. The answer is 9.

Two ways to trigger it:

  • Few-shot: include worked examples with reasoning in the prompt (in-context learning).
  • Zero-shot: just add “Let’s think step by step.”

Each step the model writes becomes part of its context, so later steps can build on earlier ones, like using scratch paper.

A caution: a model’s written reasoning is not necessarily a faithful account of what drives its answer, which is an active topic in interpretability and safety. Building on this idea, reasoning models are trained to think at length before answering.

Everyday use cases

  • Case 01

    Math word problems

    Asking for the steps before the answer greatly reduces arithmetic and logic slips.

  • Case 02

    Debugging

    Having a model walk through code line by line before proposing a fix.

Strengths, weaknesses and when to use it

Strengths

  • Large accuracy gains from a small prompt change; the steps make errors easier to spot.

Weaknesses

  • More tokens means slower and costlier answers.
  • The written reasoning is not guaranteed to reflect how the model actually reached its answer.

When to use itMulti-step problems (math, planning, logic). Less useful for simple lookups.

Compare with

Check yourself

  1. Q01

    Why does writing out steps help an LLM?

    Show answer

    A: Each generated step becomes context the model can build on, giving it more computation per answer

Go deeper