The Research Report
GEPA Becomes DSPy's Default Optimizer: Why Reflective Evolution Replaced Bayesian Search
The most popular framework for programming language models just made its biggest optimizer change in years. DSPy, Stanford's open-source framework with 35,000+ GitHub stars, has promoted GEPA (Genetic-Pareto Prompt Evolution) as its recommended instruction optimizer. The shift away from MIPROv2, the previous top recommendation, signals that reflective evolution has matured past the research stage.
The numbers tell the story. GEPA outperforms MIPROv2 by 13% in aggregate benchmarks. It beats GRPO, a leading reinforcement learning method, by up to 20% with 35x fewer rollouts. Shopify, Databricks, and Dropbox already run it in production. The ICLR 2026 committee gave it an oral acceptance.
Here is what changed, why it matters, and how to use it.
What GEPA Replaces
Before GEPA, DSPy's optimizer hierarchy looked like this:
- BootstrapFewShot for quick few-shot demo selection
- MIPROv2 for joint instruction and demonstration optimization via Bayesian search
- COPRO for simple instruction hill-climbing
MIPROv2 was the heavyweight. It used Bayesian optimization to search over instruction and demonstration combinations. It worked well given enough data (200+ examples) and compute (40+ trials). But it had a fundamental limitation: it treated the metric score as a single number. MIPROv2 knew candidate A scored 0.72 and candidate B scored 0.81. It did not know why.
GEPA flips that. It reads the full execution trace, including error messages, reasoning logs, and structured evaluator feedback. It diagnoses failures in natural language and proposes targeted fixes. Where MIPROv2 searched blindly with a scalar reward, GEPA searches with a diagnostician.
How GEPA Works
GEPA runs a five-step loop that mirrors how a skilled engineer debugs a system.
Step 1: Select from the Pareto Frontier
GEPA maintains a population of candidate prompts, not just one. Each candidate is evaluated across all examples in the validation set. The Pareto frontier contains candidates that are the best on at least one example. On each iteration, GEPA samples a parent from this frontier, weighting toward candidates that dominate more examples.
This is the "Pareto" in Genetic-Pareto. Instead of keeping one best candidate, GEPA preserves diversity. Different candidates excel on different problem types. A math reasoning prompt might handle algebra well but fail on geometry. Another might nail geometry but struggle with number theory. Both stay on the frontier.
Step 2: Run on a Minibatch
The selected candidate runs on a small minibatch from the training set. Default size: 3 examples. GEPA captures the full execution trace for each example. The prompt sent, the model's reasoning steps, tool calls and their outputs, the final answer, and why the evaluator scored it the way it did. This trace includes what GEPA calls Actionable Side Information (ASI).
Step 3: Reflect with an LLM
A strong LLM reads the execution traces and produces a diagnosis. The reflector identifies failure modes, logic breakdowns, and causal relationships. It sees what worked in successful examples and what broke in failures. This is where the metric contract matters. GEPA requires metrics to return Prediction(score, feedback), not just a float. The feedback string flows directly into the reflection prompt.
If you return a bare float, GEPA still works. It just says "This trajectory got a score of 0.4." The reflector has no clue what went wrong. With rich feedback, the reflector gets "Score: 0.4. The model failed to enforce digit constraints in base-9 representation and did not verify the final answer against the original problem statement." That specificity produces dramatically better proposals.
Step 4: Mutate with Accumulated Lessons
Based on the reflection, GEPA proposes a new prompt. This is not random mutation. The new prompt inherits all accumulated lessons from its ancestors in the search tree, plus the specific fixes from the current reflection. GEPA also supports a merge operation that combines strengths from two Pareto-optimal candidates into a single new candidate.
Step 5: Validate and Update the Frontier
The new candidate runs on the full validation set. If it achieves the best score on any evaluation instance, it joins the Pareto frontier. If an existing candidate becomes dominated (beaten on every instance), it drops off. The frontier only grows with genuinely complementary candidates.
The Key Innovation: Actionable Side Information
ASI is GEPA's central conceptual contribution. In traditional machine learning, gradients tell you which direction to adjust parameters. But when your parameters are natural language prompts, numerical gradients do not exist.
ASI fills that gap. It converts a scalar "you scored 72%" into rich directional information. This can include:
- Error messages from code execution
- Profiling data showing which steps took longest
- Reasoning traces revealing logical fallacies
- Structured evaluator feedback identifying specific failure modes
ASI is the text-optimization analogue of a gradient. Every iteration produces a detailed diagnosis that compounds across runs. The accumulated lesson log means GEPA avoids repeating mistakes and builds on prior insights.
Why DSPy Made the Switch
Three factors drove the change.
Quality. GEPA outperforms MIPROv2 by 13% in aggregate across six benchmark tasks. On AIME 2025 competition math specifically, it gains +12% accuracy. On MATH, it pushes ChainOfThought from 67% to 93% accuracy through instruction refinement alone. No few-shot examples, no architectural changes, no model fine-tuning.
Sample efficiency. GEPA works with as few as 10 examples and 20-100 evaluations. MIPROv2 needs 200+ examples and 40+ trials to reach its best results. GEPA achieves comparable or better results with a fraction of the data. For teams with limited labeled data, this is a game changer.
Interpretability. MIPROv2 is a black box. You give it a metric, it returns an optimized prompt, and you have no idea what it tried or why the winner won. GEPA's reflection logs show you every diagnosis, every proposed fix, and every lesson accumulated. You can trace exactly why the final prompt has the instructions it has.
Production Adoption
GEPA is not just a research artifact. Real companies run it in production.
Databricks published a detailed blog and integration guide showing GEPA-optimized open models beating Claude Opus 4.1 at 90x lower cost. They integrated GEPA into their Mosaic AI platform with MLflow tracking, custom judge scorers, and one-click deployment. The Databricks Mosaic AI Research team validated all the paper's findings independently.
Shopify CEO Tobi Lutke tweeted that "Both DSPy and GEPA are currently severely under hyped." Shopify uses GEPA for production prompt optimization across their merchant-facing AI features.
Dropbox is listed as a production user on the GEPA homepage. Drew Houston, Dropbox CEO, tweeted that he has "heard great things about DSPy plus GEPA, which is an even stronger prompt optimizer than MIPROv2."
Additional reported results:
- ARC-AGI agent accuracy: 32% to 89% through architecture discovery (not just prompt tweaking, GEPA discovered entirely new agent architectures)
- AIME 2025 with GPT-4.1 Mini: 46.6% to 56.6%, a 10-point jump
- Coding agent resolve rate on Jinja tasks: 55% to 82% via auto-learned skills
- Cloud scheduling cost savings: 40.2%, beating hand-crafted expert heuristics
50+ production deployments have been reported across Shopify, Databricks, Dropbox, OpenAI, Pydantic, and MLflow teams.
The Standalone Library
GEPA is not limited to DSPy. The standalone library (pip install gepa) exposes an optimize function that can evolve any text artifact against any evaluation function.
Three optimization modes cover different use cases:
- Prompt optimization. The default. Evolve system prompts, instructions, or any natural language text.
- Code optimization. Treat source code as text. The reflector reads error messages, profiling data, and test failures to propose targeted code changes.
- Architecture discovery. Evolve agent architectures, tool configurations, and workflow parameters.
The standalone API looks like this:
import gepa
result = gepa.optimize(
seed_candidate={"system_prompt": "You are a helpful assistant..."},
trainset=trainset,
valset=valset,
task_lm="openai/gpt-4.1-mini",
max_metric_calls=150,
reflection_lm="openai/gpt-5",
)
print(result.best_candidate['system_prompt'])
The tasklm runs your program on each evaluation. The reflectionlm reads the traces and proposes improvements. A common pattern: cheap task model (gpt-4.1-mini) for evaluation, strong model (gpt-5) for reflection. This keeps costs low while maintaining proposal quality.
Using GEPA with DSPy
The DSPy integration is a drop-in replacement for other optimizers:
import dspy
class RAG(dspy.Module):
def __init__(self):
self.retrieve = dspy.Retrieve(k=3)
self.generate = dspy.ChainOfThought("context, question -> answer")
def forward(self, question):
context = self.retrieve(question).passages
return self.generate(context=context, question=question)
gepa = dspy.GEPA(
metric=your_metric,
max_metric_calls=150,
reflection_lm="openai/gpt-5"
)
optimized_rag = gepa.compile(student=RAG(), trainset=trainset, valset=valset)
The key difference from other optimizers: your metric must return dspy.Prediction(score, feedback), not just a float. This feedback string is what feeds the reflection loop. The richer the feedback, the better GEPA performs.
Budget modes:
auto="light": ~1,330 metric calls on a 2-predictor/100-example task. Good for quick iteration.auto="medium": ~1,740 metric calls. The recommended starting point.auto="heavy": ~2,045 metric calls. For final production optimization.
You can also set maxmetriccalls directly for a hard dollar cap, or maxfullevals for a pass-count budget.
GEPA vs MIPROv2: When to Use Each
GEPA is not always the right choice. DSPy's optimizer selection guide still recommends MIPROv2 for specific scenarios.
Use GEPA when:
- You need the highest possible accuracy on a specific task
- Your evaluation set has diverse problem types (math, multi-hop QA, mixed formats)
- You can provide rich diagnostic feedback beyond a scalar score
- You are using a black-box model with no gradient access
- Sample efficiency matters (limited budget for rollouts)
- Your task involves complex reasoning, agentic workflows, or multi-step pipelines
Use MIPROv2 when:
- You have 200+ examples and want joint instruction + demo optimization
- Your metric only returns a scalar score without meaningful feedback
- You want to optimize both instructions and few-shot demonstrations together
- Compute budget is extremely tight (GEPA's reflection calls cost more per iteration)
Use BootstrapFewShot when:
- You need results in under 5 minutes
- You only need few-shot example selection, not instruction optimization
- Your task is simple and the baseline already works well
The BetterTogether optimizer chains GEPA with few-shot optimization, giving you both instruction quality and demonstration selection. This is the recommended path for maximum quality when you have the compute budget.
Practical Implications for Prompt Optimization Pipelines
The shift from MIPROv2 to GEPA has four practical implications for teams building production LLM systems.
1. Invest in metric feedback quality. GEPA's performance scales with the quality of your ASI. A metric that returns Prediction(score=0.4, feedback="Failed to enforce base-9 digit constraints") produces dramatically better proposals than Prediction(score=0.4, feedback="Score: 0.4"). If you are building LLM-as-judge metrics, include detailed natural language critiques.
2. Budget for reflection costs separately. GEPA uses two LLMs: a task model for evaluation and a reflection model for proposals. The reflection model is typically more expensive. On a medium budget with a 2-predictor/100-example task, expect 12-36 calls to the reflection LM. With gpt-4o reflecting and gpt-4o-mini running the program, reflection often costs more than evaluation.
3. Use the Pareto frontier for production. GEPA does not return just one prompt. It returns the best aggregate prompt from compile(), but detailed_results gives you the full Pareto frontier. You can deploy different candidates for different problem types. If one candidate excels at math and another at retrieval, route accordingly.
4. Combine with fine-tuning for maximum gains. The BetterTogether paper showed that GEPA + fine-tuning beats either alone. Start with GEPA for rapid prompt optimization (minutes to hours, API-only access). Then apply fine-tuning for additional gains when prompt quality plateaus.
The Bigger Picture: Reflection Over Reinforcement
GEPA's success points to a deeper shift in how we optimize AI systems. Reinforcement learning treats your system as a black box and nudges it with sparse reward signals. GEPA treats it as a text system that a language model can read, understand, and improve through reasoning about failures.
This is the difference between trial-and-error and actual diagnosis. RL needs thousands of rollouts to discover what a single reflection step can reveal. When your system's "parameters" are natural language instructions, the interpretable nature of text provides a richer learning medium than policy gradients derived from scalar rewards.
The paper's title makes the claim directly: "Reflective Prompt Evolution Can Outperform Reinforcement Learning." The benchmarks back it up. Across six tasks, GEPA outperforms GRPO by 6% on average and up to 20%, while using 35x fewer rollouts. That is 100-500 evaluations versus 5,000-25,000+ for RL methods.
For teams with expensive evaluation functions (scientific simulations, slow compilation, complex agent workflows with long tool calls), the sample efficiency alone justifies the switch. For teams optimizing closed-source models (GPT-5, Claude, Gemini) where gradient access is impossible, GEPA is the only game in town for structured prompt optimization.
Getting Started
- Install:
pip install gepa(standalone) or upgrade DSPy to 3.0+ (integrated) - Define a metric with feedback: Return
dspy.Prediction(score=float, feedback=str)instead of a bare float - Pick a budget: Start with
auto="medium"ormaxmetriccalls=150 - Choose a reflection LM: Use a strong model (gpt-5, Claude Opus) for reflection and a cheap model for evaluation
- Run:
gepa.compile(student=your_program, trainset=trainset) - Inspect: Set
trackstats=Trueand reviewdetailedresultsfor the full optimization trace
The standalone library works with any Python system, not just DSPy. If you are optimizing prompts outside the DSPy ecosystem, the gepa.optimize() API accepts a custom adapter that defines how your system evaluates candidates and returns traces.
What This Means for the Field
GEPA becoming DSPy's default optimizer is more than a version bump. It is an acknowledgment that reflective evolution, not Bayesian search or reinforcement learning, is the most practical approach for optimizing production AI systems today.
The reasons are straightforward. GEPA needs fewer examples. It produces interpretable traces. It works with closed-source models. It delivers higher accuracy. And it costs less to run.
For teams building prompt optimization pipelines, the shift is clear. Invest in rich evaluation feedback, not more training data. Budget for a strong reflection model, not more compute for random search. And treat your prompts as evolvable text, not fixed strings to be manually tweaked.
The Pareto frontier is no longer just an optimization concept. It is the production reality for prompt engineering.
GEPA paper: arXiv 2507.19457 (Agrawal et al., 2025), accepted as ICLR 2026 oral. GitHub: github.com/gepa-ai/gepa (4,922 stars). DSPy integration: dspy.GEPA in DSPy 3.0+. Standalone: pip install gepa.