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
Optimizing LLM systems for downstream tasks often requires many expensive rollouts. GEPA uses natural-language reflection and Pareto-based prompt evolution, outperforming GRPO by an average of 6% across six tasks while using up to 35x fewer rollouts.
Problem
Existing reinforcement-learning approaches for optimizing LLM systems can require tens of thousands of rollouts to fit new tasks.
Source: §1 · p. 2Method
Results
+6% average gain across six tasks, with up to 20% improvement over GRPO using up to 35x fewer rollouts.
Source: §1 · p. 2Takeaways & Limitations
Language-based reflection can provide a sample-efficient strategy for optimizing complex AI workflows and shows promise for inference-time code search.
Source: §1 · p. 2, §7 · p. 15GEPA+Merge can degrade performance on Qwen3 8B when shared hyperparameters poorly allocate budget between mutation and crossover.
Source: §4 · p. 11
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 optimizes prompts through natural-language reflection on serialized LLM trajectories and Pareto-based evolutionary search, addressing the rollout inefficiency of scalar-reward reinforcement learning. Across six tasks, it improves performance over GRPO and MIPROv2 while using substantially fewer rollouts, and extends to inference-time code optimization and adversarial prompt search.
Motivation
- GEPA addresses costly adaptation settings where RL methods such as GRPO (Shao et al., 2024) typically require tens of thousands of rollouts and expensive tool calls.The rollout burden is especially problematic when inference budgets are limited or model-weight finetuning is unavailable.Source: §1 · p. 2
- GEPA reflects on serialized reasoning, tool calls, outputs, and reward-function traces to exploit LLM language priors more effectively than scalar policy-gradient feedback.The approach is motivated by the richer information preserved in natural-language trajectories compared with collapsed end-of-rollout rewards.Source: §1 · p. 2
Method
- GEPA evolves prompts through natural-language mutations and maintains a Pareto front of strong candidates to combine complementary lessons and avoid local optima.It stochastically explores high-performing prompts for different problem instances rather than retaining only the global best.Source: §1 · p. 2
Evaluation
- Up to 20% improvement over GRPO with up to 35× fewer rollouts, averaging +6% across six tasks on Qwen3 8B.GRPO used 24k rollouts in this comparison.Source: §1 · p. 2
- +13% aggregate gains over MIPROv2 across all benchmarks and models, more than double its +5.6% gains.GEPA surpasses MIPROv2 on every evaluated benchmark and model.Source: §1 · p. 2
Applications
- GEPA also supports inference-time search for code optimization on NPUEval and KernelBench and adversarial prompt search.The paper reports these applications in Sections 5.1 and 5.2.Source: §1 · p. 2
2 PROBLEM STATEMENT
The paper formulates optimization for compound AI systems comprising modular LLM invocations and tool calls under arbitrary control flow. It seeks prompt and weight parameters that maximize held-out performance while extracting maximal learning signal from a limited budget of expensive rollouts.
- Compound AI systems are modular collections of LLM invocations, potentially interleaved with external tools and coordinated through arbitrary control flow.This class includes agents, multi-agent systems, and scaffolding techniques such as ReAct and Archon.Source: §2 · pp. 2–3
- Each system comprises language modules with prompts, weights, input/output schemas, and control logic that sequences, conditionally invokes, and repeatedly reuses modules or tools.The formal system is Φ = (M, C, X, Y), with each module Mi = (πi, θi, Xi, Yi).Source: §2 · p. 4
- The optimization jointly varies module prompts and weights to maximize an output-quality metric over a task distribution, enabling comparison across algorithms operating in different parameter spaces.Quality is measured against evaluator metadata using metrics such as exact match, F1, or pass rate.Source: §2 · p. 4
- The sample-efficient objective is to maximize held-out performance using no more than B costly training rollouts, making every rollout’s learning signal especially valuable.Rollouts include invoking Φ and evaluating its output on training data, motivating adaptation in low-data or budget-constrained settings.Source: §2 · p. 4
3 GEPA: REFLECTIVE PROMPT EVOLUTION
GEPA is a sample-efficient optimizer that evolves prompts while keeping the underlying LLM weights fixed, combining reflective natural-language feedback, genetic updates, and Pareto-based candidate selection. Its loop uses execution and evaluation traces to diagnose module-level failures, test targeted revisions, and preserve diverse high-performing candidates.
3 GEPA: REFLECTIVE PROMPT EVOLUTION
- GEPA evolves only a system’s prompts, keeping its underlying LLM weights fixed while optimizing performance under a rollout budget.It takes a prompted AI system, training data, task metric, feedback function, and rollout budget as inputs.Source: §3 · p. 4
- GEPA’s genetic loop repeatedly selects candidates, proposes reflective mutations or crossovers, evaluates variants, and retains improvements with ancestry records.Candidates inherit learning signals from parents and their own rollouts, accumulating knowledge along the genetic tree.Source: §3 · pp. 4–5
- GEPA’s candidate-generation process evaluates proposed prompts on minibatches before testing improved candidates on a larger validation set and returning the best aggregate candidate.The overview also highlights reflective mutation, system-aware merging, and Pareto-based sampling as mechanisms supporting sample efficiency and generalization.Source: Figure 3 · p. 5, §3 · p. 5
- Reflective mutation uses execution traces and outcomes to assign credit to modules and generate targeted prompt revisions that can change whole-system behavior.A reflection model receives the current prompt, program trajectory, score, and textual feedback before proposing revised instructions.Source: §3 · pp. 5–6
- GEPA extends scalar rewards into textual feedback by extracting evaluation traces such as compiler errors, failed rubrics, and module-specific assessments.Human-written explanations can also augment training data as auxiliary feedback when rollout feedback is limited or unavailable.Source: §3 · pp. 6–7
3.1 PARETO-BASED CANDIDATE SELECTION
- Always selecting the best candidate can trap optimization in a local optimum by repeatedly refining one strategy until the budget is exhausted.This failure mode motivates GEPA’s alternative candidate-selection strategy.Source: §3.1 · p. 7
- Pareto-based selection retains candidates that lead on at least one task, prunes strictly dominated candidates, and samples survivors according to their task-lead frequency.This illumination strategy balances exploration and exploitation while helping GEPA escape local optima without inflating the search.Source: §3.1 · pp. 7–8
4 EVALUATION
Across six benchmarks and two models, GEPA achieves strong sample-efficient optimization, outperforming GRPO and MIPROv2 while also generalizing across models. Its Pareto-based selection, compact instruction prompts, and optional crossover mechanism further explain its performance and efficiency.
Sample efficiency and benchmark results
- GEPA exceeds GRPO on 5 of 6 tasks by up to 19.0% while using up to 35× fewer rollouts, and GEPA+Merge widens the advantage to 21%.GEPA matches GRPO’s best validation scores after only 243, 402, 330, 1143, 1179, and 306 rollouts, reaching optimal performance with 4–35× fewer rollouts.Source: Table 1 · p. 8, §4 · p. 9
Comparison with prompt optimizers
- GEPA consistently outperforms MIPROv2 across six tasks and two models, with margins up to 11.1% and aggregate gains of +13.33% for GEPA versus +5.64% for MIPROv2.GEPA’s instruction-only optimization surpasses MIPROv2’s joint instruction and few-shot optimization; GEPA and GEPA+Merge more than double MIPROv2’s aggregate gains.Source: Table 2 · p. 8, §4 · p. 9
Candidate selection
- Pareto-based candidate selection yields a +12.44% improvement, surpassing greedy and beam-search gains of +6.05% and +5.11%.By considering all Pareto-optimal candidates, GEPA balances exploration and exploitation and avoids the local optima observed when selecting only the best candidate.Source: Table 3 · p. 10, §4 · pp. 10–11
Prompt efficiency
- GEPA and GEPA+Merge produce prompts up to 9.2× shorter than MIPROv2 while retaining performance gains, reducing input-token cost and serving latency.Reflectively evolved instructions remain compact even on complex tasks where optimized few-shot demonstrations can become prohibitively long.Source: §4 · p. 11
System-aware crossover
- GEPA+Merge improves over GEPA by as much as 5% and adds 2% in aggregate by combining complementary strategies from distinct optimization lineages.The benefit is strongest for GPT-4.1 Mini, whereas fixed crossover settings can degrade performance on Qwen3 8B; adaptive budget allocation and merge timing remain open questions.Source: §4 · p. 11
Cross-model generalization
- GEPA-Qwen-Opt transfers from Qwen3-8B to GPT-4.1-Mini with a +9.00% aggregate gain across six benchmarks, outperforming directly optimized MIPROv2, TextGrad, and Trace baselines.Its gains reach +27.67% on HotpotQA, compared with baseline gains of +5.64%, +6.11%, and +3.27%, respectively.Source: Table 2 · p. 8, §4 · p. 11
5 EXTENDED APPLICATIONS OF GEPA
GEPA extends beyond sample-efficient adaptation as an inference-time search method for code generation and as an adversarial prompt-search method. It improves kernel generation through iterative prompt evolution and exposes severe, task-preserving instruction-following vulnerabilities.
5.1 GEPA FOR INFERENCE-TIME SEARCH (CONTD.)
- Domain-specific retrieval and cached stochasticity control let GEPA use compiler errors, profiling results, manuals, and deterministic evaluations to guide prompt evolution.The approach overfits a task set at inference time, allowing lessons from one task’s rollout to transfer to other tasks.Source: §5.1 · p. 12
- These inference-time search results are preliminary and require systematic study before claims of broader generalization to code generation or domain adaptation.The authors identify domain-specific textual feedback as a promising ingredient for future work.Source: §5.1 · p. 12
- 30.52% mean vector utilization: GEPA improved AMD NPU kernel generation beyond GPT-4o’s 4.25%, RAG’s 16.33%, and MIPROv2’s 19.03%.Several GEPA-generated kernels reached 70% utilization, while a single GEPA-generated prompt achieved 26.85%, without runtime RAG.Source: §5.1 · p. 12, Figure 7 · p. 13
- Over 20% of 35 KernelBench tasks: GEPA raised GPT-4o’s close-to-0% fast1 score through increasing search budgets using up to five sequential refinements.The CUDA experiments used the KernelBench representative subset across three difficulty levels and incorporated environment feedback.Source: §5.1 · p. 12, Figure 8 · p. 13
5.2 GEPA FOR ADVERSARIAL PROMPT SEARCH (CONTD.)
- 76% to 10%: GEPA’s adversarial instruction reduced GPT-5 Mini’s AIME-2025 pass@1 while preserving the task description and answer-format directive.The instruction was evolved from AIME 2022–2024 problems using 150 generations and evaluated on 30 AIME-2025 problems with 5 runs per problem.Source: §5.2 · pp. 12, 14
- Manual inspection attributed the adversarial degradation to distractors interacting with a strict literal formatting constraint, which produced repeated placeholder answers.GEPA’s universal, task-preserving distractors can serve as automated robustness probes, regression tests, and targeted data for finetuning or safety training.Source: §5.2 · p. 14
6 RELATED WORK
GEPA extends automatic prompt optimization with textual environment feedback, Pareto-aware candidate search, and per-submodule evolution. It differs from related evolutionary, language-space learning, and compound-system methods by producing task-specific rules and matching designs to individual examples.
Automatic prompt optimization
- GEPA extends automatic prompt optimization with textual environment feedback, Pareto-aware search, and evolution strategies applied per AI-system submodule.Earlier methods use LLMs to optimize prompts automatically, including chain-of-thought prompting Wei et al. (2023) and automatic approaches Zhou et al. (2022); Yang et al. (2024); Agarwal et al. (2024); Fernando et al. (2024).Source: §6 · p. 14
Evolutionary optimization
- Unlike EvoPrompt and Rainbow Teaming, GEPA uses domain-specific feedback for targeted mutations and combines Pareto-frontier optimization with prompt evolution across domains.AlphaEvolve (Novikov et al., 2025) and OpenEvolve apply evolutionary search directly to code rewriting, whereas GEPA transfers tactics from related problems.Source: §6 · p. 14
Feedback-driven improvement
- GEPA learns task-specific rules from examples rather than relying solely on slow scalar rewards, complementing language-space methods such as in-context bootstrapping, workflow memory, and test-time strategy synthesis.Related approaches include majority-voting reinforcement learning Zuo et al. (2025), in-context methods Shinn et al. (2023); Madaan et al. (2023); Monea et al. (2025); Xu et al. (2025a); Feng et al. (2025); Cheng et al. (2024), workflow memory and skills Wang et al. (2024; 2025c), and Dynamic Cheatsheet Suzgun et al. (2025) and reasoning cache Chen et al. (2025c).Source: §6 · pp. 14–15
Compound AI systems
- For compound AI systems, GEPA combines global rewards with per-module textual feedback and maintains a Pareto frontier over instances to explore diverse designs before robust convergence.DSPy, TextGrad, MIPROv2, Agent-Pro, and Optimas respectively search examples, backpropagate textual feedback, jointly optimize instructions and examples, evolve agent policies, or use locally aligned rewards.Source: §6 · p. 15
7 CONCLUSION … C GEPA’S REFLECTION AND PROMPT UPDATE META PROMPT
GEPA optimizes arbitrary LLM agents and workflows through explicit reflection and Pareto-based candidate selection, achieving strong sample efficiency and benchmark performance. The appendix further documents GEPA’s supporting materials, LLM usage, and reflection-driven prompt-update procedure.
7 CONCLUSION
- GEPA combines explicit natural-language reflection with Pareto-based selection to rapidly adapt arbitrary LLM agents and workflows, outperforming GRPO and leading prompt optimizers.The approach maintains a diverse pool of Pareto-optimal candidates and is especially promising for resource-constrained optimization.Source: §7 · p. 15
- GEPA also shows promise as an inference-time search strategy for writing code in challenging domains.Source: §7 · p. 15
A APPENDIX OUTLINE
- The appendix outlines materials covering GEPA’s methodology, evaluations, results, inference-time search, adversarial prompt search, budget curves, generalization, costs, search trees, prompt examples, and reflection calls.Source: A APPENDIX OUTLINE · p. 22
B USAGE OF LARGE LANGUAGE MODELS
- The authors used LLM assistants to polish prose and code assistants to implement their original designs, while retaining authorship of the scientific contributions, methods, ideas, and core results.Source: B USAGE OF LARGE LANGUAGE MODELS · p. 22
C GEPA’S REFLECTION AND PROMPT UPDATE META PROMPT
- GEPA’s meta-prompt asks an assistant to replace a current instruction using task inputs, responses, and feedback from a minibatch of examples.Source: C GEPA’S REFLECTION AND PROMPT UPDATE… · p. 22
- The meta-prompt instructs the assistant to infer the task and input format, incorporate domain-specific facts, and preserve generalizable solution strategies in the new instruction.Source: C GEPA’S REFLECTION AND PROMPT UPDATE… · p. 23
- The resulting instruction must be provided within code blocks, and Figure C depicts this reflective refinement process based on input–output examples and environmental feedback.Source: C GEPA’S REFLECTION AND PROMPT UPDATE… · p. 23
D GEPA ALGORITHM AND METHODOLOGY DETAILS · D.1 MERGE: SYSTEM-AWARE CROSSOVER STRATEGY FOR COMPOUND AI OPTIMIZATION
GEPA’s core algorithm uses Pareto-based candidate selection, while its system-aware merge strategy combines complementary prompt optimizations under strict lineage and performance conditions.
D GEPA ALGORITHM AND METHODOLOGY DETAILS
- GEPA’s core algorithm includes Pareto-based candidate selection.Figure 4 presents both the core GEPA algorithm and its Pareto-based selection procedure.Source: D GEPA ALGORITHM AND METHODOLOGY DETAILS · p. 23
D.1 MERGE: SYSTEM-AWARE CROSSOVER STRATEGY FOR COMPOUND AI OPTIMIZATION
- Merge combines Pareto-optimal candidates sharing an ancestor when they improve disjoint prompt sets and outperform that ancestor, so it occurs sparsely.GEPA checks for two such candidates and invokes merge only when these strict lineage conditions are satisfied.Source: §D.1 · p. 23
E EVALUATION SETUP (CONTD.) · E.1 BENCHMARKS, REFERENCE COMPOUND AI SYSTEMS, AND FEEDBACK FUNCTIONS
The evaluation assembles diverse benchmarks and compound AI systems to compare GEPA with state-of-the-art optimizers, using task-specific feedback functions and carefully separated training, validation, and test data. The suite spans multihop retrieval, instruction following, mathematical reasoning, and privacy-conscious delegation.
E.1 BENCHMARKS, REFERENCE COMPOUND AI SYSTEMS, AND FEEDBACK FUNCTIONS
- The benchmark suite evaluates GEPA against current compound AI system optimizers across diverse tasks, mostly drawn from Tan et al. (2025).Source: §E.1 · p. 23
- HotpotQA uses a modified HoVerMultiHop system with document-retrieval feedback and 150 training, 300 validation, and 300 test examples.The final hop answers questions, while feedback identifies relevant documents still needing retrieval.Source: §E.1 · p. 23
- IFBench tests generalization to 58 unseen output constraints using a two-stage answer-and-rewrite system with feedback on satisfied and failed constraints.IF-RLVR Train is split into 150 training and 300 validation examples, while IFBench provides 294 test examples without optimizer access during training.Source: §E.1 · pp. 23–24
- Figure 9 details System Aware Merge, whose stochastic sampler is seeded.Source: Figure 9 · p. 24
- AIME-2025 contains 30 questions, with 2022–2024 questions split into training and validation and each test question repeated five times for a single-step Chain-of-Thought system.Source: §E.1 · pp. 24–25
- LiveBench-Math uses 368 questions retrieved July 30, 2025, shuffled with Python random seed 0, and split equally into train, validation, and test sets.The optimized system is single-step Chain-of-Thought.Source: §E.1 · p. 25
- HoVer evaluates multihop query writing with up to three retrieval hops, document-summary modules, and feedback identifying retrieved and remaining gold documents.For full-parameter results in Figure 11, the setup uses two hops and 150 training, 300 validation, and 300 test examples.Source: §E.1 · p. 25
- PUPA evaluates privacy-conscious delegation with PAPILLON, combining trusted-model query and response rewriting, an untrusted-model call, and quality–PII leakage feedback.The dataset contains 111 training, 111 validation, and 221 test examples.Source: §E.1 · p. 25
E.2 MODELS AND INFERENCE PARAMETERS
GEPA and baseline optimizers are evaluated with one open-source and one commercial LLM, using shared-model compound systems and up to 16,384-token inference contexts. Qwen3-8B and GPT-4.1 Mini use their specified decoding configurations for training or inference.
Evaluation setup
- Each compound AI system is instantiated once per model, all modules use that same model, and inference allows up to 16,384 context tokens.The systems may include retrievers, rewriters, and answer generators.Source: §E.2 · p. 25
Qwen3 8B
- Experiments use Qwen3-8B for open-source evaluations, including GRPO, with temperature 0.6, top-p 0.95, and top-k 20 during training and inference (Yang et al., 2025; Team, 2025).Qwen3-8B represents the open-source model family.Source: §E.2 · p. 25
GPT-4.1 Mini
- GPT-4.1 Mini represents the commercial model family and is accessed through the OpenAI API with temperature 1.0.The evaluated model is openai/gpt-4.1-mini-2025-04-14.Source: §E.2 · p. 25
E.3 COSTS
All Table 2 experiments cost under $500 with GPT-4.1 mini, with GEPA and GEPA-Merge costing less than the compared optimizers.
E.3 COSTS
- Under $500 covers all Table 2 experiments: GEPA costs $86, GEPA-Merge $67, MIPROv2 $76, and Trace and TextGrad $172.These totals use GPT-4.1 mini.Source: §E.3 · p. 25
E.4 OPTIMIZERS
This section defines the baseline and compares GEPA with prompt optimizers and GRPO under matched experimental conditions. GEPA is evaluated alongside MIPROv2, Trace, TextGrad, and GRPO, with rollout budgets aligned to support fair comparisons.
Experimental protocol
- The baseline directly evaluates the base program without further optimization, while GEPA matches MIPROv2’s per-benchmark rollout budget within 10.15%.GEPA uses each benchmark’s training set for feedback and validation set for Pareto selection; the protocol is designed to isolate optimizer differences from search-budget differences.Source: §E.4 · pp. 25, 27
MIPROv2
- MIPROv2 jointly optimizes instructions and demonstrations through Bayesian optimization using candidate bootstrapping, TPE proposals, and evaluation-guided selection.All runs use the auto = heavy setting, proposing 18 instruction candidates and 18 bootstrapped few-shot sets.Source: §E.4 · p. 26
Trace and TextGrad
- Trace and TextGrad use the same program architecture, prompts, data, metrics, feedback functions, and rollout budget as GEPA and MIPROv2.The unoptimized Trace baseline was within 0.5% of the corresponding DSPy baseline.Source: §E.4 · p. 26
GRPO
- GRPO uses group-relative advantage estimation, with implementations from Ziems et al. (2025) for compound systems and SkyRL for single-module systems.Compound-system runs use LoRA and 500 training steps, totaling 24,000 rollouts, with validation-based early stopping.Source: §E.4 · p. 26
GEPA
- GEPA is evaluated in four variants: GEPA, GEPA+Merge, SelectBestCandidate, and SelectBestCandidate+Merge.The latter two replace Pareto-based sampling with naive SelectBestCandidate sampling; runs use minibatches of 3 and at most 5 merge invocations when enabled.Source: §E.4 · p. 27
F RESULTS AND ANALYSIS (CONTD.) · G PERFORMANCE VS. BUDGET (ROLLOUTS) CURVES · H GENERALIZATION GAP
The section presents visual analyses of final test performance, performance as a function of rollout budget, and generalization gaps across optimization methods. These figures cover aggregate and individual benchmarks, all optimizers, and different optimization methods.
F RESULTS AND ANALYSIS (CONTD.)
- Figure 10 visualizes final test-set performance for aggregate and individual benchmarks across both models.Source: F RESULTS AND ANALYSIS (CONTD.) · p. 27
- The final-performance analysis includes both aggregate benchmark results and individual benchmark results.Source: F RESULTS AND ANALYSIS (CONTD.) · p. 27
- Figure 10 reports final test-set performance across both evaluated models.Source: F RESULTS AND ANALYSIS (CONTD.) · p. 27
G PERFORMANCE VS. BUDGET (ROLLOUTS) CURVES
- Figures 12–15 show full performance-versus-rollout curves for all optimizers across all benchmarks.Source: G PERFORMANCE VS. BUDGET (ROLLOUTS)… · p. 27
- The rollout-budget analysis spans every optimizer and benchmark represented in the experiments.Source: G PERFORMANCE VS. BUDGET (ROLLOUTS)… · p. 27
H GENERALIZATION GAP
- Figure 16 visualizes the generalization gap for different optimization methods.Source: H GENERALIZATION GAP · p. 27
I COST VS. PERFORMANCE ANALYSIS FOR OPTIMIZED SYSTEMS · J GEPA SEARCH TREES
GEPA achieves higher performance than MIPROv2 while using prompts that are approximately 33% shorter, indicating a favorable cost–performance profile. The paper also presents genetic search trees for multiple GEPA configurations and the SelectBestCandidate ablation.
I COST VS. PERFORMANCE ANALYSIS FOR OPTIMIZED SYSTEMS
- 33% shorter prompts let GEPA achieve higher performance than MIPROv2, establishing its main cost–performance advantage.The comparison uses aggregate prompt length as a proxy for downstream cost.Source: I COST VS. PERFORMANCE ANALYSIS FOR… · p. 27
- Prompt size is an important determinant of the downstream cost of using an optimized system.Figure 17 visualizes aggregate prompt lengths of final optimized systems against achieved performance.Source: I COST VS. PERFORMANCE ANALYSIS FOR… · p. 27
- Figure 17 compares each optimizer’s final optimized-system prompt length with the performance it achieves.Aggregate prompt length serves as the cost proxy in this analysis.Source: I COST VS. PERFORMANCE ANALYSIS FOR… · p. 27
- GEPA’s shorter prompts accompany higher performance than MIPROv2’s prompts.The reported prompt-length difference is approximately 33%.Source: I COST VS. PERFORMANCE ANALYSIS FOR… · p. 27
- The cost–performance analysis focuses on the final optimized systems produced by the compared optimizers.The analysis measures prompt lengths and achieved performance for each optimizer.Source: I COST VS. PERFORMANCE ANALYSIS FOR… · p. 27
J GEPA SEARCH TREES
- Figures 19–26 present genetic search trees generated by various GEPA configurations and the SelectBestCandidate ablation.The cited figure set comprises Figures 19, 20, 21, 22, 23, 24, 25, and 26.Source: J GEPA SEARCH TREES · p. 27
K VISUALIZING THE ITERATIVE REFINEMENT ACHIEVED BY GEPA · K.1 PROMPTS AT INTERMEDIATE STAGES FOR PUPA
This section visualizes GEPA’s iterative refinement of PUPA prompts across intermediate stages and benchmarks. It highlights how the prompts evolve toward privacy-safe reformulations that preserve task intent and response quality while explaining detected risks and anonymization choices.
K.1 PROMPTS AT INTERMEDIATE STAGES FOR PUPA
- Intermediate PUPA prompts progressively instruct the system to abstract or omit sensitive details while preserving user intent and producing a clear privacy-safe external-LLM request.The prompts require reasoning that explains privacy risks, mitigation choices, and how the reformulation avoids data leakage.Source: K VISUALIZING THE ITERATIVE REFINEMENT… · p. 27, §K.1 · pp. 34–37
K VISUALIZING THE ITERATIVE REFINEMENT ACHIEVED BY GEPA
- On the 2-hop HoVer task, GEPA shows a comparable performance gap against both full-parameter and LoRA-based GRPO.The comparison is presented as learning behavior across optimization rollouts.Source: Figure 11 · p. 28
- The appendix visualizes rollout-versus-score behavior for GEPA and other settings on HotpotQA, IFBench, HoVerBench, and PUPA.These comparisons are shown separately for the four benchmark settings.Source: Figure 12 · p. 29, Figure 13 · p. 29, Figure 14 · p. 29
- Reflective prompt evolution achieves stronger generalization and improved overall performance than exemplar-based optimization in the reported comparison.The section attributes this difference hypothetically to newer LLMs’ stronger instruction following and reflection capabilities.Source: Figure 16 · p. 30
- GEPA produces prompts under 33% the size of MIPROv2’s while achieving higher performance across benchmarks.GEPA primarily uses prompt tokens for instructions, whereas MIPROv2 primarily uses few-shot examples.Source: Figure 17 · p. 30
K.1 PROMPTS AT INTERMEDIATE STAGES FOR PUPA
- PUPA prompts remove or generalize PII, locations, dates, proprietary terms, URLs, and direct quotations rather than lightly redacting them.Names become generic role descriptors, places become generalized regions, and exact temporal references become approximate.Source: §K.1 · pp. 39–40
- The reformulation identifies the query’s functional intent and preserves its thematic and informational core without reproducing the original input verbatim.It frames requests around essential elements such as creative, translational, summarization, communication, or technical goals.Source: §K.1 · p. 40
- Effective prompts balance privacy abstraction with contextual clarity, using neutral formulations that maintain technical meaning and specify expected content and style.They avoid both vague prompts that reduce usefulness and proprietary nomenclature that could reveal sensitive information.Source: §K.1 · pp. 40–41
- The prompts require transparent reasoning about identified privacy risks, abstraction methods, and how the essential task and user intent were preserved.This explanation documents choices such as replacing names, locations, or system identifiers with generic descriptors.Source: §K.1 · pp. 40–41
L EXAMPLES OF BEST PROMPTS FOR EVERY BENCHMARK
This section presents benchmark- and model-specific optimized prompts and responses for GEPA and MIPROv2 across compound AI systems, illustrating how they support precise instruction following, evidence-grounded reasoning, targeted retrieval, verification, and privacy-preserving reformulation. The examples cover tasks including HotpotQA, IFBench, HoVer, and PUPA, with prompts tailored to different configurations and response-generation needs.
L.1 HOTPOTQA, GPT-4.1 MINI
- The displayed HotpotQA prompts span query generation, final answering, and two summarization modules, reflecting the multi-module structure of the compound QA system.The configurations use fields such as `question`, summaries, context, and passages to produce query, answer, or summary outputs.Source: L EXAMPLES OF BEST PROMPTS FOR EVERY… · p. 41, §L.1 · pp. 43, 49
- The prompt examples demonstrate reasoning patterns such as identifying missing evidence for a second hop and integrating multiple summaries before producing a direct answer.Examples include refining a query about Virtus Entella’s league and synthesizing evidence about whether Machaeranthera and Prumnopitys are plants.Source: §L.1 · pp. 42, 44
- GEPA’s HotpotQA second-hop query prompt targets missing, complementary documents rather than paraphrasing the original question or repeating known summary facts.It instructs the model to infer broader or related entities, preserve relevant context, and output only a focused `query` for efficient retrieval.Source: §L.1 · pp. 42–43
- GEPA’s HotpotQA answer prompt compares two summaries, resolves conflicts with domain knowledge, and produces concise answers matching the requested specificity.It emphasizes direct responses, factual verification for names, dates, identities, categories, and yes/no questions, and explicit uncertainty when appropriate.Source: §L.1 · pp. 44–45
- GEPA’s first-hop summarization prompt synthesizes question-relevant passage facts while preserving entities, titles, dates, locations, and bridging details for later retrieval.The summary should identify what is known without forming the final answer, thereby supporting both next-hop query refinement and downstream answer extraction.Source: §L.1 · p. 47
- The optimized first-hop summarization approach is intended to make summaries informative for next-hop retrieval and foundational for final answer extraction.This stated outcome connects the summary’s factual synthesis to both subsequent retrieval and final answering modules.Source: §L.1 · p. 48
- GEPA’s HotpotQA example correctly identifies the Medici Bank as founded by Giovanni di Bicci de' Medici, the second Duke of Florence’s great-great-great-grandfather.The prompt links the historical lineage to the requested institution and produces a concise final answer.Source: §L.1 · p. 49
L.2 HOTPOTQA, QWEN3 8B
- For Qwen3 8B, the optimized second-hop query prompt targets missing entities, relationships, or details while avoiding duplicate questions and directly stated answers.It uses the first summary and original question to formulate focused retrieval queries for unresolved information.Source: §L.2 · p. 50
- The Qwen3 8B answer prompt extracts precise terminology, resolves ambiguity, cross-references summaries, and avoids unsupported context or overgeneralization.It also prioritizes explicit factual claims and requires concise responses when the question calls for a simple comparison or yes/no answer.Source: §L.2 · pp. 51–52
- Another demonstration concludes that Tay Garnett and Alexander Kluge are both film directors by comparing their descriptions across retrieved passages.The reasoning extracts the shared occupation rather than repeating their other professions or biographical details.Source: §L.2 · pp. 52–53
- Qwen3 8B’s first-hop summarization prompt preserves direct answers while highlighting missing or implied clues, full entity names, relevant context, and actionable follow-up searches.Its structure separates direct answers from inferred clues and includes exact dates, numbers, rankings, and entity relationships when relevant.Source: §L.2 · p. 53
- A Qwen3 8B demonstration shows the summarizer identifying that Virtus Entella competes in Serie B, correcting an initially incomplete context statement.Multiple retrieved passages explicitly confirm the team’s league, enabling the summary to answer the question.Source: §L.2 · p. 55
- The final Qwen3 8B summarization prompt prioritizes explicit answers, bridges missing links with necessary supporting information, and uses precise domain-specific terminology.It instructs the model to connect entities, roles, and relationships so answer generation can proceed confidently even when passages omit critical context.Source: §L.2 · pp. 55–56
- For HotpotQA, prompts require summaries to include the character’s name, explicitly stated profession, plot or series context, and relevant role background.They aim to match an ideal summary’s coverage and relevance so the answer module can produce the correct final answer.Source: §L.2 · p. 56
L.3 IFBENCH, GPT-4.1 MINI
- IFBench prompts instruct models to parse every explicit constraint, reproduce requested text exactly, satisfy formatting and lexical rules, and avoid omissions or extraneous content.Requirements include exact repetition, restricted options, minimum word or letter counts, forbidden keywords, sentence limits, and mandated endings.Source: §L.3 · pp. 57, 59, 60
- The GPT-4.1 Mini IFBench prompt adds a verification stage that checks whether an initial response satisfies repetition, formatting, frequency, and other user-specified constraints before producing a corrected answer.Its example validates an eight-bullet response and required closing phrase against the query’s instructions.Source: §L.3 · p. 58
- The merged GPT-4.1 Mini IFBench prompt prioritizes query parsing, verbatim reproduction, structural compliance, factual accuracy, ethical refusals, and a final review against all instructions.It explicitly prohibits unsupported explanations, apologies, or meta-commentary beyond what the query permits.Source: §L.3 · pp. 59–60
L.4 IFBENCH, QWEN3 8B
- Qwen3 8B IFBench prompts frame response generation as precision-focused instruction adherence, combining stepwise constraint analysis, requested formatting, factual specificity, and ethical neutrality.Examples show exactly eight franchise-related bullets and a swordfighting response that avoids forbidden keywords while limiting the letter “f” to two instances.Source: §L.4 · pp. 60–62
- A Qwen3 8B GEPA prompt requires repeating the query verbatim, answering in the specified format, adding domain-specific facts, and avoiding any extra preamble or postscript.A second variant further requires precise formatting, validated technical steps, pitfall coverage, and concise, actionable guidance.Source: §L.4 · pp. 61–62
L.5 HOVER, GPT-4.1 MINI
- HoVer prompts generate focused follow-up questions from a claim and initial evidence summary by identifying gaps, contradictions, and factual discrepancies requiring verification.The target output is one or more concise search-style queries that can verify or refute the claim.Source: §L.5 · pp. 63–64
- The HoVer example converts a contradiction about AirBaltic’s VNO/EYVI base and a 2015 closure into the targeted query, “Did Vilnius Airport (IATA: VNO, ICAO: EYVI) cease operations in 2015?”The query isolates the disputed airport identity and operational-status claim rather than repeating the broader original assertion.Source: §L.5 · p. 63
- HoVer GPT-4.1 Mini’s query prompt instructs models to extract claim facts, compare them with summaries, and formulate focused queries covering agreement, contradiction, and ambiguity.It emphasizes named entities, dates, roles, relationships, and separately verifiable subclaims.Source: §L.5 · p. 64
- Across the examples, the optimized prompts prioritize precise, evidence-rich outputs that connect claims to factual details and support subsequent retrieval or verification.The GPT-4.1 Mini prompts repeatedly use explicit names, titles, dates, relationships, and factual corrections to guide reasoning and search.Source: §L.5 · pp. 64, 70, §L.6 · p. 70
- The GEPA+Merge query prompt further requires incorporating summary corrections, distinctive entities, factual disputes, comparisons, and domain-specific nuances into objective evidence-retrieval questions.Its strategy is to combine the claim with clarifications from both summaries so retrieval can test the claim’s veracity.Source: §L.5 · pp. 65–66
- The GPT-4.1 Mini summarize1 prompt asks for step-by-step evidence analysis followed by a concise summary that explicitly connects passages to a claim during multi-hop verification.The example identifies Skittles, Mars, Incorporated, and McLean, Virginia when concluding that the claim is true based on external knowledge.Source: §L.5 · pp. 66, 68
- The task is to analyze a factual claim against its context and passages, determine whether evidence supports, partially supports, or contradicts it, and summarize that relationship accurately.The summary should explicitly connect relevant entities and facts from the passages, including names, works, dates, attributes, nicknames, or roles when applicable, and clarify potential misunderstandings.Source: §L.5 · pp. 69–70
L.6 HOVER, QWEN3 8B
- HoVer Qwen3 8B’s query prompt targets unresolved aspects by identifying gaps in an initial summary and crafting an unambiguous query for critical supporting evidence.Its example asks whether the provided summaries contain evidence that the horror film Zeitgeist was released in 2001.Source: §L.6 · pp. 70–71
- HoVer query prompts target unverified details, domain-specific anomalies, and summary context using precise names, titles, dates, and locations.They are designed to maximize evidence retrieval and resolve ambiguities in multi-hop fact-checking.Source: §L.6 · pp. 71–72
- HoVer multi-summary queries explicitly test claim support, cite specific evidence, and focus on disputed points such as incorrect attributions, missing evidence, and contradictions.The prompt also recommends including named entities, titles, and contrasts rather than using vague questions.Source: §L.6 · p. 72
- HoVer summary prompts require step-by-step claim analysis, evidence cross-referencing, explicit support or refutation judgments, and prioritization of details useful for further retrieval.They also instruct the model to flag unverified details and clarify niche or ambiguous information.Source: §L.6 · pp. 73–74
- HoVer contextual summaries use multi-hop reasoning to connect claims, context, and passages into a coherent conclusion that explicitly confirms or contradicts the claim.An example rejects a claim because the passages confirm separate facts but do not establish the asserted connection.Source: §L.6 · pp. 74–76
L.7 PUPA, GPT-4.1 MINI
- PUPA reformulates private queries into generalized prompts for external LLMs while removing or abstracting sensitive, proprietary, and personally identifiable information.The reformulation is required to preserve the user’s original intent without exposing private details.Source: §K.1 · p. 34, §L.7 · pp. 77–78
- PUPA’s output separates a concise privacy-treatment explanation from a carefully constructed LLM request that anonymizes PII and retains task requirements.The request should remain clear, contextually rich, and aligned with the original task.Source: §L.7 · p. 78
- PUPA guidance requires abstracting names, locations, dates, proprietary terms, and direct quotes while preserving the query’s functional intent and thematic core.It also balances privacy protection with sufficient contextual detail, neutral wording, and technical meaning.Source: §L.7 · pp. 78–79
- PUPA explanations must describe identified privacy risks, applied abstraction or omission strategies, and how the essential task remains preserved.Examples include replacing personal names, locations, and system terms with generic descriptors.Source: §L.7 · p. 79
- Privacy-preserving reformulation requires full anonymization or abstraction, avoiding verbatim PII, proprietary content, URLs, exact dates, direct quotes, and ambiguity.The prompt should use generic descriptors instead of real personal or organizational names unless public-figure naming is necessary.Source: §L.7 · p. 79
- Effective PUPA prompts generalize geographic references, abstract proprietary identifiers, and replace personal names with generic descriptions while preserving the original request’s intent.Examples include broad regions for exact places, abstracted system names, and a structured summary about “a notable individual.”Source: §L.7 · p. 80
- The GPT-4.1 Mini response prompt combines anonymized external output with the original query to produce a complete, polished, privacy-preserving answer.It explicitly requires maintaining the user’s intent while integrating the external response into a contextually appropriate final answer.Source: §L.7 · p. 80
- The Easton example demonstrates that the resulting answer can preserve substantive explanatory detail, covering inputs, political-system processing, outputs, feedback, environment, significance, and limitations.The response presents the model as a dynamic input-processing-output-feedback system and notes criticisms concerning abstraction, conflict, power, and agency.Source: §L.7 · p. 83
L.8 PUPA, QWEN3 8B
- Qwen3 8B’s redaction prompt requires a structured, non-sensitive request that preserves user intent, explains the redaction, and remains actionable for an external LLM.The required output separates a coherent reasoning explanation from the anonymized request.Source: §L.8 · pp. 84, 86
- Qwen3 8B guidance generalizes locations, numbers, names, brands, and study details while retaining technical terms, formulas, parameters, and task-specific constraints.It emphasizes publicly available information, domain-specific precision, avoidance of inferred details, and anonymization of numerical data.Source: §L.8 · pp. 85–86
- The Qwen3 8B response prompt synthesizes external technical solutions with user-specific context, replacing placeholders while omitting sensitive information and maintaining accuracy and professionalism.Its example targets a structured PESTLE analysis that prioritizes issues by urgency and significance without confidential data.Source: §L.8 · p. 86
- The generated PESTLE matrix identifies political, economic, social, technological, environmental, and legal issues affecting GE Healthcare in the US.Examples include reimbursement reforms, healthcare spending, population aging, AI advances, sustainability pressures, and FDA approvals.Source: §L.8 · p. 87
- The prioritization framework evaluates issues by urgency, significance, and potential impact on GE Healthcare’s operations, profitability, and strategic positioning.High urgency denotes immediate or ongoing attention, whereas lower urgency indicates a longer-term horizon.Source: §L.8 · pp. 88–89
- The matrix is intended to help GE Healthcare allocate resources toward pressing challenges and high-impact opportunities.It balances immediate challenges with longer-term trends and supports monitoring or phased planning for lower-priority issues.Source: §L.8 · pp. 88–89
- High-priority issues combine high urgency and high significance, including reimbursement changes, healthcare spending constraints, aging-population demand, AI advances, and FDA approvals.These issues are described as requiring immediate strategic attention because they affect revenue, demand, competitiveness, or market access.Source: §L.8 · p. 88
- Medium-priority issues include inflation and operational costs, IoT integration and cybersecurity, and carbon-footprint reduction and sustainability.Their impacts include margin pressure, security requirements, cost implications, brand reputation, and regulatory compliance.Source: §L.8 · pp. 88–89
- The GEPA-generated prompt asks the system to use a related LLM response as inspiration while producing clear, organized, language-tailored answers without PII or sensitive data.It recommends bullets or sections and prohibits proprietary information, PII, and unverified claims.Source: §L.8 · p. 89
- For rephrasing and summarization, the prompt requires academic tone when requested, removal of redundancy, and emphasis on domain-specific facts.For technical responses, it recommends decomposing complex logic, documenting functions, reducing redundancy, and managing resources properly.Source: §L.8 · p. 89
- For multi-step queries, the prompt instructs the model to address each part systematically and follow the user’s preferred language conventions.Across outputs, it prioritizes clarity, accuracy, and adherence to user requirements.Source: §L.8 · p. 89
M GEPA GENERATED PROMPTS FOR KERNEL GENERATION · N NUMBER OF REFLECTION LM CALLS MADE BY GEPA DURING OPTIMIZATION
This section presents GEPA-generated prompts for CUDA kernel generation on NVIDIA GPUs, including a workflow for producing correct, performant custom kernels integrated into PyTorch. It also reports their performance with the same GPT-4o agent and the number of reflection-language-model calls made during optimization.
M.1 NPUEVAL: KERNEL CODE GENERATION FOR NEW HARDWARE ARCHITECTURE
- 26.85% score versus 4.25%: GEPA’s NPUEval prompt improves the same GPT-4o agent’s kernel-generation performance.Figure 27 presents the GEPA-generated prompt and the corresponding scores.Source: §M.1 · p. 89, Figure 27 · p. 90
M.2 KERNELBENCH: CUDA KERNEL CODE GENERATION FOR NVIDIA GPUS
- KernelBench’s prompt instructs GPT-4o to replace PyTorch operators with custom CUDA kernels while preserving correctness and improving performance.It requires real, compilable code, a ModelNew architecture, and no testing code in the generated output.Source: §M.2 · pp. 91, 93
- The prompt additionally recommends CUDA error checking and debugging or profiling with tools such as cudaGetLastError(), cuda-memcheck, CUDA-GDB, and NVIDIA Nsight.These practices target both correctness and performance diagnosis.Source: §M.2 · pp. 91, 93
- The workflow identifies computationally intensive, parallelizable operators and opportunities to fuse operations such as matrix multiplication with ReLU.It prioritizes operators frequently used in the forward pass.Source: §M.2 · p. 94
- The prompt specifies CUDA implementation practices including per-thread indexing, GPU memory management, shared memory, coalesced accesses, boundary handling, and numerical-stability checks.It also recommends mixed precision, Tensor Cores, and avoiding divergent execution paths for performance.Source: §M.2 · p. 94
- The generated CUDA code is compiled inline with torch.utils.cpp_extension.load_inline and integrated into a functional ModelNew that replaces the original PyTorch operators.The prompt requires the modified model to compile without errors.Source: §M.2 · p. 94
- Validation compares optimized-model outputs with the original model, measures runtime improvements, and tests edge cases such as sizes not divisible by the block size.The instructions also require maintaining the original model’s accuracy and minimizing execution time.Source: §M.2 · pp. 94, 96
- GEPA prompts guide replacing PyTorch operators with custom CUDA kernels while maintaining model accuracy.The instructions also target significant performance improvements and maximizing GPU utilization.Source: §M.2 · p. 96
N NUMBER OF REFLECTION LM CALLS MADE BY GEPA DURING OPTIMIZATION
- Table 4 reports the total number of reflection LM calls GEPA makes during optimization.Source: Table 4 · p. 96
Related papers
This paper cites
- Efficient Memory Management for Large Language Model Serving with PagedAttention2023
- Self-Refine: Iterative Refinement with Self-Feedback2023
- HotpotQA: A Dataset for Diverse, Explainable Multi-hop Question Answering2018
- Large Language Models as Optimizers2023
- Illuminating search spaces by mapping elites2015
Cited by
- Before the Next Rollout: Diagnosing Skill Utility Shifts from Policy Updates2026
- Masked Erosion: How Acceptance Gates Lose Redundant Safeguards in Self-Improving Agents2026
- GEPA-Curator: Curated Learning for Self Improving Agents2026
- Zero-Shot Multimodal Event Spotting in Soccer Broadcasts2026
- Where Should the Evaluation Budget Go in LLM-Driven Agent Scaffold Evolution?2026
- Does Your Generalist Skill Optimizer Really Incentivize Agentic Tasks? Rethinking Skill Optimization via Bipartite Attribution2026