Source-linked AI summary

Automatic Chain of Thought Prompting in Large Language Models

Zhuosheng Zhang, Aston Zhang, Mu Li, Alex Smola

arXiv:2210.03493v1cs.CLcs.AI

TL;DR

Manual-CoT improves reasoning but depends on labor-intensive, task-specific demonstrations, while automatically generated chains can contain mistakes. Auto-CoT addresses this by sampling diverse questions and generating reasoning chains, and it consistently matches or exceeds Manual-CoT across ten benchmark reasoning tasks with GPT-3.

  • Problem

    Manual-CoT’s stronger performance depends on hand-crafted, task-specific demonstrations, while automatically generated reasoning chains may contain mistakes.

  • Method

    Auto-CoT clusters questions, selects representative questions, and generates their reasoning chains with Zero-Shot-CoT and simple heuristics.

  • Results

    Auto-CoT with GPT-3 consistently matches or exceeds Manual-CoT across ten public benchmark reasoning tasks.

  • Takeaways & Limitations

    Diverse sampling enables automatic, task-adaptive construction of CoT demonstrations without manual designs.

  • Takeaways & Limitations

    Clustering can still produce some wrong demonstrations, although heuristics such as favoring shorter questions and rationales can mitigate their effects.

Abstract

from arXiv · show

Large language models (LLMs) can perform complex reasoning by generating intermediate reasoning steps. Providing these steps for prompting demonstrations is called chain-of-thought (CoT) prompting. CoT prompting has two major paradigms. One leverages a simple prompt like "Let's think step by step" to facilitate step-by-step thinking before answering a question. The other uses a few manual demonstrations one by one, each composed of a question and a reasoning chain that leads to an answer. The superior performance of the second paradigm hinges on the hand-crafting of task-specific demonstrations one by one. We show that such manual efforts may be eliminated by leveraging LLMs with the "Let's think step by step" prompt to generate reasoning chains for demonstrations one by one, i.e., let's think not just step by step, but also one by one. However, these generated chains often come with mistakes. To mitigate the effect of such mistakes, we find that diversity matters for automatically constructing demonstrations. We propose an automatic CoT prompting method: Auto-CoT. It samples questions with diversity and generates reasoning chains to construct demonstrations. On ten public benchmark reasoning tasks with GPT-3, Auto-CoT consistently matches or exceeds the performance of the CoT paradigm that requires manual designs of demonstrations. Code is available at https://github.com/amazon-research/auto-cot

1 Introduction

CoT prompting elicits intermediate reasoning steps from LLMs, but stronger Manual-CoT performance requires labor-intensive, task-specific demonstrations. Auto-CoT automates their construction by sampling diverse questions and generating reasoning chains, matching or exceeding Manual-CoT across ten reasoning tasks with GPT-3.

  • Motivation: LLMs use intermediate reasoning steps to solve complex multi-step problems through chain-of-thought prompting.CoT prompting elicits a reasoning process before the final answer.
  • CoT paradigms: Zero-Shot-CoT uses “Let’s think step by step,” whereas Manual-CoT uses manually designed question-and-reasoning demonstrations.These are the two major CoT prompting paradigms described in the introduction.
  • Challenge: Manual-CoT performs more strongly than Zero-Shot-CoT but requires nontrivial, task-specific hand-design of questions and reasoning chains.Different tasks require different demonstration designs, increasing the manual effort.
  • Auto-CoT: Auto-CoT uses LLMs prompted with “Let’s think step by step” to generate reasoning chains for demonstrations one by one.The method aims to eliminate manual construction of demonstrations.
  • Auto-CoT: Auto-CoT clusters dataset questions, selects representative questions, and generates their reasoning chains with Zero-Shot-CoT and simple heuristics.Diversity is used to mitigate mistakes in automatically generated reasoning chains.
  • Results: On ten benchmark reasoning tasks, Auto-CoT with GPT-3 consistently matches or exceeds Manual-CoT performance.The evaluated tasks include arithmetic, commonsense, and symbolic reasoning.

2 Related Work

