RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Fredoline Eruo
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /Prompt Engineering Fundamentals
  6. /Ch. 5
Prompt Engineering Fundamentals

05. Chain-of-Thought

Chapter 5 of 25 · 15 min
KEY INSIGHT

Chain-of-thought externalizes the model's reasoning process, allowing errors to surface before the final answer and enabling self-correction.

Chain-of-thought (CoT) prompting asks the model to show its reasoning before outputting the final answer. This works because language models produce tokens sequentially—what comes before the answer affects the answer.

Standard CoT: Add "Let's think step by step" or "Explain your reasoning" to the prompt.

Question: If a store has 47 apples and receives a shipment of 12 more, then sells 23 apples, how many apples remain?

Let's think step through this:
1. Store starts with 47 apples
2. Shipment adds 12 apples: 47 + 12 = 59
3. Sold 23 apples: 59 - 23 = 36

Answer: 36

The intermediate steps constrain the final answer. If the model makes an error in step 2, it appears visibly—and may self-correct in later steps.

CoT helps when:

  • The task has multiple steps
  • Errors are hard to detect in final output
  • You need to audit reasoning
  • The problem involves arithmetic or logical chains

CoT is less helpful for:

  • Single-step tasks
  • Tasks where intermediate steps are subjective
  • High-latency applications (CoT increases token count significantly)

Self-consistency CoT runs the same prompt multiple times and selects the most frequent final answer:

Question: [question]

Generate three different reasoning paths, then state the most confident answer.

Path 1: [reasoning]
Path 2: [reasoning]
Path 3: [reasoning]

Final answer: [most consistent result]

This reduces variance in complex reasoning tasks. Tested on GSM8K (grade school math), self-consistency improved accuracy from 74.4% to 83.4% on Llama-2-70B.

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

EXERCISE

Take a multi-step task (calculation, classification with multiple criteria, or multi-document analysis) and compare results with and without "Let's think step by step."

← Chapter 4
Few-Shot Prompting
Chapter 6 →
Step-by-Step Reasoning