Introduction
Prompt engineering has emerged as a critical yet often manual and opaque process in the deployment of Large Language Models (LLMs). While automated prompt optimization techniques have been developed, they frequently suffer from a lack of "cohesion." Most existing methods optimize instructions (the task description) and in-context examples (the demonstrations) as separate entities. This disjointed approach can lead to prompts where the instructions and examples provide conflicting signals, ultimately degrading model performance.
To address these challenges, we introduce SEE (Strategic Exploration and Exploitation), a novel metaheuristic framework designed to automatically and simultaneously optimize both instructions and examples. By treating the prompt as a single, cohesive unit, SEE navigates the high-dimensional space of natural language more effectively than previous methods.
The SEE Framework
SEE is built upon a quad-phased metaheuristic design that strategically balances global exploration (searching for new, promising regions of the prompt space) and local exploitation (refining existing high-quality prompts). This iterative process ensures the framework avoids getting trapped in local optima while maintaining computational efficiency.
Quad-Phased Optimization Cycle
- Phase 0: Global Initialization: The process begins by generating a diverse pool of candidate prompts. This is achieved through "Lamarckian" operators, which reverse-engineer instructions from existing data, or by creating semantic variations of human-authored prompts.
- Phase 1: Local Feedback Operation: An LLM "Examiner" analyzes the errors made by current candidates, providing feedback to an "Improver" model that refines the prompts to address specific weaknesses.
- Phase 2: Global Fusion Operation: To escape local minima, SEE employs crossover operators that combine traits from different high-performing prompts. A key innovation here is Performance-based Similarity, which measures diversity based on the specific test cases prompts get right or wrong (using Hamming distance on performance vectors) rather than simple textual similarity.
- Phase 3: Local Semantic Operation: The final phase performs a "last mile" polish, making subtle lexical adjustments to the prompts while preserving their core semantic meaning.
Experimental Evaluation
We evaluated SEE across a comprehensive suite of 35 benchmark tasks, including 8 Big Bench Hard (BBH) reasoning tasks, 3 NLP detection tasks (hate speech, fake news, and sarcasm), and 24 instruction induction tasks. The framework was tested across a wide array of models, including GPT-3.5, GPT-4, PaLM 2, Claude 2, and open-source models like Llama 3 and Mistral.
Key Results
SEE consistently outperformed nine state-of-the-art (SOTA) baselines, including APE, APO, and OPRO. On the challenging BBH benchmarks, SEE achieved an average performance gain of 13.94 points over the next best method.
Beyond raw performance, SEE is significantly more efficient. It reduced computational costs by approximately 58.67% compared to existing SOTA methods. When compared to traditional evolutionary algorithms like PromptBreeder, SEE reached superior results while requiring 2.5 orders of magnitude fewer API calls.
Conclusion
The SEE framework demonstrates that cohesive optimization of instructions and examples is vital for maximizing LLM performance. By strategically alternating between exploration and exploitation and utilizing performance-based diversity metrics, SEE provides a robust and efficient solution for automated prompt engineering. Future work will focus on multi-objective optimization—balancing accuracy with safety and token efficiency—and exploring online adaptation techniques for real-time prompt refinement.
Summary updated