Prior work established CoT prompting and related in-context learning approaches for eliciting reasoning from LLMs. This paper focuses on automatically constructing demonstrations while addressing errors and sensitivity associated with manually selected examples.

  • Chain-of-thought prompting: CoT prompting is a gradient-free technique that induces LLMs to generate intermediate reasoning steps leading to an answer.Prior studies demonstrated both zero-shot and manually demonstrated CoT reasoning.
  • Zero-Shot-CoT: Zero-Shot-CoT showed that LLM-generated rationales can support reasoning without manually written demonstrations.This finding motivates using self-generated rationales for demonstrations.
  • Zero-Shot-CoT: Unlike rationale-selection methods requiring annotated answers, this work considers settings with only test questions and no training dataset.The distinction places Auto-CoT in a more challenging no-training-data scenario.
  • Manual-CoT: Manual-CoT improves reasoning with effective demonstrations, but designing both demonstration questions and reasoning chains requires substantial human effort.Related work often responds by crafting more complex demonstrations or using ensemble-like methods.
  • In-context learning: In-context learning performs tasks from prompted examples without gradient updates, but performance can vary with demonstration choice, formatting, and order.These sensitivities motivate careful construction of demonstrations.
  • In-context learning: CoT adds both input-to-rationale and rationale-to-output mappings, so mistakes in either mapping can cause a dramatic performance drop.This creates challenges beyond those observed for simpler in-context learning mappings.

3 Challenge of Auto-CoT

Auto-CoT addresses the challenge of automatically constructing reliable demonstrations when Zero-Shot-CoT-generated reasoning chains can be wrong. The analysis finds that similarity-based sampling can reinforce shared mistakes, while diverse clustering-based sampling and heuristics reduce this risk.

  • Challenge: Manual-CoT’s stronger performance depends on costly, task-specific hand-crafted questions and reasoning chains.Different tasks require different demonstration designs, and annotator choice can produce up to 28.2% accuracy disparity in a symbolic reasoning task.
  • Retrieval-Q-CoT: Retrieval-Q-CoT retrieves similar questions and uses Zero-Shot-CoT to generate rationale-and-answer demonstrations, but it can underperform random sampling.The method retrieves the top-k similar questions by cosine similarity, while Random-Q-CoT samples other questions randomly.
  • Retrieval-Q-CoT: 46.9% versus 25.8%: Retrieval-Q-CoT has a higher unresolving rate than Random-Q-CoT on MultiArith questions where Zero-Shot-CoT initially fails.The result supports the paper’s explanation that similar sampled questions can cause misleading by similarity.
  • Retrieval-Q-CoT: A case study shows Retrieval-Q-CoT repeating a shared misunderstanding of “the rest,” whereas Random-Q-CoT avoids the mistake with more diverse demonstrations.The retrieved demonstrations answer about “the total of” instead of “the rest,” and the test prediction follows that error.
  • Error Clusters: A frequent-error cluster contained 52.3% Zero-Shot-CoT errors, making similarity-based retrieval likely to gather demonstrations with related mistakes.The analysis links clustered errors to Retrieval-Q-CoT’s higher unresolving rate and motivates diversity in Auto-CoT.
  • Diversity-Based Auto-CoT: Auto-CoT partitions questions into clusters, selects a representative from each, and generates its reasoning chain with Zero-Shot-CoT and simple heuristics.Clustering promotes diverse demonstrations, while shorter-question and shorter-rationale heuristics help reduce remaining wrong demonstrations.

4 Auto-CoT: Automatic Chain-of-Thought Prompting

Auto-CoT automatically constructs task-specific chain-of-thought demonstrations by clustering questions for diversity and generating concise rationales with Zero-Shot-CoT. It then uses one selected demonstration per cluster to prompt reasoning on test questions.

  • 4 Auto-CoT: Automatic Chain-of-Thought Prompting: Auto-CoT has two stages: partition dataset questions into clusters, then sample a representative question from each cluster and generate its reasoning chain.
  • 4 Auto-CoT: Automatic Chain-of-Thought Prompting: Auto-CoT’s demonstrations are automatically constructed one by one with an LLM, replacing the manual construction paradigm.
  • 4.2 Demonstration Sampling: The resulting k demonstrations are concatenated before a test question and fed to an LLM for in-context reasoning and answering.
  • 4.1 Question Clustering: Question clustering encodes questions with Sentence-BERT and applies k-means to produce k clusters, sorting each cluster by distance to its center.
  • 4.2 Demonstration Sampling: Each constructed demonstration concatenates a question, its generated rationale, and its answer, producing one demonstration for each of the k clusters.
  • 4.2 Demonstration Sampling: The method considers questions closer to each cluster center earlier when searching for a demonstration that satisfies its selection criteria.
  • 4.2 Demonstration Sampling: For each candidate question, Zero-Shot-CoT prompts an LLM with “Let’s think step by step” to generate a reasoning chain.

5 Experiments

