OPRO, short for Optimization by prompting, is an automatic prompt optimization method in which a large language model acts as the optimizer: it reads a history of earlier candidate prompts with their scores and proposes new candidates that are expected to score higher. In prompting, OPRO is best known for discovering instructions that outperform hand-written prompts on reasoning benchmarks without any gradient computation.
The method was introduced by researchers at Google DeepMind in 2023 under the title describing language models as optimizers. Its central idea is that natural language can describe an optimization problem, so a capable model can search for better solutions by reasoning over past attempts rather than by computing derivatives.
How OPRO optimizes a prompt
OPRO optimizes a prompt by running a loop of generation and evaluation. At each step, an optimizer model receives a meta-prompt that contains a description of the task, a few input-output examples and a list of previously tried instructions with their accuracy scores. The optimizer then writes several new instructions intended to beat the best ones listed.
Each new instruction is inserted into a fixed prompt template and passed to a scorer model, which answers a training subset of the task. The fraction of correct answers becomes the instruction’s score. The best-scoring instructions are added to the history, and the loop repeats until the score stops improving or a budget of steps is reached.
The table below lists the components of one OPRO iteration and the role each plays in the search.
| Component | Content | Role in the search |
|---|---|---|
| Meta-prompt | Task description and scored history | Gives the optimizer its context |
| Solution-score pairs | Past instructions sorted by score | Shows which directions work |
| Optimizer model | A large language model | Proposes new candidate instructions |
| Scorer model | The model the prompt is meant for | Measures accuracy on training examples |
| Training subset | A small labeled sample | Supplies the objective value |
A detail that matters in practice is ordering the history in ascending score, so that the best instructions appear last, closest to where the model starts writing. The original work also keeps only the top 20 or so instructions in the meta-prompt to stay within the context window.
Key parameters and design choices
OPRO behaves very differently depending on a handful of search parameters, and tuning them is part of using the method well. The most influential choices concern the sampling temperature, the number of candidates per step and the size of the scored history.
| Parameter | Typical setting | Effect when increased |
|---|---|---|
| Optimizer temperature | About 1.0 | More diverse but less focused candidates |
| Candidates per step | About 8 | More stable progress, higher scoring cost |
| History length | Up to about 20 entries | Richer signal, longer meta-prompt |
| Number of exemplars | About 3 | Clearer task framing, more tokens |
| Optimization steps | Tens to around 200 | Higher ceiling, risk of overfitting |
Lower temperatures make the optimizer repeat minor paraphrases of the best instruction, while very high temperatures produce candidates that ignore the history. Generating several candidates per step reduces the effect of noisy individual scores, which is important because accuracy on a small training subset varies from sample to sample.
Results and what they show
OPRO demonstrated that model-written instructions can beat human prompt engineering on established benchmarks. The original evaluation reported gains of up to about 8 percentage points on the GSM8K grade-school math benchmark and much larger gains on some Big-Bench Hard reasoning tasks, compared with human-designed prompts such as the classic zero-shot chain-of-thought phrase.
One widely cited discovered instruction asked the model to take a deep breath and work through the problem step by step. The example illustrates an important lesson: effective prompts are often counterintuitive to humans, and the best wording differs between scorer models, so an instruction optimized for one model may transfer poorly to another.
The authors also applied the same loop to small mathematical problems such as linear regression and the traveling salesman problem. There it worked for small instances but fell behind dedicated solvers as problems grew, which shows that OPRO is most valuable where the search space is language rather than numbers.
How OPRO compares with other prompt optimization methods
OPRO belongs to the family of automatic prompt optimization methods but differs in how it generates candidates. Instead of editing one prompt based on error analysis, it relies on the trajectory of scored attempts, which acts as an implicit gradient expressed in text.
| Method | How candidates are produced | Signal used |
|---|---|---|
| OPRO | Optimizer reads scored history | Accuracy trajectory |
| Automatic prompt engineer | Model infers instructions from examples, then resamples | Accuracy of each candidate |
| Textual gradient methods | Model critiques errors and edits the prompt | Natural-language feedback |
| Evolutionary prompt search | Mutation and crossover of prompts | Fitness score per generation |
| Manual iterative prompting | Human rewrites after inspection | Human judgment |
Compared with meta-prompting in the general sense, OPRO uses the meta-prompt for a narrow purpose: turning past scores into better proposals. Compared with gradient-based soft prompt tuning, it produces readable hard prompts and needs only API access to the models.
Practical use and limitations
OPRO is suitable when a task has a clear automatic metric and a labeled sample of at least a few dozen examples. Typical uses include classification instructions, extraction prompts and reasoning prefixes for a fixed production model, where a few points of accuracy justify a one-time optimization cost.
- Scoring cost: hundreds of candidates times dozens of examples can require many thousands of model calls.
- Overfitting: an instruction tuned on a small training subset may not generalize, so a held-out test set is essential.
- Model dependence: results degrade when the scorer model changes, so re-optimization is needed after upgrades.
- Weak optimizers: smaller models often fail to use the history and produce random rewrites.
- Metric gaming: the search optimizes only what is measured, including flaws in the metric.
A sensible workflow starts with a strong human baseline prompt, runs OPRO with a fixed evaluation split, and accepts the result only if it improves the held-out score by more than run-to-run noise.
Stripped to the essentials
Writing the perfect instruction for an AI model is often trial and error. OPRO lets a model do that trial and error itself. It tries some instructions. It checks how well each one works on practice questions. Then it looks at the scores and writes new, better instructions.
Think of a cook adjusting a recipe after every tasting. The cook keeps notes on which versions scored best and builds on them. The model keeps a scored list of attempts in the same way and steadily improves the wording.
Where it is applied
A support team uses a language model to classify incoming tickets into twelve categories. Its hand-written instruction reaches about 81 percent accuracy on a labeled set of 300 tickets, and errors between billing and account questions are common.
The team runs an OPRO-style loop for 40 steps, generating eight candidate instructions per step and scoring each one on 100 training tickets. The optimizer gradually adds guidance about distinguishing payment failures from login problems and about choosing the most specific category.
On the remaining 200 held-out tickets, the best discovered instruction reaches about 87 percent accuracy. The team deploys it, records the scorer model version, and schedules a new optimization run whenever the model is upgraded.