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

Weijia Xu, Andrzej Banburski-Fahey, Nebojsa Jojic · DOI

Abstract

Chain-of-Thought (CoT) prompting has revolutionized the ability of Large Language Models (LLMs) to tackle complex reasoning tasks. However, the manual creation of these prompts is labor-intensive and often fails to account for the unique "internal logic" of different models. This paper introduces Reprompting, an automated framework that treats prompt discovery as a search problem solved via Gibbs sampling. By iteratively sampling and refining reasoning "recipes," Reprompting allows models to discover their own optimal reasoning paths. Our evaluation across 20 challenging benchmarks shows that Reprompting outperforms human-written prompts by an average of 9.4 points and surpasses existing automated baselines by significant margins.

The Challenge of Manual Prompt Engineering

While CoT prompting—providing step-by-step reasoning examples—has significantly boosted LLM performance, it faces two primary bottlenecks:

  1. Human Effort: Crafting effective reasoning chains requires domain expertise and an understanding of model-specific nuances.
  2. Model Sensitivity: Prompts are rarely transferable; a strategy that works for one model may be suboptimal for another due to differing training data and architectures.

Reprompting addresses these issues by automatically inferring the most effective CoT prompts for a specific model using only a small set of question-answer pairs.

Methodology: Prompt Discovery via Gibbs Sampling

The core of the Reprompting algorithm is an iterative process based on Gibbs sampling, which "evolves" successful reasoning strategies over time.

The process follows four main stages:

  • Initialization: The model generates initial solutions for training problems in a zero-shot setting.
  • Iterative Sampling: The algorithm selects a training problem and a set of "parent" recipes (successful reasoning paths from other problems). These parents serve as few-shot examples to guide the model in generating a new reasoning path for the target problem.
  • Rejection Sampling: New paths are added to the "recipe pool" only if they lead to the correct answer, ensuring the survival of the most accurate logic.
  • Convergence: Through thousands of iterations, the pool converges toward a set of highly consistent and effective reasoning strategies.
The iterative Reprompting process refines reasoning steps across different logical deduction tasks, allowing the model to discover and recombine successful logic fragments.

Experimental Evaluation

The researchers evaluated Reprompting on 20 tasks across three major benchmarks: Big-Bench Hard (BBH), GSM8K (grade-school math), and MATH (competition-level mathematics).

Key Results and Performance

Reprompting demonstrated a clear superiority over both human experts and existing automated methods:

  • Outperforming Humans: On average, Reprompting improved performance by +9.4 points over human-written CoT prompts.
  • State-of-the-Art (SOTA): It consistently beat automated methods like Auto-CoT and Automatic Prompt Optimization (APO) by margins of 11 to 33 points.
  • Benchmark Success: On BBH tasks, Reprompting achieved an average accuracy of 83.0% with ChatGPT, compared to 70.1% for standard human CoT.
Average training accuracy curves for InstructGPT, ChatGPT, and a ChatGPT-bootstrapped InstructGPT model show steady convergence and the benefits of cross-model initialization.

Insights: Model-Specific Logic and Recombination

A key finding of the study is that prompts are highly model-specific. A prompt optimized for ChatGPT often performs poorly on InstructGPT. Reprompting allows each model to find its own "language." Furthermore, the algorithm facilitates "recombination," where the LLM takes a successful strategy from one recipe and combines it with another to create a superior hybrid.

Interestingly, "Cross-Model Bootstrapping" proved highly effective. Using a stronger model (like ChatGPT) to initialize the recipe pool for a different model (like InstructGPT) led to massive performance gains, sometimes exceeding +70 points.

Limitations and Future Directions

Despite its success, Reprompting has notable limitations:

  • Computational Cost: The iterative search process is resource-intensive, with costs ranging from $80 to $800 per task depending on the model API.
  • Data Requirements: Unlike zero-shot methods, it requires a small set of labeled training data for rejection sampling.
  • Search Time: While final inference is fast, the initial search for optimal prompts takes significant time.

Future work may explore human-in-the-loop guidance to streamline the sampling process or more diverse initialization strategies to reduce computational overhead.

Summary updated

BibTeX
@inproceedings{xu2024reprompting,
  author = {Weijia Xu and Andrzej Banburski-Fahey 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