Chain-of-Thought Prompting
Improve LLM reasoning by instructing the model to break down complex problems into intermediate steps before giving a final answer.
Overview
Chain-of-Thought (CoT) prompting is a technique that dramatically improves LLM performance on reasoning tasks by asking the model to show its work — generating intermediate reasoning steps before arriving at a final answer.
Rather than asking for a direct answer, you either provide few-shot examples with step-by-step reasoning, or simply append “Let’s think step by step” (zero-shot CoT).
When to Use
- Math & logic problems requiring multi-step reasoning
- Complex Q&A where the answer depends on combining multiple facts
- Code generation requiring algorithm design
- Decision-making with multiple factors to weigh
- Any task where jumping to the answer causes errors
Architecture
flowchart TB
Q[Complex Question] --> CoT[CoT Prompt]
CoT --> S1[Step 1: Identify key facts]
S1 --> S2[Step 2: Apply reasoning]
S2 --> S3[Step 3: Draw conclusion]
S3 --> A[Final Answer]
style S1 fill:#1c2128,stroke:#58a6ff,color:#e6edf3
style S2 fill:#1c2128,stroke:#58a6ff,color:#e6edf3
style S3 fill:#1c2128,stroke:#58a6ff,color:#e6edf3
How It Works
Zero-Shot CoT
Simply append “Let’s think step by step.” to your prompt. Surprisingly effective!
Few-Shot CoT
Provide examples of problems solved step-by-step, then pose the new problem.
The Key Insight
The reasoning chain keeps the model on track as it “thinks through” the problem. Without CoT, the model must compress all reasoning into the token prediction — with CoT, each step informs the next.
Implementation
Gotchas & Best Practices
On simple factual lookups or straightforward tasks, CoT adds unnecessary tokens and can actually reduce accuracy. Use it only for tasks that benefit from reasoning.
The model’s chain-of-thought may not reflect its actual reasoning process. The steps might look correct but be post-hoc rationalization. Don’t treat CoT as proof of correctness.
Generate multiple CoT paths and take a majority vote on the final answer. This significantly improves accuracy on math and logic tasks (see Self-Consistency pattern).
Instead of “think step by step,” try “First identify the given information, then set up the equation, then solve.” More specific instructions yield more structured reasoning.
Variations
- Zero-Shot CoT — “Let’s think step by step”
- Few-Shot CoT — Provide worked examples
- Self-Consistency — Multiple CoT paths + majority vote
- Tree-of-Thought — Explore branching reasoning paths
- Least-to-Most — Decompose into subproblems, solve incrementally