Skip to the workspace
Pebellslearn by building
Prompting for Reasoning  ›  Lesson

Chain-of-Thought Prompting

Chain of Thought (CoT) Prompting 14 minAsking the model to reason step by step before answering gives it room to work through multi-step problems, which improves accuracy.

prompt engineering / Chain-of-Thought Prompting

Explore each scene at your own pace.

01 · The rule

The rule

Chain-of-Thought Prompting

"Is this customer owed a refund?" sounds like a yes-or-no question, but answering it means finding the delivery date, counting days, checking whether the item was used and comparing with the policy. When the prompt demanded only "yes" or "no", the model got about one in four wrong. Letting it work the problem through first changed that.

The rule

Reason first, answer last — the answer can only use what came before.

Chain-of-thought (CoT) prompting asks the model to write out intermediate reasoning steps before its final answer. It helps on tasks with several steps: arithmetic, date logic, rule-checking, planning.

Why it works follows from next-token prediction. Each token is chosen based on the text before it. If the final answer comes first, it must be produced in a single step, with no written working to lean on. If the reasoning comes first, the answer is predicted after the dates, counts and comparisons are already written down in the context.

Two common forms:

  • Zero-shot CoT — add an instruction like "Work through this step by step before answering."
  • Few-shot CoT — include examples whose outputs show the reasoning, not just the answer.
Policy: unused items returned within 30 days of delivery get a full refund.
Today is 20 June.

<email>The gloves arrived on 28 May. Never worn. Can I return them?</email>

Reason step by step: find the delivery date, count the days to today,
check the item's condition, compare with the policy.
Then write a final line: "Refund: yes" or "Refund: no".

A good response counts 3 days left in May plus 20 in June, 23 days in total, notes "never worn", and ends Refund: yes.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.