Skip to main content
Back

GEPA Beats GRPO by 20% Using 35x Fewer AI Training Rollouts

GEPA optimizes prompts, code, and agent architectures using LLM reflection on execution traces, beating RL methods with 35x fewer rollouts.

Pro

  • GEPA optimizes prompts by having an LLM reflect on full execution traces instead of scalar rewards
  • Beats GRPO by up to 20% while using 35x fewer rollouts, per the ICLR 2026 Oral paper
  • Databricks reports open-source models plus GEPA beating Claude Opus 4.1 at 90x lower cost
  • optimize_anything API extends the loop to code, agent architectures, scheduling policies, and SVGs
  • Integrated with DSPy, MLflow, Pydantic AI, LangChain, Google ADK, and Comet ML Opik
  • MIT licensed, pip install gepa, works with API-only models and as few as 3 examples

A new optimizer called GEPA is quietly reshaping how teams tune LLM systems. Instead of nudging weights with scalar rewards, it reads full execution traces (error messages, reasoning logs, tool outputs) and rewrites the prompt itself. The repo has crossed 6,000 stars, the paper was accepted as an ICLR 2026 Oral, and Shopify's CEO publicly called it under-hyped. So it's worth unpacking what it actually does.

GEPA stands for Genetic-Pareto. It targets a specific pain point: reinforcement learning methods like GRPO often require thousands of rollouts to learn new tasks, and the authors argue that the interpretable nature of language provides a much richer learning medium for LLMs than policy gradients derived from sparse scalar rewards. The core bet is that natural language feedback carries more signal per rollout than a single reward number ever could.

Reading traces instead of counting rewards

The optimization loop looks less like gradient descent and more like a code review cycle. Given any AI system containing one or more LLM prompts, GEPA samples system-level trajectories such as reasoning, tool calls, and tool outputs, and reflects on them in natural language to diagnose problems, propose and test prompt updates, and combine complementary lessons from the Pareto frontier of its own attempts.

Concretely, each iteration does five things:

  1. Select a candidate prompt from the Pareto frontier of prior attempts (candidates that excel on different task subsets)
  2. Execute it on a minibatch, capturing full traces
  3. Reflect: a reflection LLM reads the traces and diagnoses failures
  4. Mutate: generate an improved candidate informed by accumulated lessons
  5. Accept if improved, and update the Pareto front

There's also a system-aware merge step that combines strengths from two Pareto-optimal candidates that excel on different tasks. The team calls the diagnostic feedback that evaluators emit Actionable Side Information (ASI), and treats it as the text-optimization analogue of a gradient. In practice this means your evaluator returns not just a score, but structured notes about what went wrong.

The numbers that got everyone's attention

The sample-efficiency claim is the headline. Across four tasks, GEPA outperforms GRPO by 10% on average and by up to 20%, while using up to 35x fewer rollouts. It also outperforms the leading prompt optimizer, MIPROv2, by over 10 percentage points, with a +12pp gain on AIME-2025.

Downstream applications tell a similar story:

  • Databricks: open-source models plus GEPA reportedly beat Claude Opus 4.1 at 90x lower cost
  • ARC-AGI agent: 32% to 89% accuracy through agent architecture discovery
  • Coding agent on Jinja: 55% to 82% resolve rate via auto-learned skills
  • Cloud scheduling: a policy discovered by GEPA beat expert heuristics by 40.2% on cost
  • DSPy Full Program adapter: 67% to 93% on MATH by evolving signatures, modules, and control flow

What GEPA discovers is not a two-line system prompt. It's a dense playbook. On HotpotQA it evolves an explicit multi-hop query construction strategy; on AIME it produces base-conversion rules, palindrome enumeration bounds, and identity-based simplifications for symmetric sums. The optimized prompts read like domain notes a senior engineer would hand to a new hire.

Excerpt of a GEPA-optimized AIME prompt containing detailed math competition strategies

Getting it running

Installation is a one-liner (pip install gepa), MIT licensed. The minimal API looks like this:

import gepa
trainset, valset, _ = gepa.examples.aime.init_dataset()
seed_prompt = {"system_prompt": "You are a helpful assistant..."}
result = gepa.optimize(
    seed_candidate=seed_prompt,
    trainset=trainset,
    valset=valset,
    task_lm="openai/gpt-4.1-mini",
    max_metric_calls=150,
    reflection_lm="openai/gpt-5",
)

You give it a seed prompt, a small dataset, a task model, and a reflection model (typically a stronger LLM). Under the hood, GEPA connects to your system through a GEPAAdapter interface with two methods: evaluate and make_reflective_dataset. Built-in adapters cover DSPy programs, generic RAG pipelines across ChromaDB/Weaviate/Qdrant/Pinecone, MCP tool descriptions, LangChain agents, and a terminal-use adapter for TerminalBench.

Beyond prompts

The optimize_anything API generalizes the same loop to any text artifact. You provide an evaluator that returns a score plus logged diagnostics, and GEPA evolves the artifact. That's how the team applied it to cloud scheduling policies, SVG generation, and agent architectures. You can also run it as an Agent Skill so Claude Code, Cursor, or other agents that read .claude/skills/ can drive optimization for you.

It's landed in most of the frameworks you probably already use: DSPy exposes it as dspy.GEPA, MLflow ships mlflow.genai.optimize_prompts(), Pydantic AI has an integration, Comet ML Opik uses it as its core optimizer, and Google's ADK offers an adk optimize command powered by GEPA inside the Gemini Enterprise Agent Platform.

When it actually helps

The README is refreshingly clear about the target regime. GEPA shines when rollouts are expensive (scientific simulations, agents with tool calls, slow compilation), when data is scarce (it can work with as few as 3 examples), when you only have API access to the model, and when you need interpretability because a human will read the resulting prompt. It also composes with RL: use GEPA for rapid initial optimization, then apply fine-tuning for the last mile.

The flip side: if your bottleneck is model capability rather than prompt quality, no amount of reflective evolution will help. And because the reflection LM has to be strong enough to diagnose failures in your traces, budget for a capable model there (GPT-5, Claude Opus, or similar). Practitioners report that the reflection-based approach means prompts can be optimized with 20 to 100 examples, making it practical for production scenarios where labeled data is expensive or domain-specific.

What actually shifted

The interesting update to make is not "there's a new prompt optimizer." It's that with rich textual feedback from execution traces, a search loop can discover behaviors previously assumed to require fine-tuning or RL, at 1/35th the rollout budget. That includes not just prompt wording, but agent architectures and system policies. If you have an evaluator and a stronger LLM sitting around, a large chunk of what teams currently do manually (rubric tweaking, few-shot curation, policy design) becomes a search problem you can hand off overnight.