liveBook · Manning

Chain-of-thought prompting

As explained in Build AI-Enhanced Web Apps

A prompting technique that guides a language model through a single sequential reasoning path.

Chain-of-thought prompting asks a language model to work through a problem in ordered steps rather than return only a final answer. In a web application, those steps can make an AI-generated answer easier to check. A visible explanation is not proof that the answer is correct. section 5.3 section 5.3.1

To draft and check a prompt:

  • State the task and the expected response format. Supply a formula or other task-specific guidance when useful. section 5.3.2
  • Optionally add a relevant worked example to show the expected method and level of detail. section 5.3.2
  • Explicitly request a step-by-step explanation, then test the prompt with varied inputs for consistent formatting and reasoning. section 5.3.2

Percentage calculation

A prompt asks, “Solve the following problem step-by-step: What is 25 percent of 80?” The response identifies the quantity, converts 25% to 0.25, and multiplies 0.25 by 80 to get 20. Check intermediate calculations and the final wording: the supplied response ends by calling the result “20 percent,” although the calculated quantity is 20. section 5.3.1

A clear-looking sequence can still contain a misread question, a faulty intermediate step, or a false conclusion. Ambiguous wording and overly narrow examples can also lead the model astray. Test more than whether it follows the requested format; check whether its steps answer the intended question. section 5.3.1 section 5.3.2

How Build AI-Enhanced Web Apps covers it

How deep it goes
Provides a prompt-construction procedure and worked calculation, but stops short of model internals or application code.
Examples
Works through 25% of 80 and sketches a circle-area prompt with a radius-three example.
What you can do after
Practice/perform it by drafting structured prompts with examples and step-by-step instructions, then testing varied inputs.
How it connects
Connects step-by-step explanations with few-shot learning, prompt engineering, and prompt testing.

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 Build AI-Enhanced Web Apps. The section links point to the parts of the book it draws on.