Chain of Thought Prompting: Stop ChatGPT from Hallucinating
TL;DR — Want to stop AI from making things up? Learn Google's Chain of Thought technique to dramatically improve AI accuracy, complete with real-world examples and practical prompts.
Chain of Thought Prompting: Stop ChatGPT from Hallucinating
🤔 "GPT is Talking Nonsense Again..."
Hello! I'm an IT journalist in my 30s. Have you ever experienced this with ChatGPT?
You ask "Who won the 2023 Nobel Prize in Literature?" and it confidently gives the wrong answer. Or you ask it to solve a complex math problem, and it skips steps to arrive at a nonsensical result.
In the AI industry, we call this phenomenon 'Hallucination'. It's as if the AI is seeing things that aren't there.
But don't worry! The 'Chain of Thought (CoT)' technique I'll introduce today can dramatically improve AI accuracy. This technique, published by Google Research, caused a sensation in the AI community and has become an essential skill in prompt engineering.
AI gets confused sometimes... but there's a solution!
🧠 What is Chain of Thought (CoT)?
📖 Core Concept
Chain of Thought (CoT) is a prompting technique that guides AI to solve problems step by step.
It's like a math teacher saying "Don't just write the answer, show your work!"
🔍 Why Is It Effective?
Regular prompt: "What's 23 × 47?"
AI: "1081" (often wrong)
CoT prompt: "Calculate 23 × 47 step by step"
AI: "Step 1: 23 × 40 = 920
Step 2: 23 × 7 = 161
Step 3: 920 + 161 = 1081
Answer: 1081" (high accuracy)
Mistakes decrease when thinking step by step!
Step-by-step thinking leads to more accurate answers
📊 Regular Prompt vs CoT Prompt Comparison
Let's see the difference with real examples.
❌ Regular Prompt (Low Accuracy)
Question: "John had 5 apples.
Mary gave him 3 more, and Tom took 2 away.
Then John ate half of what he had.
How many apples are left?"
AI Answer: "3 apples." (Wrong!)
✅ CoT Prompt (High Accuracy)
Question: "Solve this problem step by step:
John had 5 apples.
Mary gave him 3 more, and Tom took 2 away.
Then John ate half of what he had.
How many apples are left?"
AI Answer:
"Step 1: John's initial apples = 5
Step 2: Mary gave him apples = 3
Current total = 5 + 3 = 8
Step 3: Tom took away apples = 2
Current total = 8 - 2 = 6
Step 4: Ate half = 6 ÷ 2 = 3 apples eaten
Step 5: Remaining apples = 6 - 3 = 3
Answer: 3 apples." (Correct!)
Same problem, different results based on approach
🎯 Zero-shot CoT: "Let's Think Step by Step"
🌟 The Simplest CoT Technique
A way to use CoT without complex examples.
Magic Phrases:
- "Let's think step by step"
- "Explain step by step"
- "Reason through this logically"
- "Show your thinking process"
💡 Zero-shot CoT Example
Prompt:
"Solve this logic problem. Think through it step by step:
All birds can fly.
Penguins are birds.
Therefore, penguins can fly.
What's wrong with this reasoning?"
AI Answer:
"Let me analyze this step by step:
Step 1: Identify premises
- Premise 1: "All birds can fly"
- Premise 2: "Penguins are birds"
- Conclusion: "Penguins can fly"
Step 2: Analyze logical structure
- This is a deductive syllogism
- The form appears valid
Step 3: Fact-check
- Problem with Premise 1: Not all birds can actually fly
- Ostriches, emus, kiwis also cannot fly
Step 4: Conclusion
The problem with this reasoning is that the first premise is false.
'All birds can fly' is an incorrect generalization."
One simple phrase improves AI's thinking ability
📚 Few-shot CoT: "Solve It Like This"
🎓 Learning Through Examples
Show AI examples of problem-solving approaches first.
📝 Few-shot CoT Template
Prompt:
"Solve the problem like this example:
[Example]
Problem: A store had 24 pencils. 3 more boxes of 12 pencils each arrived. How many total?
Solution:
Step 1: Original pencils = 24
Step 2: New boxes = 3
Step 3: Pencils per box = 12
Step 4: Total new pencils = 3 × 12 = 36
Step 5: Total pencils = 24 + 36 = 60
Answer: 60
[Actual Problem]
Problem: A library had 150 books. 5 boxes of 20 books each arrived,
and they threw away 30 old books. How many books total?"
AI Answer:
"Following the example format:
Step 1: Original books = 150
Step 2: New boxes = 5
Step 3: Books per box = 20
Step 4: Total new books = 5 × 20 = 100
Step 5: After addition = 150 + 100 = 250
Step 6: Books thrown away = 30
Step 7: Final book count = 250 - 30 = 220
Answer: 220"
AI learns patterns when shown examples
💼 5 Practical CoT Applications
1️⃣ Complex Business Planning
Prompt:
"Create a product launch plan. Explain step by step with considerations:
- Product: Health management app
- Budget: $50,000
- Timeline: 3 months"
AI provides systematic planning: Market research → Development → Marketing → Launch
2️⃣ Code Debugging
Prompt:
"Find the problem in this code. Analyze step by step:
[Paste code]
1. First understand the code's purpose
2. Analyze each function's role
3. Identify potential bug points
4. Provide solutions"
3️⃣ Investment Decisions
Prompt:
"Show the decision process for investing in this stock step by step:
- Company: ABC Corp
- Current price: $50
- P/E ratio: 15
- Recent performance: 20% YoY growth
Explain risks to consider at each step"
4️⃣ Learning Curriculum Design
Prompt:
"Create a 3-month plan to master React.
Explain weekly content and reasoning step by step.
Current level: Basic JavaScript"
5️⃣ Problem-Solving Strategy
Prompt:
"We're facing increasing customer churn.
Provide step-by-step approach from root cause analysis to solutions.
Include required data and actions at each step"
CoT shines in complex tasks
🎯 5 Tips for Effective CoT Usage
1. Request Clear Step Division
❌ "Explain this"
✅ "Explain in 5 steps"
2. Add Intermediate Verification Points
"Verify logical validity at each step as you proceed"
3. Require Specific Thinking Process
Request "calculations", "reasoning", "assumptions" to be explicit
4. Acknowledge Error Possibility
"Double-check if you might have missed anything"
5. Request Conclusion Summary
"Summarize the entire thinking process at the end"
Proper CoT usage determines results
🚀 Conclusion: You're Now a CoT Master!
Chain of Thought seems simple but is powerful.
Key Takeaways:
- "Let's think step by step" - Simplest Zero-shot CoT
- Provide examples - Improve accuracy with Few-shot CoT
- Step-by-step thinking - More effective for complex problems
- Intermediate verification - Check logic at each step
- Real-world application - Apply to all fields: work, learning, analysis
🔥 Start Today:
- Always add "step by step" for complex questions
- Use CoT for logical verification in important decisions
- Apply CoT to work automation prompts for higher accuracy
Next Post Preview: "GPT-4o vs Claude 3.5 Sonnet: Which AI Model is Best for You?"
Share in the comments how CoT has changed your AI conversations! 🎉
Tags: #ChainOfThought #CoT #PromptEngineering #ChatGPT #AIHallucination #PromptTechniques #AIAccuracy #ThinkingChain #ZeroShotCoT #FewShotCoT