Skip to main content

GEPA

GEPA (Generative Evolutionary Prompt Adaptation) evaluates a seed prompt against your dataset, identifies the examples that fail, and generates improved candidates that address those failures. It repeats until the score stops improving or the iteration budget is exhausted.

How it works

Installation

Basic Usage

Parameters

Required

Optional

Custom Executor

By default, GEPA calls the model directly with the candidate prompt. If your agent is more complex (has memory, tools, an API), pass a custom executor:

Custom Evaluator

For structured or deterministic tasks, a custom evaluator gives sharper signal than the LLM judge:
Use a custom evaluator when the task has deterministic success criteria (valid JSON, specific fields, exact format). Use the default LLMEvaluator when quality is subjective (tone, clarity, factual grounding).

Output Schema

OptimizationResult

IterationResult

Score interpretation

The score is the average across all examples of what the evaluator returns (0.0–1.0). With the default LLMEvaluator, it represents how well the agent follows the objective criteria as judged by the LLM.

LLM Provider Options

Best Practices

Vague objectives produce vague improvements. Be explicit about what the agent should and should not do:
A seed prompt like "Eres un asistente." gives GEPA maximum room to improve and produces a more dramatic demonstration of the optimization. If your current prompt is already decent, the improvement will be smaller.
If the expected output follows a strict format (JSON, numbered steps, specific fields), write a deterministic evaluator. It gives GEPA a much clearer signal than an LLM judge on whether a candidate is correct.
8–20 examples is enough for GEPA. Too few examples and the signal is noisy; too many and each iteration becomes slow. If you have many examples, consider sampling a representative subset.

Next Steps

MIPROv2

Optimize instruction AND few-shot examples simultaneously

Retriever

Build a Retriever to load your evaluation dataset