Chain-of-thought reasoning
Lesson 5 of 8 · 25 min · part of the AI Prompt Engineer certification
Because a model generates one token at a time, it has no hidden "scratch pad" unless you give it one. Asking for the final answer immediately forces it to commit before doing the work.
Chain-of-thought (CoT) prompting asks the model to write out intermediate reasoning steps before the answer. Each generated step becomes context for the next, which dramatically improves accuracy on math, logic and multi-step problems.
Interactive exercise: Direct answer vs. step-by-step
- Zero-shot CoT: simply add "Think step by step before answering."
- Few-shot CoT: show examples that include the reasoning, not just the answer.
- Structured CoT: ask for reasoning inside
<thinking>tags and the final answer inside<answer>tags, so your code can extract just the answer. - Self-consistency: sample several reasoning paths at a higher temperature and take the majority answer.
- Prompt chaining: split a big task into sequential prompts (extract → analyze → write), passing each output into the next.
Interactive exercise: Chain these prompts