TL;DR
Kojima and colleagues show that a large language model can be made to reason step by step by adding one sentence to the question: "Let's think step by step." No worked examples are needed. The same sentence, used with one fixed template for every task, raised accuracy sharply on arithmetic, symbolic and logic benchmarks. With the text-davinci-002 model, accuracy on the MultiArith benchmark went from 17.7 percent to 78.7 percent.
Builds on: Chain-of-Thought Prompting, Zero-Shot Learning, Autoregressive Model · Leads to: later reasoning-prompt work, which has no lesson yet
Why it mattered
The paper showed a very cheap way to get a chain of thought out of a language model. Before it, the step-by-step method needed a handful of hand-written reasoning examples for each task. After it, one line of text worked across tasks, which made it a common zero-shot baseline when papers compare prompting methods on reasoning benchmarks.
History
Through 2020 and 2021, large language models were known mostly for few-shot learning. GPT-3 could learn a task from a few examples in its prompt, with no weight updates. Researchers found that even very large models struggled on multi-step problems when asked for the answer directly.
In 2022, Wei et al. showed that examples with written reasoning fixed much of this. Kojima and colleagues asked a sharper question in May 2022, when the paper was posted to arXiv: whether the examples were needed at all. Their answer was no, for many tasks. The paper was later published at NeurIPS 2022.
It caught on because it was simple. One sentence, no data, and a fixed template. It also made clear that a large model holds more zero-shot ability than people had been using, which later prompting work built on.
The problem
Large language models are good at quick answers, but they fail on problems that need several steps. A model can recall a fact in one step. It often fails when the answer needs three or four calculations in a row, because it tries to produce the final number straight away.
The known fix was chain-of-thought prompting, from Wei et al. (2022). You show the model a few questions, each with a written-out chain of reasoning, and the model copies that style on the new question. That works well, but it has two costs. Someone must write the examples for each task, and the examples take up space in the prompt. The paper asks whether the examples are needed at all.
The reader needs three things from the prerequisites. A Language Model assigns probabilities to text, and it generates text by repeatedly picking a next token; that is the Autoregressive Model view. A zero-shot prompt gives the model only an instruction and no examples, as in Zero-Shot Learning. A chain of thought is the intermediate reasoning written before the answer, as in Chain-of-Thought Prompting.
How it works
Take one tiny problem. A shop has 3 boxes with 4 pens in each box. It sells 5 pens. How many pens are left? The answer is 12 minus 5, which is 7. The trace below is written by hand to show the method. It is not a recorded model output.
- Turn the question into a prompt. Put the question in the template "Q: [question]. A:" and add the trigger sentence after it. The prompt now ends with "A: Let's think step by step." Check: the model sees the question and the instruction to reason, and no example answers.
- Let the model write its reasoning. The model adds text one token at a time. At each step it takes the most probable next token, which is called greedy decoding. Suppose the text it writes is: "3 boxes of 4 pens is 12 pens. Selling 5 leaves 12 minus 5, which is 7 pens." Check: the reasoning is written out, and it contains the intermediate number 12 as well as the final number 7.
- Build a second prompt from the first. Join three pieces: the first prompt, the reasoning from step 2, and an answer trigger such as "Therefore, the answer (arabic numerals) is". The model is reading its own reasoning as part of the prompt. Check: the answer trigger asks for a number, so the model will give one.
- Read the answer. The model continues the text and outputs "7". A small parser keeps the first number that fits the answer format, so the answer is 7. Check: if the reasoning had ended with a different number, the parser would still read the one after the answer trigger.
flowchart LR Q["Question"] --> P1["Prompt 1: Q: ... A: Let's think step by step."] P1 --> R["Model writes reasoning z"] R --> P2["Prompt 2: prompt 1 + z + answer trigger"] P2 --> A["Model writes answer"] A --> X["Parse first number: 7"]
The whole method is two calls to the same model. The first call makes it reason. The second call makes it commit to an answer in a form the grader can read. A plain zero-shot prompt asks for the answer in one call, and the paper found that this often fails on multi-step problems.
Worked examples
Problem: 5 rows have 2 chairs each. 4 chairs are removed. How many chairs remain?
- Write the first prompt: "Q: 5 rows have 2 chairs each, and 4 chairs are removed. How many remain? A: Let's think step by step."
- Suppose the reasoning is: "5 rows of 2 is 10 chairs. Removing 4 leaves 10 minus 4, which is 6."
- Build the second prompt by adding the answer trigger "Therefore, the answer (arabic numerals) is".
- The model writes "6". The parser keeps 6.
- Check: 5 times 2 is 10, and 10 minus 4 is 6. The method got the right answer because the intermediate step 10 was written down before the subtraction.
Interpretation: the reasoning text is not decoration. The second prompt can only use numbers that the reasoning put on the page.
The paper's Table 1 compares Zero-shot-CoT with plain zero-shot prompting. The numbers below are the paper's headline results for the two benchmarks it reports most often.
- MultiArith: zero-shot 17.7 percent, Zero-shot-CoT 78.7 percent. The gain is 78.7 minus 17.7, which is 61.0 percentage points.
- The relative gain is 78.7 divided by 17.7, which is about 4.45. So the method more than quadruples the score.
- GSM8K: zero-shot 10.4 percent, Zero-shot-CoT 40.7 percent. The gain is 40.7 minus 10.4, which is 30.3 points.
- The relative gain is 40.7 divided by 10.4, which is about 3.91.
- Interpretation: the gain is largest on multi-step arithmetic (MultiArith and GSM8K). Read the size of the gain together with the baseline it starts from, because a strong baseline leaves less room to improve.
Problem: A baker makes 4 trays of 12 rolls. He sells 3 dozen rolls. How many rolls are left?
- The reasoning the model writes is: "4 trays of 12 is 48 rolls. 3 dozen is 36 rolls. 48 minus 36 is 12."
- The second prompt adds the answer trigger, and the model writes "12".
- Check each step. 4 times 12 is 48. A dozen is 12, so 3 dozen is 36. 48 minus 36 is 12.
- Interpretation: a human would also write these three lines, and the answer is only as reliable as those lines. If the model had written "4 trays of 12 is 42", the answer would be wrong even with a perfect second prompt.
Try it: A class has 3 groups of 8 students. Five students leave. How many remain?
Answer: 3 times 8 is 24. 24 minus 5 is 19. So 19 students remain.
The math
A language model defines a probability over token sequences. Writing the tokens of a text as , an autoregressive model factorises the probability of the whole text into next-token probabilities:
Zero-shot-CoT uses this model in two passes. Let be the question, the trigger sentence such as "Let's think step by step", and the answer trigger.
Step 1 in symbols
The first prompt is . The reasoning is built with greedy decoding. Each token is the most probable one given everything before it:
Here means the token with the largest probability. Greedy decoding is not the same as finding the most probable whole sequence, but it is cheap and it is what the paper uses throughout.
Step 2 in symbols
The second prompt joins the pieces: , where means text concatenation. The model then produces the answer text with greedy decoding, and the final prediction is . The parser keeps the first span of text that matches the answer format, such as the first number for arithmetic or the first capital letter for multiple choice.
Step 3 in symbols
Accuracy over test questions is the fraction of predictions that match the reference answer , where equals 1 when its condition holds and 0 otherwise:
Results
Main comparison (Table 1). Zero-shot-CoT beats zero-shot on the multi-step arithmetic benchmarks, most clearly on MultiArith (78.7 vs 17.7) and GSM8K (40.7 vs 10.4). The gains on the easier one-step arithmetic sets are much smaller, and the table gives the exact figures for each dataset. Check Table 1 for the rest of the numbers before quoting them.
Comparison with few-shot baselines (Table 2). Zero-shot-CoT reaches 78.7 on MultiArith and 40.7 on GSM8K. Standard few-shot prompting with eight examples reaches 33.8 and 15.6. Few-shot chain of thought with two examples reaches 84.8 and 41.3, so the zero-shot version is close to it without any examples.
Template robustness. Among 16 templates, the best instructive template gave the highest accuracy, and misleading templates did not help. The method depends on the wording.
Limits. The main experiments use one model family (text-davinci-002, an InstructGPT-series model) with greedy decoding. The method gave no clear gain on the commonsense tasks. The numbers depend on the answer-extraction step, so the extraction prompts in the appendix matter when reading any number.
Common mistakes and tradeoffs
It is tempting to think that the sentence makes the model smarter at everything. In fact it changes how the model spends its output. It writes more steps, and that helps when a problem has several steps. The paper reports no clear gain on the commonsense tasks, so the sentence is not a universal boost.
It is tempting to think that any encouraging sentence works. In fact the wording matters. The paper tried 16 templates in three groups: instructive, misleading and irrelevant. Instructive templates helped. "Let's think step by step" was the best of them. Misleading templates did not help.
It is tempting to think the first output is the answer. In fact the reasoning text often contains intermediate numbers that look like answers. That is why the paper uses a second prompt and a parser instead of reading the first output.
When to use it: you have many tasks, you have no examples, and you want one template that works across them. The method is also cheap to set up.
When not to use it: you have good hand-written examples for one task, because few-shot chain of thought can be more accurate. In Table 2, two examples of few-shot chain of thought reach 84.8 percent on MultiArith, compared with 78.7 for the zero-shot version. The method also costs more: it makes two calls, and the reasoning text makes each answer longer.
Alternatives: write a few examples per task (the Wei et al. approach), or use a stronger model with direct prompting.
Reading guide
- Introduction: needs Chain-of-Thought Prompting and the idea of few-shot learning from In-Context Learning.
- Background: assumes you know what a Language Model is and how prompting works.
- Method: needs Autoregressive Model and greedy decoding, which you can read as "pick the most probable next token".
- Experiments: arithmetic, commonsense and logic benchmarks. Read the main results table alongside the few-shot comparison table.
- Appendix: the exact answer-extraction prompts and the answer-cleansing rules. Read these before you trust any number in the main table.
Recap: a Language Model writes text one token at a time, so it can write its reasoning before its answer. A zero-shot prompt ending with "Let's think step by step" makes it do that with no examples, in two passes: one to write the reasoning, one to append an answer trigger and read the answer. The gains were large on multi-step arithmetic and small on commonsense tasks.
Next, read Chain-of-Thought Prompting Elicits Reasoning in Large Language Models for the few-shot version this paper was compared against, Language Models are Few-Shot Learners (GPT-3) for the few-shot ability it builds on, and Training Language Models to Follow Instructions with Human Feedback for the instruction-following models the paper's experiments used.
Check yourself
QuestionWhat exact sentence does the paper add to the question, and what does it make the model do?Show answer
QuestionOn MultiArith, zero-shot scores 17.7 percent and Zero-shot-CoT scores 78.7 percent. What is the gain in percentage points, and what is the relative gain to one decimal place?Show answer
QuestionWhy does the method call the model twice instead of once, and why does the second prompt include the model's own reasoning?Show answer
QuestionA team has 200 labelled examples for one task and wants the highest accuracy they can get from a language model. They also have a new task with no examples. Which method would you suggest for each, and why?Show answer
Sources
- Kojima, T., Gu, S. S., Reid, M., Matsuo, Y., and Iwasawa, Y. (2022). Large Language Models are Zero-Shot Reasoners. arXiv:2205.11916. https://arxiv.org/abs/2205.11916
- Kojima et al. (2022), NeurIPS 2022 proceedings version. https://doi.org/10.52202/068431-1613