gepa-ai/gepa

Optimize prompts, code, and more with AI-powered Reflective Optimization

What it solves

GEPA (Genetic-Pareto) is a framework designed to optimize any system that relies on textual parameters—such as prompts, code, agent architectures, and configurations—against a specific evaluation metric. It addresses the limitation of traditional optimizers that only know if a candidate failed; GEPA identifies why it failed by analyzing execution traces to drive targeted improvements.

How it works

GEPA uses a combination of LLM-based reflection and Pareto-efficient evolutionary search:

  1. Selection: It picks candidates from a Pareto frontier (those performing best on different subsets of tasks).
  2. Execution: Candidates are run on minibatches, and full execution traces (error messages, logs, profiling data) are captured.
  3. Reflection: An LLM analyzes these traces to diagnose the root cause of failures.
  4. Mutation: The LLM generates an improved version of the candidate based on these diagnostic lessons.
  5. Acceptance: Improved candidates are added to the pool and the Pareto front is updated.

It also utilizes "Actionable Side Information" (ASI)—diagnostic feedback that acts as a text-based analogue to a gradient—and can merge the strengths of two Pareto-optimal candidates.

Who it’s for

  • AI Engineers: Who need to optimize complex prompts or agentic workflows without manually guessing changes.
  • Systems Researchers: Looking to optimize non-prompt text artifacts like scheduling policies or code.
  • DSPy Users: Who want to integrate automated optimization into their AI pipelines via dspy.GEPA.
  • Agent Developers: Who want to provide their agents with the ability to self-optimize via the GEPA Agent Skill.

Highlights

  • Efficiency: Claims to be 35x faster than RL (e.g., GRPO) and significantly cheaper than using top-tier models like Claude Opus.
  • Versatility: Can optimize prompts, agent architectures, RAG configurations, and even SVG graphics.
  • Broad Integration: Integrated into major tools like MLflow, Pydantic AI, Comet ML Opik, and Google's Gemini Enterprise Agent Platform.
  • Extensible: Provides a GEPAAdapter interface to plug into any system, with built-in adapters for LangChain, MCP, and RAG.

Related

  • Project
  • Project
  • Project
  • Project