NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

PhaseEvo: Towards Unified In-Context Prompt Optimization for Large Language Models

Wendi Cui, Jiaxin Zhang, Zhuohang Li, Hao Sun, Damien Lopez, Kamalika Das, Bradley A. Malin, Kumar Sricharan · OpenReview

Abstract

Crafting an ideal prompt for Large Language Models (LLMs) is a challenging task that demands significant resources and expert human input. Existing work treats the optimization of prompt instruction and in-context learning examples as distinct problems, leading to sub-optimal prompt performance. This research addresses this limitation by establishing a unified in-context prompt optimization framework, which aims to achieve joint optimization of the prompt instruction and examples. However, formulating such optimization in the discrete and high-dimensional natural language space introduces challenges in terms of convergence and computational efficiency. To overcome these issues, we present PhaseEvo, an efficient automatic prompt optimization framework that combines the generative capability of LLMs with the global search proficiency of evolution algorithms. Our framework features a multi-phase design incorporating innovative LLM-based mutation operators to enhance search efficiency and accelerate convergence. We conduct an extensive evaluation of our approach across 35 benchmark tasks. The results demonstrate that PhaseEvo significantly outperforms the state-of-the-art baseline methods by a large margin whilst maintaining good efficiency.

Introduction: The Challenge of Prompt Cohesion

Large Language Models (LLMs) are notoriously sensitive to prompts. Even a slight change in wording or the choice of few-shot examples can swing performance wildly. Current "automatic prompt engineering" tools usually tackle this in silos: they either optimize the instruction (the "what to do") or select the best examples (the "how to do it"), but rarely both at once.

Conceptual overview of Cohesive In-Context Prompt Optimization (SEE), illustrating the transition from basic task descriptions to optimized instructions and examples.

The authors argue that this leads to "in-cohesive" prompts where the instructions and examples do not complement each other. Furthermore, searching for the "perfect" prompt in the infinite, high-dimensional space of natural language is computationally expensive and prone to getting stuck in "local minima."

Methodology: The SEE Framework

The authors introduce SEE (Strategic Exploration and Exploitation), a framework inspired by metaheuristic optimization. The core innovation is a quad-phased design that alternates between "Exploration" (searching far and wide for new ideas) and "Exploitation" (polishing the best ideas found so far).

The quad-phased design of the SEE framework, showing the iterative cycle between exploration and exploitation across four distinct mutation phases.

The optimization process follows four distinct phases:

  1. Phase 0: Global Initialization: Generates a diverse pool of candidate prompts using "Lamarckian" operators (reverse-engineering instructions from input-output pairs) or semantic variations.
  2. Phase 1: Local Feedback (Exploitation): Uses an "LLM Examiner" to identify mistakes and an "LLM Improver" to fix them, pushing candidates toward local peak performance.
  3. Phase 2: Global Fusion (Exploration): To avoid getting stuck, SEE uses "Crossover" and "Estimation of Distribution" operators to mix traits from different high-performing prompts.
  4. Phase 3: Local Semantic (Exploitation): A final "last mile" polish that uses semantic operators to fine-tune wording without changing the underlying strategy.

Instead of using standard semantic similarity, SEE uses Performance Vectors and Hamming Distance. It tracks which specific questions a prompt gets wrong and pairs prompts that make different mistakes, ensuring that the fusion phase covers the model's blind spots.

Experimental Evaluation

The framework was evaluated across 35 benchmark tasks spanning three domains: 8 Big Bench Hard (BBH) reasoning tasks, 3 NLP Detection tasks (hate speech, fake news, sarcasm), and 24 Instruction Induction tasks.

Key Results

  • Superior Accuracy: SEE outperformed 9 state-of-the-art baselines (including OPRO, APO, and APE). On difficult BBH tasks, it achieved an average performance gain of 13.94 points.
  • Efficiency Gains: Despite searching a more complex space, SEE reduced computational costs by 58.67% compared to the best-performing baselines.
  • Model Agnostic: While developed using GPT-3.5, the framework works across various models, including GPT-4, Claude 2, Llama-3, and Mistral.

Discussion and Insights

  • Cohesion is King: The paper demonstrates that randomly adding "good" examples to a "good" instruction often decreases performance. Optimization must happen as a unified unit.
  • Strategic Patience: Local polishers should be stopped quickly if they don't show gains, but global explorers should be given more time to "fail" before moving on, as their breakthroughs often take several iterations to manifest.
  • Behavioral Diversity > Word Diversity: It is more useful to combine two prompts that "think" differently (based on error patterns) than two prompts that just "look" different.

Conclusion

PhaseEvo (SEE) represents a significant advancement in automated prompt engineering by unifying instruction and example optimization. While currently a "pre-deployment" tool due to iteration latency, its efficiency and accuracy gains are substantial. Future work will focus on multi-objective goals, such as optimizing for accuracy while simultaneously minimizing token costs or maximizing safety.

Summary updated

BibTeX
@misc{cui2024phaseevo,
  author = {Wendi Cui and Jiaxin Zhang and Zhuohang Li and Hao Sun and Damien Lopez and Kamalika Das and Bradley A. Malin and Kumar Sricharan},
  title = {{PhaseEvo: Towards Unified In-Context Prompt Optimization for Large Language Models}},
  year = {2024},
  eprint = {2402.11347},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.11347},
}
Figure