📌 What Chain-of-Thought (CoT) prompting is and why it works
Normally, when you ask a Large Language Model a complex question, it tries to spit out the final answer immediately. For hard logic or math problems, this often leads to the wrong answer because the AI didn't "think" through the steps.
Chain-of-Thought (CoT) prompting is a technique where you force the AI to break the problem down and explain its reasoning step-by-step before giving the final answer.

📌 How adding 'think step by step' changes model behaviour
The simplest way to use CoT is called Zero-Shot CoT. You simply append the magic words: "Let's think step by step." to the end of your prompt.
When the AI sees this phrase, it triggers a different generation pattern. Instead of generating the final answer tokens, it starts generating reasoning tokens ("First, I need to...", "Next..."). Because LLMs predict the next word based on all previous words, this "scratchpad" of reasoning helps it predict the correct final answer!

📌 Zero-shot CoT vs Few-shot CoT: differences and when to use each
There are two main ways to use CoT:
- Zero-Shot CoT: Just adding "think step by step" without giving examples. Best for general logic and math.
- Few-Shot CoT: Providing a few examples of questions and fully reasoned-out answers in your prompt. Best for highly specific, domain-expert logic where you need the AI to follow a strict reasoning format.

📌 Tree-of-Thought: exploring multiple reasoning paths at once
Chain-of-Thought is linear (one path). But what if that path hits a dead end? Enter Tree-of-Thoughts (ToT).
In ToT, the AI generates multiple possible next steps (branches), evaluates each one, and discards the bad ones while continuing down the good ones—just like a human playing chess and thinking 3 moves ahead.

📌 Self-consistency: running CoT multiple times and voting on answers
Another powerful upgrade to CoT is Self-Consistency. This means you run the exact same CoT prompt 5 or 10 times. Since LLMs have some randomness (temperature), they might take slightly different reasoning paths each time.
At the end, you look at all the final answers and take a majority vote. If 8 out of 10 runs arrived at the answer "42", you can be highly confident it's correct.

📌 When CoT helps and when it is not needed
When to use CoT: Complex math, logic puzzles, multi-step planning, coding, and situations where you need to trace how the AI got its answer.
When NOT to use CoT: Simple factual recall ("What is the capital of France?"), translation, summarization, or tasks where speed is more important than deep reasoning. CoT uses more tokens and takes longer to generate!

Quick Knowledge Check
Test what you just learned about Chain-of-Thought Prompting
Question 1 of 3
Which statement best describes What Chain-of-Thought (CoT) prompting is and why it works?
Question 2 of 3
When working with How adding 'think step by step' changes model behaviour, what is the most important thing to remember?
Question 3 of 3
What happens when you correctly apply Zero-shot CoT vs few-shot CoT: differences and when to use each in your code?
Loading results...