Reprompting: Automated Chain-of-Thought Prompt Inference Through Gibbs Sampling

Weijia Xu, Andrzej Banburski, Nebojsa Jojic

Introduction

While Large Language Models (LLMs) demonstrate impressive capabilities, they frequently stumble on multi-step reasoning tasks such as logical deduction or complex mathematics. The current "gold standard" to address this is Chain-of-Thought (CoT) prompting, where a human expert manually writes out step-by-step reasoning for a few examples to "show the model how to think."

However, this manual approach suffers from two major flaws:

  1. Scalability: It requires human experts to painstakingly craft prompts for every new task.
  2. Model Specificity: A reasoning chain that works perfectly for one model (e.g., GPT-4) might confuse another (e.g., Llama-3). There is no universal, "one size fits all" prompt.

To solve this, researchers have introduced Reprompting, an iterative algorithm that automatically discovers high-performing CoT prompts without human intervention. By treating prompt discovery as a Gibbs sampling problem, the method evolves "reasoning recipes" that outperform human-written prompts by an average of 9.4 points across complex reasoning tasks.

The Reprompting Method

Reprompting automates the search for the "perfect" reasoning recipe for any given model and task. Instead of relying on human-written steps, the model discovers them through an iterative, evolutionary process based on Gibbs Sampling:

  1. Initialization: The model attempts to solve a set of training problems using "zero-shot" CoT (essentially prompting the model to "think step by step" without providing prior examples).
  2. Iterative Sampling: The algorithm selects a problem and attempts to solve it again. This time, it uses successful reasoning "recipes" sampled from other training problems as few-shot examples.
  3. Rejection Sampling: If the model generates a reasoning chain that leads to an incorrect final answer, that recipe is discarded. If it is correct, it is added to the pool of potential "parent" prompts.
  4. Convergence: Over thousands of iterations, the model breeds increasingly robust reasoning strategies. Effective fragments of thought are recombined and refined.
The iterative Reprompting process, where successful reasoning chains from one problem serve as parent prompts for the next.

One of the most surprising findings of this method is the "Aha!" moment of prompt evolution. Even "broken" initial recipes can be useful. A recipe might contain a logical error but follow a helpful structural pattern. When used as a prompt for a different problem, the model often retains the helpful structure while fixing the logic, eventually evolving a high-quality recipe.

Datasets and Evaluation

The researchers evaluated Reprompting on 20 challenging reasoning tasks across three major benchmarks:

  • Big-Bench Hard (BBH): Includes tasks like logical deduction, tracking shuffled objects, and temporal sequences.
  • GSM8K: Grade school math word problems.
  • MATH: Advanced mathematical reasoning problems.

They primarily used ChatGPT (gpt-3.5-turbo) and InstructGPT (text-davinci-003) as the underlying engines for these experiments.

Key Insights and Results

Reprompting proved to be highly effective, consistently converging on high-accuracy strategies across all 20 tasks.

  • Better than Humans: Reprompting outperformed human-written CoT prompts by +9.4 points on average.
  • State-of-the-Art Performance: It consistently beat other automated methods like Auto-CoT and Automatic Prompt Optimization (APO) by margins of 11 to 33 points.
  • Model Bootstrapping: The authors found they could use a stronger model (ChatGPT) to initialize the recipes for a different model (InstructGPT). This "combo" approach led to massive gains—up to +71 points—allowing the second model to far exceed its baseline capabilities.
Training accuracy over iterations for InstructGPT, ChatGPT, and a combined approach, demonstrating steady convergence.

The paper also confirmed that prompts are not universal. On tasks like Geometric Shapes, using a prompt optimized for a different model led to an 18–19 point drop in accuracy, highlighting the necessity of automated, model-specific optimization.

Limitations and Future Work

While powerful, Reprompting has a few notable limitations:

  • Computational Cost: The iterative nature of Gibbs sampling is resource-intensive. Running 20,000 iterations via paid APIs can cost between $80 and $800 per task, depending on the model.
  • Requirement for Ground Truth: The algorithm relies on having the correct answers (labels) for the training set to perform rejection sampling. It cannot currently optimize prompts for tasks where the "correct" answer is subjective or unknown.

Looking forward, the authors suggest exploring how this method could be used to "teach" smaller, more efficient models using recipes evolved by larger, more expensive models. This could potentially bridge the performance gap in edge computing scenarios, bringing complex reasoning capabilities to smaller devices.

Summary updated

BibTeX
@inproceedings{xu2024reprompting,
  author = {Weijia Xu and Andrzej Banburski and Nebojsa Jojic},
  title = {{Reprompting: Automated Chain-of-Thought Prompt Inference Through Gibbs Sampling}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=D8zn1DnTuj},
}
Figure