All papersFoundations Classic
Show the steps and the model reasons better Paper: Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Brian Ichter, Fei Xia, Ed H. Chi, Quoc V. Le, Denny Zhou · NeurIPS 2022 · Posted 28 Jan 2022 · 16 min read · arXiv 2201.11903
1 The problem Show in original Making a model bigger did not fix hard reasoning . Plain few-shot prompts show only questions and answers. Models guess the answer in one jump. Math, commonsense and symbol tasks stayed hard. 57% of GSM8K math problems solved by PaLM 540B with chain of thought , versus 18% without.
2 What they tested Show in original They put worked steps in the few-shot examples. They tried 5 models on arithmetic , commonsense and symbol tasks. They turned parts off to see what matters. They had 3 annotators write their own chains. 3 What they found Show in original Steps help only at large scale, around 100B parameters. PaLM 540B set a new best on GSM8K , SVAMP and MAWPS. Hard problems gain the most. Plain equations or extra compute alone did not help. In a chart Chain of thought lifts PaLM 540B past finetuned models on GSM8K From Figure 2 0 25 50 75 100 GSM8K solve rate (%) Finetuned GPT-3 175B 33% Prior best 55% PaLM 540B, standard 18% PaLM 540B, chain of thought 57%
Hover, tap or focus a bar to read its exact value.
Show as table Setup Solve rate (%) Finetuned GPT-3 175B 33 Prior best 55 PaLM 540B, standard 18 PaLM 540B, chain of thought 57
5 Watch out Show in original A chain looks like thinking. The paper says it may not be real reasoning. The reasoning path can be wrong , even when the answer is right. Small models do worse with chains. Large models cost more to serve. Jump to A The abstract1 Introduction2 Chain-of-thought prompting3.1 Arithmetic: experimental setup3.2 Arithmetic: results3.3 Ablation study3.4 Robustness of chain of thought4 Commonsense reasoning5 Symbolic reasoning6 Discussion and limits7 Related work8 ConclusionsApp A Appendix A: frequently asked questionsApp B Appendix B: all experimental resultsApp C Appendix C: extended related workApp D Appendix D: additional analysisApp E Appendix E: additional detailsApp F Appendix F to H: examples and promptsW Words to knowEvery detail from the paper Cards follow the paper's own order. Dotted words link to Words to know. Numbers match the paper.
A The abstract Show in original The idea A chain of thought is a series of reasoning steps written in plain words. The authors show it helps large language models on hard reasoning tasks. The method is simple: put a few worked examples in the Prompt . The result They test 3 large models on math, commonsense and symbol tasks. Prompting PaLM 540B with just 8 worked examples sets a new best on GSM8K. It beats even finetuned GPT-3 with a verifier. 1 Introduction Show in original The gap Bigger models gain many things. But size alone did not fix arithmetic, commonsense or symbolic reasoning. Two ideas Idea 1: write the reasoning in natural language before the answer.Earlier work trained models from scratch or finetuned them to do this. Idea 2: few-shot prompting. Show a few input and output examples in the prompt.It needs no new model per task. Their limits Rationales are costly to write for a large training set. Plain few-shot prompting works poorly on reasoning tasks. It does not improve much as models grow. The combination This paper joins both ideas. Each example in the prompt has three parts: input, chain of thought, output. The authors call this chain-of-thought prompting . Why prompt-only matters Figure 2: PaLM 540B with chain of thought sets a new best on GSM8K. GSM8K is a set of math word problems. A prompt-only method needs no large training set. One model checkpoint can do many tasks. 2 Chain-of-thought prompting Show in original The goal People break a hard problem into steps. Example: "After Jane gives 2 flowers to her mom she has 10...". The chain ends: "so the answer is 7". The goal is to make models write a similar chain of thought. Large models can do this if the examples show it. Standard prompting versus chain of thought From Figure 1 Example: question, then answer only Model answers new question: 27 Example: question, steps, answer CoT Model writes steps Model answers 9: correct The cafeteria question: 23 apples, use 20, buy 6. The right answer is 9.
The name They call it a chain of thought, not a solution. It copies how a person thinks toward an answer. Solutions normally come after the final answer. Four good properties, 1 and 2 1. It splits a multi-step problem into steps.More steps means the model can spend more computation. 2. It gives a window into how the model got the answer.You can debug where the reasoning went wrong. Fully explaining the model's computation stays an open question. Properties 3 and 4 3. It works for math, commonsense and symbol tasks.It may apply to any task a person can solve with language. 4. It needs no training.Add chain-of-thought examples to few-shot prompts of a ready model. Where tests come next Section 3: arithmetic. Section 4: commonsense. Section 5: symbolic. 3.1 Arithmetic: experimental setup Show in original Why arithmetic Math word problems are simple for people. Language models often struggle with them. With 540B parameters, chain of thought matches task-specific finetuned models on several tasks. Five benchmarks 1. GSM8K: math word problems.2. SVAMP: problems with varying structures.3. ASDiv: diverse math word problems.4. AQuA: algebraic word problems.5. MAWPS: a standard benchmark.The two prompts Standard prompting: input and output pairs. The model answers directly.Chain of thought: each example also has its reasoning chain.Most datasets have only a test split. So the authors wrote 8 examples with chains by hand. These examples were not tuned. AQuA is multiple choice, so it uses 4 . Five models GPT-3: text-ada-001, text-babbage-001, text-curie-001, text-davinci-002.These are probably 350M , 1.3B , 6.7B and 175B parameters. LaMDA: 422M, 2B, 8B, 68B and 137B.PaLM: 8B, 62B and 540B.UL2: 20B. Codex: code-davinci-002.How they run it They use greedy decoding . Later work shows majority voting over many samples can do better. LaMDA results average 5 random orders of the examples. Other models use one order, to save compute. 3.2 Arithmetic: results Show in original Takeaway 1 1. Emergent with scale. Chain of thought does not help small models.It helps only around 100B parameters. Small models wrote fluent but illogical chains. That scored lower than standard prompting. Chains of thought only pay off at 68B and above, on LaMDA From Table 2 LaMDA PaLM
Standard Chain of thought
0 5 10 15 20 GSM8K solve rate (%) 420M 2.6% 0.4% 2B 3.6% 1.9% 8B 3.2% 1.6% 68B 5.7% 8.2% 137B 6.5% 14.3%
Hover, tap or focus a bar to read its exact value.
Show as table Model size Standard (%) Chain of thought (%) 420M 2.6 0.4 2B 3.6 1.9 8B 3.2 1.6 68B 5.7 8.2 137B 6.5 14.3
Takeaway 2 2. Bigger gains on harder problems. GSM8K has the lowest baseline of the five. Performance more than doubled for the largest GPT and PaLM models. SingleOp, the easiest MAWPS subset, saw small or negative change. Takeaway 3 3. It rivals the prior best. PaLM 540B sets a new best on GSM8K, SVAMP and MAWPS. Standard prompting already passed the prior best for SVAMP. On AQuA and ASDiv, PaLM is within 2% of the best. Do the chains make sense? Error analysis Right answers They read 50 random LaMDA 137B answers that were right on GSM8K. All chains were correct except two, which got lucky. Wrong answers They read 50 random wrong answers. 46% of chains were almost right.Small slips: a calculator error, a symbol mapping error, or one missing step. The other 54% had major errors in understanding or coherence. Why scale helps They checked PaLM 62B errors and whether 540B fixed them. Scaling to 540B fixes a large share of missing-step and understanding errors. 3.3 Ablation study Show in original The question An ablation turns off one part to see what matters. They test three variants on LaMDA 137B and PaLM 540B (Figure 5). Variant 1 Equation only: the model writes only the math equation.It does not help much on GSM8K. The questions are too hard to turn into an equation directly. It helps on datasets with one or two steps. Variant 2 Variable compute only: the model writes dots, one per equation character.It scores about the same as the baseline. So extra computation alone is not the reason it works. Writing steps in natural language matters. Variant 3 Chain of thought after the answer: the chain comes after the answer.It scores about the same as the baseline. So chain of thought is not just a way to recall knowledge. The step order matters. Only a real chain of thought lifts GSM8K; the ablations do not From Table 6 0 4 8 12 16 GSM8K solve rate, LaMDA 137B Standard 6.5% Equation only 5.4% Variable compute only 6.4% Reasoning after answer 6.1% Chain of thought 14.3%
Hover, tap or focus a bar to read its exact value.
Show as table Prompt Solve rate (%) Standard 6.5 Equation only 5.4 Variable compute only 6.4 Reasoning after answer 6.1 Chain of thought 14.3
3.4 Robustness of chain of thought Show in original Why check Prompts can be fragile. Changing example order moved GPT-3 on SST-2 from 54.3% to 93.4% . Different writers Annotator A wrote the main chains. Annotators B and C, two other authors, wrote their own. Annotator A also wrote a more concise version. Result Results vary, as expected. All sets beat standard prompting by a large margin. So chain of thought does not depend on one writing style. Other exemplars They also sampled 3 sets of 8 examples from the GSM8K training set. Those came from crowd workers with no machine learning background. They scored about the same as the hand-written chains. Chain of thought also held up across example orders and example counts (Appendix A.2). 4 Commonsense reasoning Show in original Why it fits Chain of thought is made of language. So it also applies to commonsense reasoning about physical and human things. Five benchmarks CSQA: commonsense questions about the world.StrategyQA: the model must infer a multi-step strategy.Date Understanding: infer a date from context.Sports Understanding: is a sports sentence plausible?SayCan: map an instruction to robot actions.Prompts Same setup as before. CSQA and StrategyQA: random training examples with hand-written chains. The two BIG-bench tasks have no training set. So they use the first 10 examples as the few-shot examples. SayCan uses 6 training examples with hand-written chains. Results Scale helped standard prompting on all tasks. Chain of thought added more, most for PaLM 540B. PaLM 540B beat the prior best on StrategyQA: 75.6% versus 69.4% . It beat an unaided sports enthusiast on sports understanding: 95.4% versus 84% . The gain on CSQA was minimal. Task Standard (%) Chain of thought (%) CSQA 78.1 79.9 StrategyQA 68.6 77.8 Date understanding 49.0 65.3 Sports understanding 80.5 95.4 SayCan 80.8 91.7
PaLM 540B on commonsense tasks
5 Symbolic reasoning Show in original The aim Symbol tasks are easy for people and hard for models. Chain of thought also helps with longer inputs than the examples show. Two toy tasks Last letter concatenation: join the last letters of a name's words. "Amy Brown" gives "yn".Coin flip: people flip or skip a coin. Is it still heads up?Names come from the top one thousand first and last names. The length test From Section 5 Examples show 2-word names In-domain test: 2 words Out-of-domain test: 3 and 4 words Chain of thought still scales Coin flip works the same way, with more flips.
In-domain results PaLM 540B with chain of thought nears 100% in-domain. Standard prompting already solves coin flip for PaLM 540B, but not for LaMDA 137B. These are toy tasks. The chains give the full solution pattern. Yet small models still fail. The skill appears at about 100B parameters. Out-of-domain results Standard prompting fails on both out-of-domain tasks. With chain of thought, results rise with scale, but stay below in-domain. Task Standard (%) Chain of thought (%) Letter concat, 2 words 7.6 99.4 Letter concat, 3 words (OOD) 0.2 94.8 Letter concat, 4 words (OOD) 0.0 63.0 Coin flip, 2 98.1 100.0 Coin flip, 3 (OOD) 49.3 98.6 Coin flip, 4 (OOD) 54.8 90.2
PaLM 540B on symbolic tasks
OOD means out of domain: longer than the examples.
6 Discussion and limits Show in original What they showed Chain of thought raises arithmetic scores by a large margin. It is robust to writers, examples and models. It suits commonsense tasks because it is made of language. It helps symbol tasks reach longer inputs. No model was finetuned for this paper. The bigger point Where standard prompting is flat with scale, chain of thought rises sharply. Standard prompting gives only a lower bound on what models can do. Open questions: how far will scale push reasoning? What other prompts could expand what models solve? Four limits 1. A chain imitates thinking. That does not prove the network reasons.2. Writing chains costs little for few-shot prompts.It could cost too much for finetuning. Synthetic data may help. 3. The reasoning path may be wrong. Correct and incorrect paths both occur.4. It only emerges at large scale, so serving it is costly.8 Conclusions Show in original Takeaway Chain-of-thought prompting is simple and broadly useful. Reasoning is an emergent property of model scale. It lets large models do tasks that had flat scaling curves. The authors hope for more language-based reasoning work. App A Appendix A: frequently asked questions Show in original A.1 Why does scale help? Chain of thought hurts most models under 10B parameters. They read 45 errors from PaLM 62B. 20 were semantic understanding errors. 18 were one step missing. 7 were other.Scaling to 540B fixed 6 , 12 and 4 of them. Small models also fail at symbol mapping and arithmetic. They often give no parseable final answer. A.2 Prompt engineering Annotators got no style rules. Chain of thought won with all of them. Order of examples had small effect, except for coin flip. Gains held with varying numbers of examples, on five datasets. Going from 8 to 16 standard examples did not close the gap. It did not help CSQA and StrategyQA for GPT-3. Coin flip ranged from 99.6% to 71.4% across annotators. Prompt writing still matters. A.3 Will it help my task? It helps most when three things hold. The task needs several reasoning steps. The model is large. The scaling curve is flat. Gains are small on easy MAWPS subsets, where PaLM 540B scores 90% or more. A.4 Why equation only is not enough Equation only helps on one-step and two-step sets, such as SVAMP. On GSM8K the question is too hard to turn into one equation. Example: the ping pong question gives 6 with an equation and 9 with a chain. App B Appendix B: all experimental results Show in original Calculator An external calculator fixes arithmetic slips in the chains. It boosts chain of thought on most tasks. Model Standard Chain of thought Chain of thought + calculator UL2 20B 4.1 4.4 6.9 LaMDA 137B 6.5 14.3 17.8 GPT-3 175B 15.6 46.9 49.6 Codex 19.7 63.1 65.4 PaLM 540B 17.9 56.9 58.6
GSM8K by model (Table 1)
The prior best is 55 (finetuning).
The other tables Table 2: all model sizes on all five math sets. Table 3: the four MAWPS subsets. Gains are minimal on easy ones. Table 4: commonsense, all models. Table 5: symbolic, all models. Tables 6 and 7: ablations and robustness on LaMDA 137B. Table 6 highlights Equation only on GSM8K: 5.4 . Variable compute only: 6.4 . Chain of thought from annotator C on GSM8K: 17.6 . App C Appendix C: extended related work Show in original Summary Five areas inspire the work. They are prompting, natural language explanations, and program synthesis. The other two are numeric and logical reasoning, and intermediate steps. Instructions augment the input. Chain of thought augments the output. A user study with 20 people found chaining model outputs improves outcomes. App D Appendix D: additional analysis Show in original D.1 Correct chains Of 50 correct LaMDA answers, 49 had correct logic and math. 1 was correct by chance.5 had minor imperfections.D.2 Wrong chains Of 50 wrong answers, 8% were right except for a calculator slip. 16% had only a symbol mapping error.22% were missing one step.A calculator lifted LaMDA 137B on GSM8K from 14.3% to 17.3% . D.3 Number of examples Eight examples were the limit set by a 1024 token input. Gains held across numbers of examples (Figure 11). App E Appendix E: additional details Show in original Reproducibility and resources Version notes: V2 added PaLM. V3 added GPT-3, SVAMP, AQuA and SayCan. V5 added Codex and UL2. No finetuning was done. LaMDA used TPU v3. PaLM used TPU v4. Prompts for all tasks are in Tables 20 to 27. Dataset licenses are listed for the arithmetic and commonsense sets. App F Appendix F to H: examples and prompts Show in original Examples Appendix F: example right and wrong chains from LaMDA 137B and PaLM 540B. Appendix G: the full few-shot prompts (Tables 20 to 28). Appendix H: chains written by other annotators (Tables 29 and 30). This write-up covers the main paper in full and each appendix at summary level. Words to know Ablation: A test that removes one part to see what it did.Chain of thought: Reasoning steps written in plain words before the answer.Emergent ability: A skill that appears only above a certain model size.Few-shot prompting: Putting a few worked examples in the prompt.Greedy decoding: Always pick the single most likely next word.Language model: A program that predicts the next word of text.Parameter: A number inside the model that training adjusts.Prompt: The text you give a model to start its answer.Solve rate: The share of problems the model answers correctly.Ask AI about this paper Stuck on a word or an idea? Ask in plain words. The answer comes from the write-up on this page.
Ask AI about this paper Explain it like I am new to AI How would a finance team use this? What are the limits?
Jump to