Source-linked AI summary
GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning
Lakshya A Agrawal, Shangyin Tan, Dilara Soylu, Noah Ziems, Rishi Khare, Krista Opsahl-Ong, Arnav Singhvi, Herumb Shandilya, Michael J Ryan, Meng Jiang, Christopher Potts, Koushik Sen, Alexandros G. Dimakis, Ion Stoica, Dan Klein, Matei Zaharia, Omar Khattab
TL;DR
Adapting complex LLM systems with reinforcement learning can require many expensive rollouts. GEPA instead reflects on natural-language trajectories to evolve prompts, achieving stronger benchmark performance than GRPO and MIPROv2 with fewer rollouts.
Problem
Reinforcement-learning methods such as GRPO often require tens of thousands of rollouts to adapt LLM systems, making efficient use of each rollout important.
Method
GEPA evolves prompts through natural-language reflection on rollout trajectories and Pareto-based candidate selection for compound AI systems.
Results
Across six tasks, GEPA outperformed GRPO by 6% on average and up to 20% while using up to 35× fewer rollouts, and surpassed MIPROv2 across benchmarks and models.
Takeaways & Limitations
Language-based reflection can provide a scalable strategy for optimizing complex AI workflows, including inference-time code optimization, particularly in resource-constrained settings.
Takeaways & Limitations
GEPA’s performance depends on rollout-budget allocation and crossover timing, and fixed hyperparameters produced suboptimal choices for Qwen3 8B.
Abstract
from arXiv · showhide
Large language models (LLMs) are increasingly adapted to downstream tasks via reinforcement learning (RL) methods like Group Relative Policy Optimization (GRPO), which often require thousands of rollouts to learn new tasks. We argue that the interpretable nature of language often provides a much richer learning medium for LLMs, compared to policy gradients derived from sparse, scalar rewards. To test this, we introduce GEPA (Genetic-Pareto), a prompt optimizer that thoroughly incorporates natural language reflection to learn high-level rules from trial and error. Given any AI system containing one or more LLM prompts, GEPA samples trajectories (e.g., 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. As a result of GEPA's design, it can often turn even just a few rollouts into a large quality gain. Across six tasks, GEPA outperforms GRPO by 6% on average and by up to 20%, while using up to 35x fewer rollouts. GEPA also outperforms the leading prompt optimizer, MIPROv2, by over 10% (e.g., +12% accuracy on AIME-2025), and demonstrates promising results as an inference-time search strategy for code optimization. We release our code at https://github.com/gepa-ai/gepa .
1 INTRODUCTION
GEPA addresses the high rollout costs of reinforcement-learning-based adaptation by using natural-language reflection and Pareto-guided prompt evolution. Across six tasks, it improves performance over GRPO and MIPROv2 while using substantially fewer rollouts.
- Motivation: GEPA uses natural-language reflection on serialized reasoning traces, tool calls, tool outputs, and reward-function details to extract richer learning signals than scalar rewards.The approach is motivated by the claim that these trajectories are readily understood by modern LLMs.
- Method: GEPA combines reflective prompt mutation with multi-objective evolutionary search over a Pareto front of candidate prompts.Candidates accumulate lessons from rollouts, while Pareto-front exploration avoids relying only on the globally best prompt.
- Results: 6% average gain across six tasks and up to 20% improvement over GRPO were achieved on Qwen3 8B using up to 35× fewer rollouts.The comparison uses GRPO with 24k rollouts as reported in the evaluation summary.
- Results: GEPA surpassed MIPROv2 on all evaluated benchmarks and models, achieving +13% aggregate gains compared with MIPROv2’s +5.6%.The paper evaluates multi-hop reasoning, mathematics, instruction following, privacy-aware delegation, and retrieval-augmented verification.
- Extensions: GEPA also shows promise for inference-time code optimization and adversarial prompt search, while reflective updates can produce large gains from a single update.The introduction connects these capabilities with improved sample efficiency and robust generalization in complex workflows.
2 PROBLEM STATEMENT
The paper formulates compound AI systems as modular LLM-and-tool workflows and defines optimization as improving their prompts or weights under a limited rollout budget. The central challenge is extracting maximal learning signal from each expensive rollout.
- System formulation: A compound AI system is a modular workflow of one or more LLM invocations, external tools, and arbitrary control flow.This definition includes agents, multi-agent systems, and scaffolding techniques such as ReAct.
- System formulation: Each language module has a prompt, model weights, input schema, and output schema, while control flow orchestrates module calls and tool APIs.The system’s global inputs and outputs are represented separately from its module-level components.
- Optimization objective: The optimization problem seeks prompts and weights that maximize held-out output quality under a rollout budget B.Task instances pair inputs with evaluator metadata such as gold answers, rubrics, or code unit tests.
- Sample-efficient optimization: Rollouts are expensive because they require invoking the compound system and evaluating its output, motivating sample-efficient optimization.The budget applies to training-data rollouts while performance is assessed on held-out data.
- Problem statement: The core challenge is extracting maximal learning signal from every expensive rollout for adaptation in low-data or budget-constrained settings.This frames the problem independently of any particular optimizer.
3 GEPA: REFLECTIVE PROMPT EVOLUTION
GEPA optimizes compound AI systems by evolving prompts through natural-language reflection, selective evaluation, and Pareto-based candidate search. Its design uses rollout traces and diverse candidate selection to accumulate task-specific lessons while avoiding local optima.
- 3 GEPA: REFLECTIVE PROMPT EVOLUTION: GEPA evolves only prompts while keeping the underlying LLM weights fixed, using a rollout budget, task metric, and feedback function as inputs.The optimizer targets the prompt set ΠΦ rather than ΘΦ.
- 3 GEPA: REFLECTIVE PROMPT EVOLUTION: Each iteration selects promising candidates, proposes a reflective mutation or crossover, tests it on a minibatch, and retains improved variants with ancestry records.Retained candidates are subsequently evaluated on Dpareto for selection.
- 3 GEPA: REFLECTIVE PROMPT EVOLUTION: Figure 3 combines reflective mutation or system-aware merging with minibatch screening, larger-dataset evaluation, and Pareto sampling to preserve diversity and support generalization.The workflow avoids always mutating only the best-performing candidate.
- 3 GEPA: REFLECTIVE PROMPT EVOLUTION: GEPA derives prompt updates from execution traces that expose module inputs, outputs, reasoning, and outcome-linked diagnostic information.These traces help attribute successes or failures to specific module-level decisions.
- 3 GEPA: REFLECTIVE PROMPT EVOLUTION: A reflection language model receives the current prompt, trajectory, score, and feedback, then proposes revised module instructions that are retested before admission.The updated program enters the candidate pool only when its minibatch score improves.
- 3 GEPA: REFLECTIVE PROMPT EVOLUTION: GEPA extends scalar rewards with evaluation traces, such as compiler errors or module-specific evaluator feedback, to support reflective credit assignment and targeted updates.Human-written explanations can also serve as auxiliary feedback when available.
- 3 GEPA: REFLECTIVE PROMPT EVOLUTION: Figure 5 illustrates a trajectory from candidate 0 to candidate 11 in PUPA, where successive reflective updates add targeted task-specific nuances.The trajectory shows how prompt changes accumulate lessons across optimization steps.
- 3.1 PARETO-BASED CANDIDATE SELECTION: Naively refining only the best candidate can exhaust the budget at a local optimum, so GEPA retains candidates that lead on at least one task and samples among them.Sampling probabilities are weighted by how many tasks each candidate leads, balancing exploration and exploitation.
4 EVALUATION
Across six diverse benchmarks and two models, GEPA consistently achieves strong performance with substantially fewer rollouts than competing optimizers, while Pareto selection and reflective instruction evolution improve search efficiency, generalization, and prompt compactness.
- Sample efficiency: GEPA outperforms GRPO on five of six tasks, using up to 35× fewer rollouts and matching GRPO’s best validation scores with 102–179 train rollouts on four tasks.GEPA reaches optimal test performance with 4–35× fewer rollouts; GEPA+Merge widens the gap to 21% at a comparable rollout budget.
- Comparisons: GEPA consistently outperforms MIPROv2 across six tasks and two models, with margins up to 11.1% for GPT-4.1 Mini and 10.3% for Qwen3 8B.Aggregate gains over baseline are +13.33% for GEPA and +12.19% for GEPA+Merge, versus +5.64% for MIPROv2.
- Candidate selection: Pareto-based candidate selection improves optimization trajectories by balancing exploration and exploitation, producing higher-performing solutions within the same rollout budget.The strategy considers all Pareto-optimal candidates rather than repeatedly refining only the current best candidate.
- Prompt efficiency: GEPA and GEPA+Merge produce prompts up to 9.2× shorter than MIPROv2 prompts, reducing input-token costs and latency while retaining performance improvements.The paper also reports that higher-performing optimizers tend to produce shorter prompts.
- Crossover: GEPA+Merge can improve GEPA by as much as 5%, but its effectiveness depends on model-specific budget allocation and crossover timing.Fixed hyperparameters worked especially well for GPT-4.1 Mini but degraded performance on Qwen3 8B.
- Generalization: GEPA-optimized prompts generalize across models: prompts optimized with Qwen3 8B yield a +9.00% aggregate improvement when evaluated unchanged on GPT-4.1 Mini.This transfer exceeds the reported gains of MIPROv2, TextGrad, and Trace, despite those baselines being optimized directly on GPT-4.1 Mini.
5 EXTENDED APPLICATIONS OF GEPA
GEPA extends prompt optimization to inference-time code search and adversarial prompt search, using textual feedback to improve kernels and expose instruction-level brittleness.
- Inference-Time Search: GEPA can overfit a task set during inference-time search by using the tasks as its training and Pareto sets.This setup iteratively proposes better solutions for the specified tasks.
- Inference-Time Search: 30.52% mean vector utilization was achieved on AMD NPU kernels with GEPA, compared with 4.25% for GPT-4o with sequential refinement.RAG and MIPROv2 improved sequential refinement to 16.33% and 19.03%, respectively.
- Inference-Time Search: Over 20% fast1 was reached on 35 CUDA KernelBench tasks as GEPA’s search budget increased, versus close to 0% for GPT-4o.The agent allowed up to five sequential refinements based on environment feedback.
- Adversarial Prompt Search: GEPA’s learned adversarial instruction reduced AIME-2025 pass@1 from 76% to 10% while preserving the task description and answer-format directive.The search evolved a single universal instruction using AIME 2022–2024 problems and evaluated it on AIME-2025.
- Adversarial Prompt Search: Manual inspection linked the adversarial drop to distractors interacting with a strict literal formatting constraint, causing frequent literal placeholder outputs.The failure was attributed to the interaction rather than the formatting requirement alone.
- Adversarial Prompt Search: Adversarial prompt search provides automated worst-case robustness probes and reusable stress tests for instruction-following systems.The resulting prompts could supply targeted data for finetuning or safety training.
6 RELATED WORK
GEPA builds on automatic prompt optimization, evolutionary search, language-space learning, and compound-system optimization while combining textual environment feedback with Pareto-aware submodule evolution.
- Prompt Optimization: GEPA differs from prior automatic prompt optimizers by using textual environment feedback, Pareto-aware candidate search, and per-submodule evolution.Earlier automatic methods sought to scale manual prompt engineering such as chain-of-thought prompting.
- Evolutionary Methods: Evolutionary prompt methods include population evolution and quality-diversity adversarial generation, whereas GEPA adds domain-specific feedback for targeted mutations.Other evolutionary systems apply search directly to code rewriting.
- Language-Space Learning: Language-space alternatives include in-context self-bootstrapping, workflow memory, skills, and test-time strategy synthesis; GEPA uses examples to propose task-specific instructions.The cited alternatives learn or synthesize strategies in language rather than relying solely on scalar rewards.
- Compound AI Systems: DSPy, TextGrad, and MIPROv2 optimize compound AI systems through examples, textual feedback, or Bayesian optimization, but largely rely on global rewards.Agent-Pro instead evolves agent policies through belief generation and reflection on interactive experiences.
7 CONCLUSION
The conclusion presents GEPA as a reflective, Pareto-based optimizer that improves sample efficiency across tasks and models, with additional promise for inference-time code search.
- 7 CONCLUSION: GEPA combines explicit reflection with Pareto-based selection to optimize arbitrary LLM agents and workflows.Its diverse pool of Pareto-optimal candidates supports rapid adaptation to new tasks.
- 7 CONCLUSION: GEPA is reported to outperform GRPO in sample efficiency and MIPROv2 in prompt optimization across the paper’s evaluations.The conclusion frames language-based reflection as a scalable strategy for complex workflows in resource-constrained settings.
- 7 CONCLUSION: The paper also reports promising inference-time search results, including code generation in challenging domains.The conclusion identifies inference-time search as an additional application beyond sample-efficient adaptation.
D GEPA ALGORITHM AND METHODOLOGY DETAILS
The GEPA algorithm includes Pareto-based candidate selection and a merge strategy that combines complementary optimization lineages under explicit conditions.
- GEPA Algorithm: GEPA’s Pareto-based selection chooses candidates from a pool of high-performing alternatives rather than retaining only the global best prompt.The selection mechanism supports exploration of diverse optimization paths.
- Merge Strategy: GEPA+Merge combines candidates only when they share an ancestor, optimize disjoint prompt sets, are Pareto-optimal, and both improve aggregate ancestor performance.The strategy is intended for candidates that have learned complementary strategies.
E.1 BENCHMARKS, REFERENCE COMPOUND AI SYSTEMS, AND FEEDBACK FUNCTIONS
The evaluation suite covers diverse reasoning, mathematics, instruction-following, privacy, and retrieval-verification tasks, each paired with compound AI systems and textual feedback functions.
- HotpotQA: HotpotQA uses a modified multi-hop question-answering system whose feedback identifies relevant documents still needing retrieval.The setup uses 150 training, 300 validation, and 300 test examples.
- IFBench: IFBench tests generalization to 58 new and out-of-distribution output constraints and instructions.A two-stage system answers queries and then rewrites responses according to satisfied and failed constraints.
- AIME-2025: AIME-2025 contains 30 questions from two 15-question problem sets, with prior AIME questions used for training and validation.The optimized system is a single-step ChainOfThought program.
- LiveBench-Math: LiveBench-Math contains 368 questions retrieved on July 30, 2025 and split equally into training, validation, and test sets.It also uses a single-step ChainOfThought system.
- HoVer: HoVer evaluates multi-hop retrieval of all relevant Wikipedia documents for claim verification using a program with query writers, document summarizers, and textual retrieval feedback.The standard setup uses up to three hops and 150 training, 300 validation, and 300 test examples.
E.2 MODELS AND INFERENCE PARAMETERS
Experiments compare GEPA and baseline optimizers on compound AI systems instantiated with one open-source model and one commercial model under a shared context limit.
- GEPA and baseline optimizers are evaluated with Qwen3 8B and GPT-4.1 Mini, representing open-source and commercial model families.Each system uses the same model across its modules.
- All models use an inference context window of up to 16384 tokens.
E.3 COSTS
The complete GPT-4.1 Mini experiment suite costs under $500, with GEPA and GEPA-Merge costing less than the other listed optimizers.
- $86 is the total cost of GEPA experiments with GPT-4.1 Mini.GEPA-Merge costs $67, MIPROv2 costs $76, and Trace and TextGrad cost $172; all experiments together cost under $500.
E.4 OPTIMIZERS
The study compares direct evaluation, Bayesian prompt optimization, trace-based optimizers, GRPO, and GEPA variants under specified training and search configurations.
- Baseline: The base program is evaluated directly without further optimization.
- MIPROv2: MIPROv2 jointly optimizes instructions and demonstrations using Bayesian optimization with TPE-proposed candidate assignments.It selects and validates the most probable optimized program configuration.
- Trace and TextGrad: Trace and TextGrad use the same program architecture, initial prompt, and data splits as GEPA for comparison.
- GRPO: GRPO estimates advantages in a group-relative manner, using separate implementations for compound and single-module systems.
- GRPO configuration: Compound-system GRPO training uses group size 12, total batch size 48, LoRA, learning rate 1 × 10^-5, and gradient clipping of 0.1.
- GRPO configuration: Single-module GRPO uses full-parameter finetuning, group size 16, global batch size 32, learning rate 1 × 10^-6, and KL regularization.
- GRPO configuration: GRPO hyperparameters for learning rate, beta, and norm clipping are manually explored across training runs.
- GEPA: GEPA is evaluated with GEPA, GEPA+Merge, SelectBestCandidate, and SelectBestCandidate+Merge variants.The GEPA runs use minibatches of 3, and merge is invoked at most 5 times when enabled.
F RESULTS AND ANALYSIS (CONTD.)
The results section visualizes final test performance, performance-versus-rollout learning curves, and generalization gaps across optimization methods.
- Figure 10 reports final test-set performance for aggregate and individual benchmarks.
- Figures 12–15 show performance-versus-rollout curves for all optimizers across the evaluated benchmarks.
- Figure 16 visualizes the generalization gap for different optimization methods.
I COST VS. PERFORMANCE ANALYSIS FOR OPTIMIZED SYSTEMS
The analysis compares optimized systems by downstream cost proxy and achieved performance, emphasizing GEPA’s shorter prompts alongside higher performance than MIPROv2.
- GEPA’s prompts are around 33% shorter than MIPROv2’s prompts while achieving higher performance.Aggregate prompt length is used as a proxy for downstream cost.
- Figure 17 plots final optimized-system aggregate prompt lengths against achieved performance for each optimizer.
- Figures 19–26 present genetic search trees for various GEPA configurations and the SelectBestCandidate ablation.
K VISUALIZING THE ITERATIVE REFINEMENT ACHIEVED BY GEPA
The section visualizes GEPA’s iterative prompt refinement, search behavior, generalization, and token usage across benchmarks, models, and privacy-preserving prompt examples.
- Search traces and prompt examples: The PUPA subsection presents full prompts produced during optimization after Figure 5 summarized their refinements.
- Final performance and learning behavior: Figure 10 visualizes final test-set performance for aggregate and individual benchmarks across both models.
- Final performance and learning behavior: Figure 11 compares GEPA with GRPO using full-parameter finetuning on 2-hop HoVer and reports a gap mirroring the LoRA comparison.
- Final performance and learning behavior: Figures 12–15 plot rollout versus score for Hotpot QA, IFBench, HoVerBench, and PUPA across models and settings.
- Generalization and prompt efficiency: Figure 16 compares generalization gaps, with reflective prompt-evolution instructions associated with stronger generalization and improved overall performance.
- Generalization and prompt efficiency: GEPA consistently produces prompts around less than 33% of MIPROv2’s size while achieving higher performance.GEPA uses most prompt tokens for instructions, whereas MIPROv2 uses most for few-shot examples.
- Privacy-preserving prompt examples: The PUPA prompt examples instruct an external LLM to assist with private queries without receiving private, identifying, or sensitive information.The examples require preserving the user’s essential task while generalizing or omitting sensitive details.
L EXAMPLES OF BEST PROMPTS FOR EVERY BENCHMARK
The appendix presents optimized prompts and examples for HotpotQA, showing how GEPA-generated instructions support second-hop retrieval and final multi-hop answer synthesis. It also includes examples where the system identifies unsupported claims rather than conflating disconnected facts.
- L EXAMPLES OF BEST PROMPTS FOR EVERY BENCHMARK: GEPA’s appendix lists optimized prompts for each benchmark-model configuration, with multiple prompt boxes for compound-system modules.MIPROv2 prompts include up to four few-shot examples, while GEPA prompts contain optimized instructions.
- L.1 HOTPOTQA, GPT-4.1 MINI: The optimized HotpotQA prompts are described as informative for next-hop retrieval and foundational for final answer extraction.The appendix also shows a GEPA-generated prompt configuration and reports this approach as effective for the benchmark workflow.
- L.1 HOTPOTQA, GPT-4.1 MINI: For HotpotQA, the second-hop module uses question and summary_1 to generate a query targeting missing documents needed for complete answering.The prompt emphasizes retrieving complementary documents rather than repeating the original question or known first-hop facts.
- L.1 HOTPOTQA, GPT-4.1 MINI: Examples instruct query generation to infer broader or related entities from retrieved summaries while avoiding direct paraphrase and duplication.The query should shift toward the missing piece that links or complements first-hop evidence.
- L.1 HOTPOTQA, GPT-4.1 MINI: The HotpotQA final-answer module combines question, summary_1, and summary_2 into a concise answer through multi-hop evidence synthesis.The prompt explicitly asks the system to analyze and integrate the intermediate summaries.
- L.1 HOTPOTQA, GPT-4.1 MINI: A HotpotQA example answers that Giovanni di Bicci de’ Medici founded the Medici Bank, using the relationship to the second Duke of Florence.The reasoning connects the historical relationship to the requested institution.
- L.2 HOTPOTQA, QWEN3 8B: A Qwen3 8B HotpotQA example identifies film director as the common occupation of Tay Garnett and Alexander Kluge.The answer selects the shared profession from their individually described occupations.
- L.6 HOVER, QWEN3 8B: For HoVer with Qwen3 8B, the system rejects a claim because the passages establish Texas’s recorded-history date and Houston’s founding separately without linking them.The example illustrates refusing an unsupported inference between two individually supported facts.
M GEPA GENERATED PROMPTS FOR KERNEL GENERATION
GEPA-generated prompts for kernel generation combine implementation guidance with correctness and performance requirements. In NPUEval, the same GPT-4o agent improved from 4.25% to 26.85% using a GEPA-generated prompt.
- M.1 NPUEVAL: KERNEL CODE GENERATION FOR NEW HARDWARE ARCHITECTURE: 26.85% score was achieved by the GEPA-generated NPUEval prompt with GPT-4o, compared with 4.25% from a simple prompt using the same agent.The comparison isolates prompt optimization while holding the GPT-4o agent constant.
- M.2 KERNELBENCH: CUDA KERNEL CODE GENERATION FOR NVIDIA GPUS: The generated code is required to provide real, compiling, functional output named ModelNew rather than pseudocode or testing code.The instructions also require correctness while targeting performance improvements.
- M.2 KERNELBENCH: CUDA KERNEL CODE GENERATION FOR NVIDIA GPUS: The CUDA-kernel prompt instructs the model to identify computationally intensive, parallelizable operators and opportunities for operator fusion.The guidance includes combining multiple operations, such as matrix multiplication and activation functions, into one kernel.
- M.2 KERNELBENCH: CUDA KERNEL CODE GENERATION FOR NVIDIA GPUS: torch.utils.cpp_extension.load_inline is used to compile custom CUDA code and integrate the resulting kernels into a PyTorch model.The example replaces a PyTorch operation with a compiled elementwise-add CUDA function exposed through a Python module.
- M.2 KERNELBENCH: CUDA KERNEL CODE GENERATION FOR NVIDIA GPUS: The example kernel computes elementwise addition by assigning indexed work to threads and launching a configured grid of blocks and threads.The prompt gives a block size of 256 and computes the number of blocks from the input size.
- M.2 KERNELBENCH: CUDA KERNEL CODE GENERATION FOR NVIDIA GPUS: Testing guidance compares custom-kernel outputs with the original PyTorch operator and uses profiling, reference outputs, and tolerances for floating-point discrepancies.The prompt also includes CUDA error checking, debugging, profiling, compatibility, and namespace guidance.
- M.2 KERNELBENCH: CUDA KERNEL CODE GENERATION FOR NVIDIA GPUS: The implementation workflow covers custom __global__ kernels, thread indexing, GPU memory allocation, shared memory, coalesced accesses, and boundary handling.It also specifies numerical-stability checks and avoidance of out-of-bounds accesses.
- M.2 KERNELBENCH: CUDA KERNEL CODE GENERATION FOR NVIDIA GPUS: The prompt recommends mixed precision, Tensor Cores, and avoiding divergent execution paths to improve parallel performance.These techniques are presented alongside shared-memory reuse as kernel optimization strategies.