Understand how prompting LLMs to show reasoning steps dramatically improves accuracy. Learn the difference between few-shot and zero-shot CoT, implement CoT in medical diagnosis, and understand why it works.
Original Paper
Wei, J., Wang, X., Schuurmans, D., Bosma, M., Ichter, B., Xia, F., Chi, E., Le, Q. V., & Zhou, D. (2022). "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models." In Advances in Neural Information Processing Systems (NeurIPS) 2022.
ArXiv: https://arxiv.org/abs/2201.11903
Venue: NeurIPS 2022
Authors: Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Brian Ichien, Fei Xia, Ed Chi, Quoc V. Le, Denny Zhou
What is Chain-of-Thought Prompting?
Chain-of-Thought (CoT) prompting is a technique where you ask an LLM to show its reasoning in intermediate steps before arriving at a final answer. Instead of jumping directly to the answer, the model explains its thinking.
"Prompting the model to generate a chain of thought — a series of short thoughts that lead to the final answer — significantly improves performance on complex reasoning tasks."
The hypothesis: By forcing intermediate outputs, we constrain the LLM to engage in valid reasoning rather than pattern-matching shortcuts.
The Paper's Key Findings (Figure 1 Recreation)
Figure 1 (Wei et al., 2022): Standard prompting vs Chain-of-Thought prompting
Few-Shot vs Zero-Shot CoT
Wei et al. showed two approaches:
| Type | How It Works | Example |
|---|---|---|
| Few-Shot CoT | Provide examples with reasoning steps, then ask question | Show 2-3 examples with step-by-step solutions, then ask new problem |
| Zero-Shot CoT | Just add "Let's think step by step" to any question | No examples needed; simple magic phrase works! |
Zero-Shot CoT: "Let's Think Step by Step"
One of the most surprising findings: simply adding "Let's think step by step" to a prompt dramatically improves accuracy, even without examples.
Medical Diagnosis Example
WITHOUT CoT prompt:
Prompt: "Patient: 65-year-old with chest pain, shortness of breath, and history of diabetes.
What is the most likely diagnosis?"
Response: "Likely diagnosis is a heart attack."
❌ Problem: No reasoning shown, could be wrong, hard to verify
WITH Zero-Shot CoT (just add one sentence):
Prompt: "Patient: 65-year-old with chest pain, shortness of breath, and history of diabetes.
What is the most likely diagnosis?
Let's think step by step:"
Response:
"Step 1: The patient has chest pain and shortness of breath.
These are classic symptoms of acute coronary syndrome.
Step 2: The patient has a history of diabetes.
This is a major risk factor for heart disease.
Step 3: Age is 65 (middle-aged).
This increases risk for MI.
Step 4: Considering all factors...
The most likely diagnosis is an acute myocardial infarction (heart attack).
However, we should also rule out:
- Pulmonary embolism (less likely without leg symptoms)
- Pneumonia (less likely without fever/cough)
- Aortic dissection (possible but less common)
Conclusion: Most likely = MI, but immediate ECG and troponin needed."
✓ Much better: reasoning is transparent, verifiable, more accurate
Why Chain-of-Thought Works
According to Wei et al. (2022), CoT works because:
- Decomposition: Breaking complex problems into steps makes them easier to solve
- Constrains reasoning: Intermediate outputs force valid reasoning, not shortcuts
- Detects errors: Readers can spot mistakes in reasoning steps
- Interpretability: We can see how the model arrived at conclusions
- Compositionality: Combining simpler steps is easier than solving all at once
Performance Improvements (From Paper)
Wei et al. showed massive improvements on complex reasoning benchmarks:
Results from Wei et al. (2022)
| Task (Benchmark) | Without CoT | With CoT | Improvement |
|---|---|---|---|
| Arithmetic (GSM8K) | 58.1% | 90.9% | +32.8% ⬆️ |
| Common sense (CSQA) | 88.9% | 94.6% | +5.7% ⬆️ |
| Symbol manipulation (SVAMP) | 79.3% | 94.3% | +15.0% ⬆️ |
When CoT Helps (and When It Doesn't)
| Task Type | CoT Helps? | Why |
|---|---|---|
| Multi-step math problems | ✓ YES - Huge improvement | Breaking into steps reveals structure |
| Reasoning/inference | ✓ YES - Moderate improvement | Makes logical steps explicit |
| Factual recall (who won the Nobel Prize?) | ✗ NO - Minimal help | Doesn't require reasoning, just memory |
| Classification (sentiment) | ✓ SOMETIMES - Minor improvement | Can help for edge cases, but simple tasks don't need it |
| Medical diagnosis | ✓ YES - Very helpful | Transparent reasoning critical for trust |
Implementation: CoT in Medical AI
# Simple CoT implementation with Claude API
from anthropic import Anthropic
client = Anthropic()
def medical_diagnosis_with_cot(symptoms, medical_history):
"""Diagnose using Chain-of-Thought reasoning"""
prompt = f"""
You are an experienced clinician analyzing a patient case.
Patient Information:
- Symptoms: {symptoms}
- Medical History: {medical_history}
Please diagnose this patient. Think step by step:
Step 1: Identify the key symptoms
Step 2: Consider differential diagnoses
Step 3: Evaluate risk factors
Step 4: Consider the most likely diagnosis
Step 5: What tests would you order?
Step 6: What is your final diagnosis and reasoning?
Take your time and reason through this carefully."""
response = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}]
)
return response.content[0].text
# Example usage
symptoms = "Fever 101.5F, cough for 3 days, sore throat, no difficulty breathing"
history = "65-year-old, diabetic, hypertensive, smoker"
diagnosis = medical_diagnosis_with_cot(symptoms, history)
print(diagnosis)
# Output will show step-by-step reasoning, making it auditable and trustworthy
Limitations and Failure Modes
• LLM lacks knowledge (reasoning steps don't help if you don't know the facts)
• Too many steps lead to drift (model forgets earlier reasoning)
• Complex multi-constraint problems confuse the step decomposition
• Domain requires expert knowledge steps can't express
Key Takeaways
- Chain-of-Thought prompting = ask LLM to show reasoning steps before answering
- Zero-Shot CoT = just add "Let's think step by step" (no examples needed!)
- Huge improvements on math and complex reasoning (30%+ accuracy gains in paper)
- Makes outputs auditable — you can verify the reasoning, not just the answer
- Critical for medical AI — transparency builds trust
- Doesn't help on simple tasks — only use CoT where multi-step reasoning is needed
Further Reading
Wei, J., Wang, X., Schuurmans, D., Bosma, M., Ichter, B., Xia, F., Chi, E., Le, Q. V., & Zhou, D. (2022). "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models." NeurIPS 2022.
Available on ArXiv: https://arxiv.org/abs/2201.11903
• Tree-of-Thought (Yao et al., 2023): Explore multiple reasoning paths
• Graph-of-Logic (Alotaibi et al., 2024): Structure reasoning as explicit graph
• Self-Consistency (Wang et al., 2022): Generate multiple CoT paths and take majority