Chain-of-Thought (CoT)

Unlock complex reasoning in LLMs by instructing them to think step-by-step before answering.

Chain-of-Thought (CoT) Prompting

Chain-of-Thought (CoT) prompting is a technique that dramatically improves an LLM's ability to handle complex reasoning tasks. The core idea is to instruct the model to not just give the final answer, but to "think step-by-step" and explain its reasoning process first.

By breaking down a multi-step problem into intermediate steps, the model is far more likely to arrive at the correct solution. It's like asking a student to show their work on a math problem instead of just writing down the answer.

Why It's a Game-Changer

For simple tasks, a direct answer is fine. But for anything requiring logic, calculation, or multi-step inference, CoT is essential. Without it, models often rush to a conclusion and make simple mistakes. With CoT, they follow a more reliable and logical path.

This technique unlocks the ability for LLMs to solve:

  • Arithmetic and math word problems

  • Logic puzzles and riddles

  • Scientific reasoning questions

  • Common sense reasoning challenges

How to Trigger CoT

The simplest way to enable Chain-of-Thought reasoning is by adding a simple phrase to the end of your prompt, like:

  • Let's think step by step.

  • Take a deep breath and work on this problem step-by-step.

  • Explain your reasoning before giving the final answer.

Example: Solving a Math Problem

Let's see the difference CoT makes with a classic word problem.

Standard (Zero-Shot) Prompt

Prompt: Q: A farmer has 15 apples. He buys 2 more boxes of apples, and each box contains 12 apples. He then gives away 7 apples. How many apples does the farmer have now?

Typical (Incorrect) Output: A: The farmer has 20 apples.

The model often makes a mistake, like adding 15 + 2 + 12 - 7, and gets the wrong answer.

CoT Prompt

Prompt: Q: A farmer has 15 apples. He buys 2 more boxes of apples, and each box contains 12 apples. He then gives away 7 apples. How many apples does the farmer have now?

Let's think step by step.

Correct CoT Output: A: Okay, let's break this down. 1. The farmer starts with 15 apples. 2. He buys 2 boxes of apples, and each box has 12 apples. So, he gets 2 * 12 = 24 new apples. 3. The total number of apples he has now is 15 + 24 = 39 apples. 4. He then gives away 7 apples. So, 39 - 7 = 32 apples. The farmer now has 32 apples.

By forcing the model to articulate its reasoning, it follows the correct path and arrives at the right answer.

Last updated