liveBook · Manning

Chain-of-thought prompting

As explained in AI Agents and Applications

Chain-of-thought prompting is a technique that elicits or guides a model to produce or follow intermediate reasoning steps before a final answer.

Chain-of-thought (CoT) prompting guides a language model through intermediate reasoning steps before it gives an answer. It can combine few-shot examples with explanations of how each example is solved. section 2.5.6 section 2.7

Classifying a “strange” sequence

Define a sequence as strange if it has at least two odd numbers and their sum is divisible by 3. A worked example—5, 6, 7, 8, 20—lists 5 and 7 as odd, adds them to get 12, then concludes the sequence is strange. section 2.5.6

Build a CoT prompt by:

  • Including several examples and spelling out the logical steps for each. section 2.5.6
  • Asking for step-by-step reasoning or specifying the reasoning steps required. section 2.7
Table 2.2 In-context learning prompts
In-context learning technique
Explanation
Zero-shot learning
No example is provided in the prompt.
One-shot learning
One example is provided in the prompt.
Two-shot learning
Two examples are provided in the prompt.
Few-shot learning
A number of examples are provided in the prompt.
Chain of Thought (CoT)
A number of examples are provided in the prompt, and for each example, all the logical steps to achieve an objective are clearly explained.

Compare CoT with zero-, one-, two-, and few-shot prompting by how many examples they include and whether they explain the reasoning. section 2.5.6

How AI Agents and Applications covers it

How deep it goes
Defines CoT through worked few-shot examples and step-by-step instructions, without explaining model internals.
Examples
Uses a custom “strange” sequence rule and worked examples that count odd numbers and test their sum for divisibility by three.
What you can do after
Apply it by adding worked examples and step-by-step reasoning instructions to a prompt.
How it connects
Connects few-shot learning with prompt templates and programmatic prompt execution.

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 AI Agents and Applications. The section links point to the parts of the book it draws on.