liveBook · Manning

Chain-of-thought prompting

As explained in Building Reliable AI Systems

Chain-of-thought prompting is a prompting method that elicits explicit intermediate reasoning steps from a model.

Chain-of-thought (CoT) prompting gives a model intermediate reasoning steps to follow on a multistep task. Rather than showing only a question and answer, a prompt demonstrates how to reach the answer. The resulting steps can make the model’s logic easier to inspect—a useful first line of defense when a confidently wrong answer would be costly. section 2.7.3 section 1.4.1

Two practical forms are:

  • Few-shot CoT: include a worked example with intermediate steps and a final answer, then present a new problem in the same format. Even one demonstration can establish the pattern. section 2.7.3
  • Zero-shot CoT: add an instruction such as “Let’s think step by step” without supplying a worked example. More directed wording can ask the model to identify key elements first, then explain its reasoning. section 2.7.3 section 2.7.4

Check the arithmetic, not just the answer

For “4, 8, 9, 15, 12, 2, 1,” a worked answer identifies the odd numbers, adds 9 + 15 + 1 = 25, and concludes that their sum is not even. The same pattern can then be applied to a new list. In customer support, a prompt can similarly state the rule—an order number ending in an odd digit qualifies for a discount—before checking that Order #17403 ends in 3. section 2.7.3 section 2.7.4

Figure 2.1 Few-shot, few-shot CoT, zero-shot, and zero-shot CoT prompting compared (Kojima et al.)
figure

Compare few-shot and zero-shot prompts with their chain-of-thought variants to see where intermediate reasoning enters the prompt. section 2.7.3

Use CoT where the target model benefits from explicit steps, and test it on the actual task. Reasoning models such as the GPT-5 series, o3, or Claude with extended thinking may not need explicit CoT instructions; standard nonreasoning models often benefit on multistep tasks. Visible steps improve inspectability, but they are not a substitute for checking whether the answer is correct. section 2.7.4 section 1.4.1

How Building Reliable AI Systems covers it

How deep it goes
Shows worked and zero-shot prompt patterns plus model-specific caveats, without detailing model internals.
Examples
Uses odd-number sums, an apple-counting problem, and an order-number discount rule to illustrate intermediate steps.
What it assumes
Assumes familiarity with prompting an LLM, while illustrating intermediate reasoning through simple arithmetic and customer-support rules.
What you can do after
Practice/perform it by adding worked reasoning or a step-by-step instruction to prompts and testing results on the target model.
How it connects
Connects few-shot and zero-shot prompting to prompt engineering, hallucination reduction, and self-consistency.

Also explained in

Compare how 18 books explain chain-of-thought prompting →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Reliable AI Systems. The section links point to the parts of the book it draws on.