Last updated:
A Survey of Automatic Prompt Engineering: An Optimization Perspective
Wenwu Li et al.
In collections: Prompting
The rise of foundation models has shifted the focus from resource-intensive fine-tuning to prompt engineering, a paradigm that steers a model's behavior by designing the input rather than updating the weights. While manual prompt engineering runs into limits of scalability, adaptability, and alignment across modalities, automated methods, including optimization based on foundation models (FMs), evolutionary methods, gradient-based optimization, and reinforcement learning (RL), offer promising solutions. Existing surveys, however, remain fragmented across modalities and methodologies. This paper presents the first comprehensive survey of automatic prompt engineering through the lens of a unified optimization theory. We formalize prompt optimization as a maximization problem over discrete, continuous, and hybrid prompt spaces, systematically organizing methods by their optimization variables (instructions, soft prompts, examples), task-specific objectives, and computational frameworks. By linking theoretical formulations with practical implementations across text, visual, and multimodal domains, this survey establishes a foundational conceptual framework for both researchers and practitioners, while highlighting little-explored frontiers in constrained optimization and agent-oriented prompt design.
Strategies from the report:
Automated Prompt Optimization (APO): A framework in which the models themselves automatically generate, test, and iteratively improve prompts, treating the process as a mathematical problem of maximizing a score instead of relying on human intuition.
Evolutionary Methods: Treating prompts like organisms that can "mutate" or "cross over". The algorithm takes the best instructions from a pool and combines their fragments so that, over successive generations, an even more effective version of the text evolves.
Continuous and Hybrid Prompt Spaces (Soft & Hybrid Prompts): Tuning the model's hidden mathematical representations (vectors) instead of the natural-language words themselves. This allows deeper, more technical communication with the AI, bypassing the limits of human language.
Best practices:
Defining the Optimization Objective (Task-specific Objectives): Before you start automatic prompt engineering, you must define the objective function clearly and mathematically, that is, what exactly "success" means for the task at hand (e.g., minimizing the number of hallucinations, maximizing conciseness).
Optimizing Example Answers (Exemplar Optimization): Automated frameworks go beyond merely improving instructions – it is worth having algorithms search huge databases to pick the best possible "few-shot" examples to put in the prompt.
Unifying the Tooling (Unified Optimization Framework): Moving from haphazard "guessing" of prompts in production to standardized systems that consistently evaluate instructions against the same metrics over time.
What to avoid?
Manual experimentation at large scale (Manual scalability limits): Avoid the human, time-consuming tweaking of individual words in a prompt ("Do it well" vs "Do it precisely") when you deploy a model in a large commercial application. At this scale, human intuition is inefficient.
Focusing only on changing words (Ignoring soft spaces): Avoid relying solely on discrete text instructions (hard prompts) if you have the computing resources and access to the model's weights to use far more powerful vector prompts (soft tuning/prefix tuning).
Aimless optimization in agent mode (Unconstrained agent design): Be careful about using automatic prompt optimization without imposing strict safety constraints. Self-modifying prompts can evolve in ways that go against human intent.
Support this project by buying me a coffee ;)