Why GEPA?
GEPA outperforms GRPO by 10% on average (up to 20%) while using up to 35x fewer rollouts. Best for:- Classification tasks (Banking77, intent classification)
- Multi-hop QA (HotpotQA)
- Instruction-following tasks
- When you want diverse prompt variants (Pareto front)
Prerequisites
Before starting, ensure you have:How GEPA Works
GEPA uses evolutionary principles to explore the prompt space. Understanding the algorithm helps you configure it effectively.The Optimization Flow
- Initialize
- Split seeds into pareto_seeds and feedback_seeds
- Evaluate baseline transformation
- Generate initial population via proposer
- Evaluate & add to Pareto archive
- Evolve (for each generation)
- For each child:
- Select parent (instance-wise Pareto sampling)
- Generate feedback from parent trace
- Mutate via proposer (LLM-guided)
- Minibatch gating (quick eval)
- Full Pareto evaluation (if gating passed)
- Update archive if non-dominated
- For each child:
- Terminate
- Budget exhausted OR
- Generation limit OR
- No improvement for N generations
- Return best transformation, by accuracy
Key Components
1. Pattern-Based Transformations
GEPA represents prompt changes as transformations that can be applied to your baseline:2. Pareto Archive
GEPA maintains a Pareto front of non-dominated solutions, balancing multiple objectives:- Accuracy (primary) – Task performance
- Tool call rate – Function calling frequency (for agentic tasks)
3. Instance-Wise Parent Selection
Unlike traditional selection that uses aggregate scores, GEPA counts how many individual seeds each prompt “wins” on:4. LLM-Guided Mutations
The proposer (meta-model) generates new prompts by analyzing:- Current instruction (baseline)
- Rollout examples (input/output/feedback for each seed)
- Trace feedback (e.g., “model under-utilizes tools”)
- Dataset and program context
Step 1: Create a LocalAPI
Your LocalAPI evaluates prompts by running rollouts and returning scores. See LocalAPI Guide for details. Example Banking77 LocalAPI structure:Step 2: Deploy Your LocalAPI
The Synth AI backend needs to reach your LocalAPI over the internet to send rollout requests. Use the Python SDK’sInProcessTaskApp for seamless deployment with automatic tunneling:
- Starts your LocalAPI locally
- Creates a SynthTunnel URL (or another tunnel backend if configured)
- Returns the tunnel URL via
task_app.url
Verify the Deployment
Check that your LocalAPI is accessible:Alternative Tunnel Backends
SynthTunnel is the default and recommended backend. If you need a Cloudflare tunnel instead:Step 3: Create the Configuration
Create a TOML file defining your optimization parameters. Thetask_app_url should match the URL from Step 2 (stored in your .env as TASK_APP_URL):
Configuration Parameters
Step 4: Launch the Optimization Job
- Validate your TOML configuration
- Verify the task app is reachable
- Submit the job to Synth AI
- Poll for completion
Understanding the Output
During optimization, you’ll see progress updates:Step 5: Understanding the Optimization Process
Generation-by-Generation Progress
How Mutations Are Generated
The proposer receives:- Baseline instruction: Your current system prompt
- Rollout examples: Input/output pairs with feedback (correct/incorrect, error messages)
- Trace statistics: Tool call rate, trajectory length, etc.
- Feedback hints: Rule-based suggestions like “model under-utilizes tools”
Minibatch Gating
Before full evaluation, GEPA performs a quick check:- Evaluate child on a small minibatch (3 seeds)
- Compare to parent’s score on the same seeds
- If child is worse → skip full evaluation (saves budget)
- If child is promising → proceed to full Pareto evaluation
Step 6: Retrieve Optimized Prompts
After completion, fetch your results using the Python SDK:Understanding the Pareto Front
GEPA returns multiple prompts representing different trade-offs:
Choose based on your latency/cost requirements.