AI engineering paper · 2022
Chain-of-thought prompting
Why writing out steps before the answer lifted a model’s maths score from 18% to 57%, and what has changed since.
You’ll learn to
- Explain how a chain-of-thought prompt differs from an ordinary prompt with worked examples, using the paper’s own questions.
- Describe why the gain appears only in very large models, and which tests show the written steps are what matters.
- Compare the paper’s hand-written examples with later options: a one-line instruction, many chains with a vote, and models trained to reason.
- Decide when asking for steps still helps and when it only adds cost.
The idea in short
A language model writes text one small piece at a time. Asked a maths question that needs several steps, it often has to jump straight to the answer, and it often gets it wrong. Wei and colleagues changed only the prompt, the text you give the model. Each worked example in the prompt showed its steps before its answer, so the model wrote its own steps too.
With eight such examples, a model with 540 billion parameters, the adjustable numbers it learns in training, scored 56.9% on school maths word problems, up from 17.9% without steps. No extra training was needed. The effect needs a very large model, and later work showed that the steps are not always an honest account of how the model reached its answer.
The problem
A is a program that has learned, from huge amounts of text, to predict what comes next. It works in pieces called : a word, or part of a word. You give it a , the text it should continue, and it writes the reply one token at a time.
By 2021, big models could do many tasks from a prompt alone. The usual method was : put a handful of worked examples in the prompt, each one a question followed by its answer, then add your real question. The model copies the pattern.
Researchers compare models on a : a fixed set of questions with known answers, scored as the share answered correctly. This paper uses several, and each is explained where it first appears. The main one is GSM8K, a set of school maths word problems that need a few steps each, such as “the cafeteria had 23 apples, used 20 and bought 6 more; how many now?”
The authors saw a gap. Bigger models had improved on many tasks, but making a model bigger had not fixed three kinds of problem: maths word problems, questions that need everyday knowledge, and small rule-following puzzles with symbols. Two earlier approaches both had limits:
- Train the model on written-out solutions. This is : more training on examples of the task. It needs a large set of step-by-step solutions that people wrote by hand, for every new task.
- Show only questions and answers in the prompt. This is cheap, but on these three kinds of problem the scores stayed low even for the largest models.
The best result on GSM8K at the time was 55%. It came from fine-tuning GPT-3 on a large set of solutions and adding a , a second model that scores several candidate solutions so the best one can be picked.
So the question the paper asks is: can a model get the benefit of writing out steps using only the prompt, with no training at all?