Automatic Chain of Thought Prompting in Large Language Models

Zhuosheng Zhang, Aston Zhang, Mu Li, Alex Smola

TL;DR

Auto-CoT eliminates the tedious manual effort of hand-crafting few-shot Chain-of-Thought (CoT) prompts for Large Language Models. By leveraging question clustering to ensure diversity and using zero-shot prompting to generate rationales, Auto-CoT automatically builds high-quality demonstrations that match or exceed the performance of manually designed prompts across various reasoning benchmarks.

What Problem Does This Paper Address?

Chain-of-Thought (CoT) prompting has revolutionized how we elicit multi-step reasoning from Large Language Models (LLMs). Currently, this paradigm exists in two main flavors: Zero-Shot-CoT (simply appending "Let's think step by step") and Manual-CoT (providing hand-crafted question-rationale-answer demonstrations).

While Manual-CoT yields superior performance, it suffers from a major bottleneck: creating effective, task-specific demonstrations requires significant human effort. If you change the task from arithmetic to commonsense reasoning, a human has to sit down and write a whole new set of step-by-step examples.

The authors of this paper ask a simple question: Can we automate the creation of these few-shot demonstrations?

An obvious first attempt might be to use Zero-Shot-CoT to generate rationales for a few dataset questions and use those as demonstrations. However, LLMs aren't perfect zero-shot reasoners; they make mistakes. If an automated system selects similar questions to prompt the model, the model tends to repeat the same errors—a phenomenon the authors call misleading by similarity.

Methods

To overcome the issue of automated errors clumping together and misleading the model, the authors introduce Auto-CoT (Automatic Chain-of-Thought Prompting). The core philosophy is that diversity matters.

The Auto-CoT framework consists of two main stages:

  1. Question Clustering: The entire pool of available dataset questions is encoded into vector representations using Sentence-BERT. These embeddings are then partitioned into $k$ distinct clusters using the $k$-means algorithm to ensure semantic diversity.
  2. Demonstration Sampling: From each cluster, the system selects a representative question (the one closest to the cluster center). To ensure the demonstrations are clean and concise, the authors apply simple heuristics: the question must be under 60 tokens, and the generated rationale must be under 5 reasoning steps. The selected question is then fed into the LLM with a "Let's think step by step" prompt to generate its reasoning chain automatically.
Overview of the Auto-CoT method

By sampling exactly one question from each diverse cluster, the system ensures that even if the LLM makes a mistake on one rationale, the error won't systematically bias the entire few-shot prompt.

Datasets

The authors evaluated Auto-CoT across ten public benchmark reasoning datasets spanning three categories:

  • Arithmetic Reasoning: MultiArith, GSM8K, AddSub, AQuA, SingleEq, and SVAMP.
  • Commonsense Reasoning: CSQA and StrategyQA.
  • Symbolic Reasoning: Last Letter Concatenation and Coin Flip.

Key Insights and Ideas

  • The Danger of Nearest-Neighbors: Standard similarity-based retrieval methods (like retrieving the top-$k$ most similar questions to use as prompts) perform poorly when rationales are machine-generated. If the model makes a mistake on a specific type of problem, nearest-neighbor retrieval forces it to look at multiple examples of that exact same mistake, compounding the error.
  • Robustness to Imperfect Prompts: LLMs are surprisingly resilient to a small percentage of incorrect few-shot examples if the examples are highly diverse. Auto-CoT leverages this by spreading its samples across different semantic clusters, ensuring that errors do not cluster together.
  • Heuristics as a Filter: Simple constraints on token length and reasoning steps are highly effective at filtering out convoluted or broken zero-shot rationales during the automated construction phase.

Key Results

Using GPT-3 (text-davinci-002), Auto-CoT consistently matched or outperformed Manual-CoT, completely removing humans from the prompt-engineering loop:

  • MultiArith: Auto-CoT achieved 92.0% accuracy, slightly edging out Manual-CoT (91.7%) and significantly outperforming Zero-Shot-CoT (78.7%).
  • GSM8K: Auto-CoT reached 47.9% accuracy compared to Manual-CoT's 46.9%.
  • Symbolic Reasoning: On the Coin Flip task, Auto-CoT hit 99.9% accuracy (vs. Manual-CoT's 97.2%).

The authors also validated the method using the Codex model (code-davinci-002), confirming that Auto-CoT's automated generation remains highly competitive and generalizable across different model architectures.

Limitations and Future Work

While Auto-CoT successfully automates prompt generation, it still fundamentally relies on the baseline zero-shot capabilities of the underlying LLM. If a model is too weak to generate any logically coherent steps during the zero-shot phase, Auto-CoT's performance will degrade.

Additionally, the selection criteria rely on basic heuristics (like token length). The authors suggest that future work could explore more advanced validation techniques, such as using execution verifiers or cross-model voting, to further prune incorrect rationales from the automatically constructed prompts.

Summary updated

BibTeX
@inproceedings{zhang2023automatic,
  author = {Zhuosheng Zhang and Aston Zhang and Mu Li and Alex Smola},
  title = {{Automatic Chain of Thought Prompting in Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=5NTt8GFjUHkr},
}
Figure