Evolutionary Pre-Prompt Optimization for Mathematical Reasoning

Mathurin Videau, Alessandro Ferreira Leite, Marc Schoenauer, Olivier Teytaud · DOI

Large Language Models (LLMs) have demonstrated impressive capabilities in complex reasoning tasks, particularly when guided by Chain-of-Thought (CoT) prompting. However, the performance of these models is notoriously sensitive to the specific examples provided in the few-shot prompt. Selecting the optimal set of examples is typically a manual, trial-and-error process. This paper introduces Evolutionary Pre-Prompt Optimization (EPPO), a systematic framework that treats example selection as a black-box evolutionary search problem to maximize reasoning performance without the need for model fine-tuning.

The EPPO Framework

The core challenge in prompt optimization is the combinatorial explosion of possible example combinations. EPPO addresses this by representing a prompt as a "genome"—an array of indices pointing to specific question-solution pairs within a large demonstration dataset.

The optimization process follows an iterative "Ask-and-Tell" loop:

  1. Ask: An evolutionary optimizer (utilizing libraries like Nevergrad) proposes candidate sets of examples.
  2. Evaluate: The LLM's performance is tested on a small, representative training subset using these candidate prompts. To maintain efficiency, the authors use uncertainty-based subsampling to select training instances that provide the most informative signal.
  3. Tell: The optimizer receives feedback on which candidates performed better. Crucially, EPPO uses relative comparisons rather than absolute scores, which provides a natural regularization effect and prevents the optimizer from overfitting to specific dataset quirks.

Experimental Evaluation

The authors evaluated EPPO using LLaMA2-70B across four diverse mathematical reasoning benchmarks:

  • GSM8k: Grade school math word problems.
  • SVAMP: Math problems designed to test robustness and transferability.
  • MathQA: Large-scale dataset with complex, sometimes noisy, annotations.
  • MATH: High school competition-level problems representing the current ceiling for many LLMs.

Key Results and Insights

EPPO consistently outperformed standard CoT baselines, often achieving better results with fewer tokens than "Long CoT" methods.

Comparison of EPPO against standard CoT baselines across four mathematical reasoning benchmarks.

Several critical insights emerged from the study:

  • Optimal Shot Count: Interestingly, 4-shot prompts frequently outperformed 8-shot prompts. Increasing the number of examples can lead to "over-steering," where the model mimics the style of the examples too closely at the expense of general logical reasoning.
  • Style over Substance: In some instances, the most effective prompts found by the optimizer contained minor mathematical errors in their reasoning traces. This suggests that the structure and logical flow of the demonstration are more important for guiding the model than the literal correctness of every intermediate step.
  • Generalization and Robustness: Unlike gradient-based fine-tuning, which often suffers from distribution shift, EPPO-optimized prompts generalize well. Prompts optimized on GSM8k showed strong "positive transfer" to the SVAMP dataset. Furthermore, the specific order of examples—previously thought to be a major factor—mattered significantly less once the content of the prompt was optimized.
  • Synergy with Decoding Strategies: The gains from EPPO are additive with other techniques. When combined with Self-Consistency (SC) decoding, performance on GSM8k reached 79.1%, a substantial improvement over the 56.8% baseline.

Conclusion and Future Work

Evolutionary Pre-Prompt Optimization provides a powerful, weight-frozen method for enhancing LLM reasoning. By treating the prompt as a discrete search space and applying evolutionary principles, EPPO finds "universal" task-specific prompts that are both efficient and robust. While the computational cost of optimization remains a factor, the ability to squeeze significant performance gains out of existing models makes it a compelling alternative to expensive fine-tuning. Future research may explore dynamic retrieval strategies or more diverse population-based optimization to further push the boundaries of automated prompt engineering.

Summary updated

BibTeX
@misc{videau2024evolutionary,
  author = {Mathurin Videau and Alessandro Ferreira Leite and Marc Schoenauer and Olivier Teytaud},
  title = {{Evolutionary Pre-Prompt Optimization for Mathematical Reasoning}},
  year = {2024},
  eprint = {2412.04291},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.04291},
}
Figure