The experiments evaluate Auto-CoT across ten reasoning datasets and compare it with several prompting baselines. Results show competitive performance across LLMs, robustness to wrong demonstrations, and effectiveness in a streaming setting.

  • 5.1 Experimental setup: Experiments evaluate Auto-CoT on ten benchmark datasets spanning arithmetic, commonsense, and symbolic reasoning.
  • 5.1 Experimental setup: The main implementation uses GPT-3 text-davinci-002 with 175B parameters, while Codex is evaluated as an alternative LLM.
  • 5.1 Experimental setup: The baselines are Zero-Shot, Zero-Shot-CoT, Few-Shot, and Manual-CoT, with Auto-CoT results averaged over three random runs.
  • 5.2 Competitive Performance of Auto-CoT on Ten Datasets: Auto-CoT consistently matches or exceeds Manual-CoT across the ten datasets and automatically constructs dataset-specific demonstrations.
  • 5.4 General Effectiveness Using the Codex LLM: With Codex, Auto-CoT remains competitive with Manual-CoT despite Manual-CoT improving relative to its GPT-3 results.
  • 5.5 Effect of Wrong Demonstrations: With 50% wrong demonstrations, Auto-CoT’s performance on MultiArith does not degrade significantly compared with the In-Cluster Sampling baseline.
  • 5.6 Streaming Setting: Auto-CoT* bootstraps by storing question-chain pairs from the first batch and using existing pairs to construct demonstrations for later batches.
  • 5.6 Streaming Setting: In the streaming setting with batches of 30 questions, Auto-CoT* matches Zero-Shot-CoT on batch 1 and performs comparably with Manual-CoT from batch 2.

6 Conclusion

Auto-CoT automatically constructs diverse reasoning demonstrations, eliminating manual design while matching or exceeding manually designed CoT on ten benchmark reasoning datasets with GPT-3.

  • Auto-CoT automatically samples diverse questions and generates reasoning chains to construct demonstrations.
  • On ten public benchmark reasoning datasets, Auto-CoT consistently matches or exceeds manually designed CoT performance with GPT-3.

A.1 Impact of demonstration elements.

Demonstrations combine questions, rationales, and answers, with rationale-answer consistency being substantially more important than question order for performance.

  • A demonstration is a triple composed of a question, rationale, and answer.
  • Shuffling questions reduces performance from 91.7% to 73.8%, the smallest reduction among the tested demonstration components.
  • Generated Zero-Shot-CoT rationales can remain logically correct even when they lead to wrong answers.
  • Shuffling rationales or answers reduces accuracy from 91.7% to 43.8% or 17.0%, respectively.
  • The results indicate that rationale-answer consistency is critical, because mismatches can encourage answer prediction without a basis.

A.2 Observation of frequent-error clusters

Zero-Shot-CoT errors tend to concentrate in recurring question clusters across datasets and remain similarly patterned when the number of clusters changes.

  • Zero-Shot-CoT mistakes tend to gather in one or more question clusters across different datasets.
  • The same clustering pattern appears when the number of clusters changes.
  • The cluster with the highest error rate is called a frequent-error cluster.
  • Similarity-based retrieval risks selecting questions from a frequent-error cluster, where generated reasoning chains are imperfect.

B.1 Tasks and Datasets

The evaluation covers ten arithmetic, commonsense, and symbolic reasoning datasets using GPT-3 under specified decoding and demonstration-count settings.

  • The evaluation uses ten benchmark datasets spanning arithmetic, commonsense, and symbolic reasoning tasks.
  • Arithmetic Reasoning: The arithmetic tasks are MultiArith, GSM8K, AddSub, AQUA, SingleEq, and SVAMP.
  • Commonsense and Symbolic Reasoning: The commonsense tasks are CommonsenseQA and StrategyQA, while the symbolic tasks are Last Letter Concatenation and Coin Flip.
  • Model and Settings: The experiments use GPT-3 text-davinci-002 with 175B parameters, greedy decoding, max_tokens = 256, and temperature = 0.
  • Model and Settings: The number of demonstrations is usually 8, with task-specific exceptions for AQuA, Last Letter Concatenation, CSQA, and StrategyQA.

C Analysis

The analysis refines Auto-CoT’s demonstration construction by favoring representative questions, filtering for simple rationales, and testing performance in streaming batches.

  • Demonstrations generally improve when sampled near their cluster center rather than farther away or randomly.
  • The simple heuristics reduce the average number of wrong rationales, keeping the construction error rate below 20%.The error rate is computed as wrong rationales divided by the number of demonstrations.
  • In the streaming setting, Auto-CoT* matches Zero-Shot-CoT on batch 1 and becomes comparable with Manual-CoT from batch 2.The evaluation covers all 600 MultiArith test questions across batches.
Loading 2210.03493v1…