Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Prompting Techniques and Context Engineering  ›  Lesson

Chain-of-Thought Prompting

CoT 12 minChain-of-thought prompting has the model work through intermediate steps before giving a final answer, which helps on multi-step problems at the cost of extra tokens and time.

Chain-of-Thought Prompting

A customer returns an opened wheelset and unopened gloves. Pedal Point's rules: opened items that are not faulty lose a 10% restocking fee, unopened items come back in full, shipping is never refunded. Asked for "just the refund amount", the assistant sometimes applies the fee to both items. The maths is easy for a person working step by step. So let the model work step by step too.

The rule

For multi-step problems, let the model work before it answers.

A model writes one token at a time, and each token is shaped by the text before it. If the very first token must be the final answer, all the reasoning has to happen invisibly inside that one step. If the model first writes out the intermediate steps, each later step can build on them.

Chain-of-thought (CoT) prompting asks for exactly that:

Work through each returned item: is it opened, is it faulty, what fee applies?
Then give the total on a final line in the form: REFUND: <amount>

For the wheelset at 250 and gloves at 40:

  • Wheelset: opened, not faulty, fee 10% of 250 = 25, refund 225.
  • Gloves: unopened, refund 40.
  • Total: 225 + 40 = 265.

Some models are built to reason internally before answering and need less prompting for this; the principle is the same.

Use CoT where it pays:

  • Helps: calculations, policy rules that combine, planning, multi-step decisions.
  • Wastes: simple lookups and classifications. Reasoning costs extra tokens and time on every request.

Two cautions. The written reasoning is not a guaranteed record of why the model reached its answer, so do not treat it as proof. And for anything involving money, recompute the result in code.

The shortcut

Think first, answer last, in a fixed spot. Ask for the steps, then the result on a line or field your code can read.

Getting a clean refund numberStep 1 of 4
  1. Ask for the steps

    "For each item, state opened or unopened, faulty or not, and the fee."

The trap is showing customers the whole scratchpad. They want the answer; keep the working in your logs, where it helps you debug a wrong total later.

Drills

Answer fast — trust the rule.

quick drill

Which task benefits most from chain-of-thought prompting?

quick drill

An opened, non-faulty 120 pump and unopened 30 lights are returned. What is the refund under the policy?

quick drill

Why ask for the final answer on a fixed line like REFUND: 265?

quick drill

What is a real cost of chain-of-thought?

Remember

  • For multi-step problems, let the model work before it answers.
  • Think first, answer last, in a fixed spot.
  • Reasoning is not proof: recompute money in code.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainA refund that needs steps

A customer returns an opened, non-defective carbon wheelset that cost 300 and unopened gloves that cost 40. Policy: opened non-defective items lose a 10% restocking fee, unopened items are refunded in full, and original shipping is not refunded. Work out the refund, then explain why step-by-step reasoning helps the model here and how the app should get a clean number out of the reply.