GEPA
GEPA, short for Genetic-Pareto, is an automatic prompt optimizer. Instead of nudging prompts with numeric reward signals, it runs your system, reads what happened in plain language, writes down what went wrong, and proposes better prompts. It keeps a diverse frontier of strong attempts rather than a single winner, and in its original study it reached better results than reinforcement learning while using far fewer trial runs.
*These are learning tools, not prompts. They teach you to write your own, think of them as training wheels that guide you while you learn, then fall away once you can ride on your own.
Reflect in Language, Evolve on a Frontier
Many prompt optimizers treat the prompt as a set of dials and search for settings that raise a score. They learn from a single number, higher or lower, which carries very little information about why an answer was wrong. Reinforcement learning approaches can improve a system this way, but they often need a great many trial runs to make progress, because each run only returns a scalar reward.
GEPA replaces the scalar with a sentence. After running the system, it reflects on the trajectory in natural language, diagnosing what failed and why, the same way a person reviewing a transcript would. That written diagnosis is far richer than a score, so a single run teaches the optimizer much more, which is why GEPA can improve with dramatically fewer rollouts.
The second idea is the Pareto part. Rather than chasing one best prompt, GEPA keeps a frontier of attempts that each win on different cases, then combines their complementary lessons. This preserves diversity and avoids collapsing onto a prompt that is good on average but weak on important slices. In the original study, GEPA outperformed a strong reinforcement-learning baseline and a leading prompt optimizer while spending far fewer evaluations.
GEPA is a process you run to produce a better prompt, not something you type at inference time. It repeatedly runs your system on training examples, reflects, and proposes edits, so it belongs to the same family as OPRO, MIPRO, and DSPy optimizers. What you deploy afterward is the improved prompt it discovered.
The GEPA Process
Run, reflect, propose, and evolve along a Pareto frontier
Run the System and Collect Trajectories
Execute the current prompt on a set of training examples and record what happened: the inputs, the intermediate steps, the outputs, and whether each was right or wrong. These trajectories are the raw material GEPA learns from.
A question-answering system is run on 20 examples; 6 are wrong, and each wrong run's full trace is captured.
Reflect in Natural Language
An LLM reads the trajectories and writes a plain-language diagnosis of what went wrong and why, spotting patterns across the failures. This reflection is the rich learning signal that replaces a bare numeric score.
Reflection: "The prompt never tells the model to check units, so most errors are unit mismatches. It should require an explicit unit-check step."
Propose Improved Prompts
Guided by the reflection, GEPA proposes concrete edits to the prompt that address the diagnosed failures. Because the diagnosis is specific, the proposed changes are targeted rather than random mutations.
The new prompt adds an instruction to state and verify the units of every quantity before computing.
Evolve Along the Pareto Frontier
Rather than keeping only the single best prompt, GEPA maintains a frontier of candidates that each excel on different cases, and combines their complementary strengths across rounds. The loop repeats until the budget is spent, and the best combined prompt is returned.
One candidate is strong on unit problems, another on multi-step ones; GEPA merges their lessons into a prompt that handles both.
See the Difference
Learning from a score versus learning from a written diagnosis
Scalar-Reward Search
The optimizer sees only a score for each run. To find what helps, it must try many variations and infer the direction of improvement from the reward alone.
Progress can require a very large number of runs, because each one returns little information about why an output was wrong.
GEPA
GEPA reflects on each run in language, so one trajectory yields a specific, actionable reason for failure and a targeted fix, then evolves a diverse frontier of prompts.
In the original study it beat a strong reinforcement-learning baseline and a leading optimizer, using far fewer runs to get there.
Practice Responsible AI
Always verify AI-generated content before use. AI systems can produce confident but incorrect responses. When using AI professionally, transparent disclosure is both best practice and increasingly a legal requirement.
Most US states are actively legislating AI transparency and accountability. Critical thinking remains your strongest tool against misinformation.
GEPA in Action
See how reflection turns failures into targeted prompt edits
A support-classification prompt mislabels several tickets. GEPA runs the prompt on the training set and captures the traces of the wrong ones.
Reflection: "Failures cluster on tickets that mention billing and technical issues together; the prompt forces a single label, so mixed tickets are guessed."
Proposed edit: add an instruction to allow a primary and secondary label when two issues co-occur, and to pick the primary by which blocks the customer.
Effect: the mixed-ticket failures are addressed directly by the diagnosis, not by random rewording.
Two evolved prompts each do well on different slices: one excels on short queries, the other on long multi-part queries.
Instead of discarding either, GEPA keeps both on the Pareto frontier and merges their complementary instructions, the concise handling from one and the decomposition guidance from the other.
Result: a prompt that holds up across both slices, which a single best-on-average prompt would not have achieved.
A pipeline retrieves documents, then drafts an answer. Errors could come from either stage.
Reflection: "Most wrong answers retrieved the right documents but ignored a constraint stated in the question, so the drafting prompt is the weak link."
Proposed edit: strengthen the drafting prompt to restate and honor every explicit constraint before answering.
Effect: the optimization effort is spent on the stage that actually caused the failures.
When to Use GEPA
Best when you can run a system on examples and want a better prompt cheaply
Perfect For
When you have a task with training examples and want a stronger prompt without spending thousands of trial runs, GEPA's sample efficiency is the draw.
Pipelines with several prompted stages benefit from reflection that can pinpoint which stage is causing failures before proposing an edit.
When performance matters across different kinds of inputs, the Pareto frontier keeps prompts that win on each slice rather than collapsing to an average.
When reinforcement learning would be too costly, reflective prompt evolution can reach comparable or better results by changing prompts instead of weights.
Skip It When
GEPA needs a way to tell good runs from bad ones. Without examples or a metric to reflect against, there is nothing to optimize toward.
For a prompt you will use once, the setup of an optimization loop is not worth it; hand-tuning is faster.
If current performance is already at the ceiling for the task, an optimization pass has little headroom to recover.
Use Cases
Where GEPA delivers the most value
Production Prompt Tuning
Improve the prompts behind a shipped feature using a modest set of labeled examples, without the cost of a reinforcement-learning run.
Retrieval-Augmented Systems
Tune the prompts in a retrieval-and-answer pipeline, using reflection to identify whether retrieval or generation is the weaker stage.
Agent Prompt Refinement
Evolve the instructions that steer a tool-using agent, letting reflection surface the specific behaviors that lead to failed tasks.
Benchmark Optimization
Push accuracy on a target benchmark by evolving prompts against its training split, reaching strong scores with a limited evaluation budget.
Covering Diverse Inputs
Build prompts that perform across a range of input types by keeping a frontier of complementary candidates instead of one average winner.
Cost-Conscious Improvement
Get most of the gain of heavier optimization for a fraction of the runs, which matters when each evaluation is expensive.
Where GEPA Fits
A reflective, sample-efficient step in the optimizer family
GEPA sits alongside OPRO and MIPRO as an automatic optimizer, and it is available within the DSPy framework. Reach for it when you want the sample efficiency of learning from written diagnoses rather than scores, especially on compound systems.
Related Techniques
Explore complementary prompt-optimization techniques
Evolve a Better Prompt
Explore how reflective optimization improves prompts in the Prompt Builder, or see how GEPA relates to the wider family of prompt optimizers.