liveBook · Manning

Chain-of-thought prompting

As explained in LLMs in Production

Chain-of-thought prompting encourages a language model to produce or use intermediate reasoning steps before giving a final answer.

Chain-of-thought prompting asks a language model to reason through intermediate steps before producing an answer. Adding “think step by step” can improve mathematical accuracy without providing examples, much like asking a student to show their work. The trade-off is longer output, higher latency, and a greater risk that the model continues after reaching the answer. section 7.1.3

Use chain-of-thought prompting with practical constraints in mind:

  • Treat zero-shot chain-of-thought as a baseline rather than a guarantee; prompt-only reasoning can remain inaccurate. section 12.2.5
  • Measure the prompt on a task-specific dataset instead of assuming that visible reasoning indicates correctness. section 12.2.5
  • Optimize the reasoning prompt with demonstrations when basic step-by-step prompting leaves substantial accuracy on the table. section 12.2.5

A DSPy math baseline and optimization

A zero-shot DSPy prompt instructs the model to think step by step while returning only the answer. On GSM8K, the Llama 3 baseline reaches 14.5%, compared with 1%–5% without prompting. DSPy’s ChainOfThought module, optimized with BootstrapFewShot, reaches 74.5% on the evaluation shown. section 12.2.5

How LLMs in Production covers it

How deep it goes
Explains zero-shot prompting, response trade-offs, evaluation, and DSPy optimization, but does not detail model-internal reasoning.
Examples
Demonstrates “think step by step,” GSM8K math questions, a DSPy QASignature, and optimized Llama 3 results.
What it assumes
Assumes familiarity with prompts and language models while teaching zero-shot reasoning without requiring example demonstrations.
What you can do after
Apply it via DSPy to construct, evaluate, and optimize reasoning prompts for mathematical question answering.
How it connects
Connects zero-shot prompting, few-shot prompting, prompt engineering, DSPy, and hallucination reduction through evaluation.

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 LLMs in Production. The section links point to the parts of the book it draws on.