Skip to content

Chapter 1.6: Chain-of-Thought Prompting

Chaining multiple prompts for specific tasks

In case a simple zero- or few-shot approach does not give the desired results, you can try to link different zero-shot prompts together and create a so-called "chain-of-thought" prompt (CoT), designed by Wei et al. (2026). This prompt starts with a few examples of what you want the AI to do. This works a little like giving the AI a small training in advance of your real question.

A simple example is given below, where we show the AI how to divide a math question in seperate chunks. This "trains" the AI how to approach the question you post at the end. In the answer you see the AI taking the same approach as specified in your prompt.

As prompt we will input two questions with the right answers, and then the question we want the answer to:

Q: There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there
will be 21 trees. How many trees did the grove workers plant today?
A: There are 15 trees originally. Then there were 21 trees after some more were planted. So there must have
been 21 - 15 = 6. The answer is 6.
Q: If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot?
A: There are originally 3 cars. 2 more cars arrive. 3 + 2 = 5. The answer is 5.

Q: Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?

The answer given by the model is:

A: Originally, Leah had 32 chocolates. Her sister had 42. So in total they had 32 + 42 = 74. After eating 35, they
had 74 - 35 = 39. The answer is 39.

Zero-shot COT Prompting

When you want to use the advantages of CoT prompting without the need to setup a detailed prompt with multiple examples, you can try the zero-shot CoT prompts. Designed by Kojima et al. (2022), in this case the main prompt is setup like a zero-shot prompt, but you add a line instructing the AI to think in steps. Examples of these lines are "Let's think step by step" or "Explain the steps taken to get to the answer".

Simply put, you end up with a prompt like this:

I went to the market and bought 10 apples. I gave 2 apples to the neighbor and 2 to the repairman. I then went and bought 5 more apples and ate 1. How many apples did I remain with?

Let's think step by step.

Sources

Based on materials from Prompt Engineering Guide.

⬅ Back to Structured output | ➡ Next: Tree of thought