Chain-of-Thought Prompting

📌 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.

Simple flat illustration showing a robot breaking a complex problem into 3 steps before answering
Simple flat illustration showing a robot breaking a complex problem into 3 steps before answering

📌 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!

Comic illustration showing a robot generating a scratchpad of steps before answering
Comic illustration showing a robot generating a scratchpad of steps before answering

📌 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.
Comic illustration comparing NO EXAMPLES vs WITH EXAMPLES for a robot AI
Comic illustration comparing NO EXAMPLES vs WITH EXAMPLES for a robot AI

📌 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.

Simple flat illustration showing a robot exploring a branching tree of thoughts, crossing out bad paths and picking the best one
Simple flat illustration showing a robot exploring a branching tree of thoughts, crossing out bad paths and picking the best one

📌 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.

Comic illustration showing 5 robots voting on an answer, with a majority vote box
Comic illustration showing 5 robots voting on an answer, with a majority vote box

📌 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!

Comic illustration comparing complex logic which needs CoT vs simple facts which do not
Comic illustration comparing complex logic which needs CoT vs simple facts which do not