AI engineering paper · 2022

Chain-of-thought prompting

Wei, Wang, Schuurmans, Bosma, Ichter, Xia, Chi, Le and Zhou · NeurIPS 2022

Why writing out steps before the answer lifted a model’s maths score from 18% to 57%, and what has changed since.

In the paper’s example, the same model says 27 without steps and 9 with them. On a set of school maths problems, the largest model’s score rose from 17.9% to 56.9%.

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?

The design choices

The authors changed one thing. Each example in the prompt is a triple: the question, a chain of thought, and the answer. A chain of thought is a short series of plain-language steps that lead to the answer. The new question comes last, and the model is left to continue. This is .

Our biggest sale ever · Black Friday

Flat 50% Off

Pro

Continue reading

Unlock every course, now and later

  • System Design, live
  • AI Engineering, live
  • Data Engineering, live
  • Machine Learning Engineering, live
  • Inference Engineering, coming soon
  • AI Research, coming soon
  • Performance Engineering, coming soon
  • Agent & Harness Engineering, coming soon
  • LLM Fine-tuning, coming soon
  • LLM Pre-training & Post-training, coming soon
  • Reinforcement Learning, coming soon
  • AI Infrastructure & Platform Engineering, coming soon
  • AI Evaluation & Safety, coming soon
  • Forward Deployed Engineering, coming soon
  • Cloud Computing, coming soon
  • DevOps, coming soon

50% off · Annual and Lifetime

BLACKFRIDAY50Applied at checkout

Choose a plan

About the paper

Chain-of-Thought Prompting Elicits Reasoning in Large Language Models by Wei, Wang, Schuurmans, Bosma, Ichter, Xia, Chi, Le and Zhou, NeurIPS 2022.

Read the original paper

More AI engineering papers

All papers