Prompt Engineering

Step-by-Step Reasoning

Lesson 5 of 10

A model writes its answer one token at a time. If you ask for only the final answer to a problem with several steps, it has to commit without working anything out. Asking it to reason first often improves the result. The research paper that popularised the idea called it chain-of-thought prompting.

The basic technique

Without reasoning:

A shop sells pens at 3 for 2.40. Asha buys 7 pens and pays with a 10 note.
How much change does she get? Reply with the number only.

With reasoning:

A shop sells pens at 3 for 2.40. Asha buys 7 pens and pays with a 10 note.
How much change does she get?

Work through the problem step by step, then give the final answer on its own line.

The second prompt lets the model find the price of one pen, then of seven, then the change. Each written step becomes input for the next.

Guide the steps

For tasks where you know the method, spell it out.

Decide whether this expense claim should be approved.

Think it through in this order:
1. What is the expense, and which category does it belong to?
2. What is the limit for that category in the policy?
3. Is the claim within the limit, and is a receipt attached?
4. Are there any exceptions in the policy that apply?

Then give your decision as APPROVE, REJECT or NEEDS REVIEW.

<policy>
{policy text}
</policy>

<claim>
{claim details}
</claim>

Separate the thinking from the answer

Ask for the reasoning and the answer in different tags, so that an application can show only the answer.

Put your reasoning in <thinking> tags.
Put only the final decision in <answer> tags.

Ask the model to check its work

A second pass catches many errors.

After writing your solution, check it: substitute your answer back into the
original problem and confirm that every condition is met. If you find a
mistake, correct it before giving the final answer.

Break a large task into a chain of prompts

Some tasks are too big for one prompt. Split them into stages, each with its own prompt, and pass the output of one to the next.

  1. Extract the key facts from the report.
  2. Draft a summary from those facts.
  3. Review the summary against the original and list anything missing or wrong.
  4. Produce the final version.

Each stage is simpler, easier to test and easier to fix when it goes wrong.

Models with built-in reasoning

Many current models can reason internally before they answer, sometimes as a setting you switch on. With these models, high-level guidance such as “think carefully about this” often works as well as a detailed list of steps, and a rigid script can get in the way. Try the simple instruction first and add structure only if the results need it.

When not to use it

Reasoning makes answers longer, slower and more expensive. Skip it for simple lookups, short rewrites and classification tasks where the answer is obvious.

A caution

The reasoning a model writes is not a guaranteed account of how it reached its answer, and a clear-sounding argument can still end in a wrong conclusion. Treat reasoning as a way to improve answers and to spot errors, and keep checking results that matter.

Practice

Give a model a logic puzzle twice: once asking for the answer only, and once asking it to reason step by step. Compare the results.