LearnThatStack Ace your next interview
Prompt Engineering · question
Question 4 of 55

What is chain-of-thought prompting, and why does it improve results on certain tasks?

beginner
← All Prompt Engineering questions
Re-explain
Visual ↓

Chain-of-thought prompting asks the model to write out its reasoning steps before it gives the final answer. The steps are ordinary output tokens, so you can see them.

Solve the problem. Think step by step inside <scratchpad> tags.
Then give only the result on a line starting with "Answer:".

Problem: {{problem}}

It helps because the model computes one token at a time. Written steps become context that later tokens can read, so the model need not jump straight to the result. That pays off on multi-step arithmetic, logic puzzles, and rule-heavy classification.

The cost is extra tokens and latency, and it rarely helps on lookup or short rewrites. Parse the answer from the marked line, not the whole text.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for Prompt Engineering One question at a time. Answer out loud, get graded, see what you missed.
See it - interactive diagram
How written steps feed the final answer
Solve the problem.
Think step by step inside
<scratchpad> tags.
Then give only the result
on a line starting with
"Answer:".
Problem: {{problem}}
Without CoTanswer right after question
17×24?
With CoTsteps stay in context
17×24?
1step

Both runs get the same problem. Only the chain-of-thought prompt says to think step by step. The model writes one token at a time.

1 / 7

Each written step joins the context, so the Answer line reads results already on the page instead of jumping straight from question to answer.

© LearnThatStack - diagrams may not be republished without permission.

Other questions have diagrams like this too. Sign in to ask for one where it's missing - it's free.

Create a free account
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

What you can say

  1. Chain-of-thought prompting means asking the model to write out its reasoning steps before it gives the final answer.
  2. In practice I tell it to think step by step inside scratchpad tags, then put only the result on a line that starts with Answer.
  3. It works because the model produces one token at a time, and the steps it writes become context that later tokens can read.
  4. So it doesn't have to jump straight to the result, and that pays off on multi-step arithmetic, logic puzzles and rule-heavy classification.
  5. In code I parse the answer from that marked line, not from the whole response.
  6. The cost is extra tokens and latency, and it rarely helps on lookups or short rewrites, so I leave it off for those.

Weak answers to avoid

  • Stops at 'add think step by step' That's the trigger, not the reason. Explain that written steps become context later tokens can read, and name the tasks where that helps.
  • Says it always improves output It costs tokens and latency, and it rarely helps lookups or short rewrites. Say which tasks gain: multi-step math, logic, rule-heavy classification.
  • Says the model 'thinks harder' Vague and anthropomorphic. The steps are ordinary output tokens, and the gain comes from later tokens being able to read them.
  • Parses the whole response for the answer The parser can pick up numbers and guesses from inside the reasoning. Put the final answer on its own marked line or tag and parse only that.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the Prompt Engineering cheatsheet.

← Back to all Prompt Engineering questions
Pro · $10/mo

48 of 55 Prompt Engineering answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime