Homeprompt optimizationPrompt Optimization – 3: Chain-of-Thought Prompting

Prompt Optimization – 3: Chain-of-Thought Prompting

IDEA : Ask the Model to Show Its Work


Theory

By default, a language model generates its final answer through a single forward pass of token prediction, conditioned on whatever’s in the prompt. For tasks with multiple dependent steps — solving a multi-stage circuit, propagating error through a series of calculations, working through a proof — jumping straight to the answer means the model has to get every intermediate step right implicitly, with no opportunity to catch its own error along the way.

Chain-of-thought prompting asks the model to print its intermediate reasoning steps before producing the final answer. This matters for two related reasons:

  1. Error propagation control. Once a step is written out explicitly, it becomes part of the context that conditions the next step. This is analogous to writing each line of a derivation on paper — it constrains what can come next and gives the model a checkpoint to catch a sign error before it cascades through the rest of the problem.
  2. Auditability. A final numeric answer with no shown work is unfalsifiable — you can’t tell if it’s right for the right reasons. A shown derivation is checkable at each step, which matters enormously in contexts where “plausible-looking but wrong” is a common and costly failure mode.

Two ways to trigger it:

  • Zero-shot CoT: simply appending an instruction like “Think through this step by step before giving your final answer” or “Explain step-by-step”, or “Show your reasoning”, or “Break the solution into steps” to an otherwise ordinary prompt.
  • Few-shot CoT: providing one or two worked examples where the reasoning steps are shown explicitly, so the model matches both the method and the level of granularity of the shown reasoning — this is chain-of-thought and few-shot prompting combined, and it’s usually the more reliable of the two.

Example1: Without Chain-of-Thought

Prompt: I have 10 apples. I give 2 to a neighbor and 2 to a repairman. Then I buy 5 more and eat 1. How many do I have left ?

Typical AI Response: “You have 11 apples.” (Incorrect; often occurs when models skip steps)

With Chain-of-Thought

Prompt: I have 10 apples. I give 2 to a neighbor and 2 to a repairman. Then I buy 5 more and eat 1. How many do I have left ? Show me step by step

Step-by-Step Resolution (Chain of Thought)

  • Step 1: Starting Inventory
    You begin with an initial count of 10 apples.
    • Current Balance: 10 apples
  • Step 2: Distribution
    You give 2 apples to a neighbor and 2 apples to a repairman.
    • Calculation: 10 – 2 – 2 = 6
    • Current Balance: 6 apples
  • Step 3: Acquisition
    You purchase 5 additional apples and add them to your remaining stock.
    • Calculation: 6 + 5 = 11
    • Current Balance: 11 apples
  • Step 4: Consumption
    You eat 1 apple from your current total.
    • Calculation: 11 – 1 = 10
    • Current Balance: 10 apples

3. Final Answer
You have exactly 10 apples left.

EXAMPLE 2: Without COT

Weak prompt: A resistor is measured as R = 100 Ω ± 2 Ω and current as I = 0.5 A ± 0.01 A. What is the uncertainty in the power dissipated, P = I²R?

This often returns a bare numeric answer, sometimes with a silently wrong propagation formula.

With zero-shot CoT Prompt: A resistor is measured as R = 100 Ω ± 2 Ω and current as I = 0.5 A ± 0.01 A. What is the uncertainty in the power dissipated, P = I²R? Think through this step by step: first write the general error propagation formula for P = I²R, then identify each partial derivative, then substitute values, then compute the final uncertainty. Show each step before giving the final answer.

Forcing the derivation to be explicit (write the formula → take partial derivatives → substitute → combine) makes each stage checkable, and it’s much harder for the model to skip the cross-term or mishandle the squared variable silently.


Example 3 — Few-Shot CoT: Stability Analysis

Good Prompt: Determine whether each system is stable using the Routh-Hurwitz criterion. Follow the reasoning style of the example.

Example System: s³ + 2s² + 3s + 10 = 0 Reasoning:

  • Step 1: Write the Routh array using coefficients 1, 2, 3, 10.
  • Step 2: Compute the first-column entries: 1, 2, (2·3 − 1·10)/2 = −2, 10.
  • Step 3: A sign change occurs in the first column (2 → −2), indicating a right-half-plane pole.
  • Conclusion: The system is unstable.

Now analyze: System: s³ + 4s² + 5s + 2 = 0

By seeing the reasoning broken into labeled steps (build array → compute entries → check sign changes → conclude), the model reliably reproduces that same decomposition on the new problem instead of jumping to a bare “stable/unstable” verdict.


Example 4 — CoT for Debugging a Derivation

CoT is also useful when you want the model to find an error in an existing derivation rather than produce one from scratch — closer to how a TA grades.

Prompt: A student claims the Laplace transform of f(t) = t·e^(−2t) is F(s) = 1/(s+2)². Check this step by step: first state the general transform pair for t·e^(at), then substitute a = −2, then compare to the student’s claimed answer, then state whether it is correct and why.

Asking for the check to be decomposed this way makes the model less likely to just pattern-match “looks about right” and instead actually re-derive the reference result before comparing.


Why Chain-of-Thought Prompting is Important ?

Normally, AI may jump directly to an answer.

When we ask AI to show steps:

  • Errors reduce significantly
  • Reasoning becomes transparent and Output becomes more reliable
  • Complex tasks become easier

This method improves accuracy, especially in:

  • Logical problems: Coding
  • Mathematical calculations
  • Complex reasoning tasks
  • Decision making and Data analysis

Notes

  • CoT is not free. Longer reasoning chains cost more tokens/compute and can occasionally introduce an error that wouldn’t have occurred in a terse answer, if the model talks itself into a wrong turn partway through. Worth showing students a case where this happens — it reinforces that CoT increases auditability, not infallibility.
  • Pair it with a verification step. A strong pattern for technical work: “Solve step by step, then check your final answer by substituting it back into the original equation.” This gives the model an explicit self-check pass, similar to how you’d teach students to verify a solution.
  • CoT and role prompting compound well. A “senior reviewer” role plus a “think step by step” instruction tends to produce output that reads like an actual technical review — stepwise, with reasoning surfaced, rather than a confident unexplained verdict.

Share: 

No comments yet! You be the first to comment.

Leave a Comment

Your email address will not be published. Required fields are marked *