egmaminta/GEPA-Lite

★ 58⑂ 4

A lightweight implementation of the GEPA (Genetic-Pareto) prompt optimization method for large language models.

About egmaminta/GEPA-Lite

egmaminta/GEPA-Lite is an open-source project on GitHub, mainly written in Python. A lightweight implementation of the GEPA (Genetic-Pareto) prompt optimization method for large language models. It currently holds 58 stars and 4 forks with 0 open issues, and was last pushed on an unknown date (repository created unknown).

Project Overview

AI Homed tracks it on the AI Prompt Engineering board.

GitHub Repository Details

Repository egmaminta/GEPA-Lite · default branch - · size 0 KB · watchers 0 · source: GitHub REST API and repository README

README

GEPA-Lite: Let the LLM reflect and optimize its own prompts.

#ForTheLoveOfCode

GEPA-Lite is a lightweight implementation based on the proposed GEPA prompt optimization method that is custom fit for single-task applications. It's built on the core principle of LLM self-reflection, self-improvement, streamlined.

Developed in the spirit of open-source initiatives like Google Summer of Code 2025 and For the Love of Code 2025, this project leverages Gemma (ollama::gemma3n:e4b) as its core model. The project also offers optional support for the Gemini API, allowing access to powerful models like gemini-2.5-flash-lite, gemini-2.5-flash, and gemini-2.5-pro.

Created by: Emmanuel G. Maminta* (GitHub: egmaminta, LinkedIn: egmaminta, Personal Blog: egmaminta.github.io, Email: egmaminta@up.edu.ph)

*University of the Philippines

Demonstration

https://github.com/egmaminta/GEPA-Lite/blob/HEAD/demo

GEPA-Lite demonstration on sampled GSM8K. Initial prompt: "You are an assistant and your task is to answer the user's question." Final prompt: "Your task is to solve mathematical word problems and output only the final numerical answer."

GSM8K consists of 8.5K high quality grade school math problems created by human problem writers.

Four strategies implemented

| Strategy | Trigger condition | Action taken | Goal | | -------- | ----------------- | ------------ | ---- | | Exploit-Max | Only one best candidate remains | Select it directly | Focus on clear winner | | Exploit-Normal | Multiple best, Q branch | Sample one by frequency as "best" | Exploit robust, multi-task candidates | Exploit-Merge | Multiple best, (1-Q) branch | Merge (mutate) all bests into a new candidate | Synthesize new, possibly better prompt | Explore | With probability (1-P) | Pick a random candidate from the pool | Maintain diversity, avoid local optima

Note: P: Exploit probability, Q: Probability to not merge (or not mutate) all bests

Disclaimer: This implementation contains minor deviations from the reference paper. I, the creator of this repository, am held accountable for any part that is implemented incorrectly. However, the idea remains the same. Feel free to contribute!

Reference paper

Title: GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning

Authors: Lakshya A Agrawal1, Shangyin Tan1, Dilara Soylu2, Noah Ziems4, Rishi Khare1, Krista Opsahl-Ong5, Arnav Singhvi2,5, Herumb Shandilya2, Michael J Ryan2, Meng Jiang4, Christopher Potts2, Koushik Sen1, Alexandros G. Dimakis1,3, Ion Stoica1, Dan Klein1, Matei Zaharia1,5, Omar Khattab6

1UC Berkeley, 2Stanford University, 3BespokeLabs.ai, 4Notre Dame, 5Databricks, 6MIT

TL;DR: GEPA is introduced, which utilizes natural language reflection to learn from trial and error. GEPA outperforms the reinforcement learning method GRPO (Group Relative Policy Optimization) by an average of 10% and up to 20%, while using up to 35 times fewer rollouts. It also surpasses the leading prompt optimizer, MIPROv2, by over 10%. Additionally, GEPA shows potential as an effective inference-time search strategy for code optimization.

About the implementation

This implementation performs iterative prompt evolution using concurrent generation, evaluation, Pareto-style selection, reflection-based mutation, and optional merging. It is fully asynchronous around model I/O to maximize throughput under a fixed evaluation budget.

High-level flow

1. Load config (GEPA_cfg.yaml) and datasets (Dpareto.json, Dfeedback.json). 2. Generate an initial pool of diverse candidate prompts concurrently from a seed prompt. 3. Evaluate each candidate over the full Pareto set (Dpareto) to build a score matrix S (candidates × tasks). 4. Enter the optimization loop (budget-limited): 5. After budget exhaustion, report the prompt with highest mean Pareto score.

Data roles

Target and reflection model

Candidate selection (Pareto filtering)

Reflection & mutation

Merging

When multiple strong candidates exist, a merge step requests a synthesized prompt that preserves strengths and addresses weaknesses (controlled by probability branch).

Four strategies used in the GEPA optimization loop

1. Exploit-Max 2. Exploit-Normal 3. Exploit-Merge 4. Explore

Concurrency

Key functions

Budget control

Every model query against a sample decrements the global budget. Full-set evaluations are only triggered when a mutation shows promise on the mini-batch, amortizing expensive scoring.

Design rationale

Limitations / future improvements

Extensibility points

General instructions

1. Ensure you have miniconda / anaconda installed. Create a virtual environment with Python ver. 3.11.13.
conda create -n "GEPA-Lite" python=3.11.13 -y
2. Activate the virtual environment.
conda activate GEPA-Lite
3. Install the required libraries.
pip install -r requirements.txt

Configuration instructions

1. Open GEPA_cfg.yml. 2. (Gemini API) Replace placeholder PROJECT and LOCATION if VERTEXAI: true; else optionally set VERTEXAI: false. (Ollama API) Replace TARGET_MODEL and REFLECTION_MODEL to Ollama-provided gemma3n:e4b model. 3. Adjust BUDGET ensuring it's ≥ (NUM_INITIAL_CANDIDATE_PROMPTS |Dpareto|) + (MINI_BATCH_SIZE 5 * |Dpareto|) + safety margin (~30%). 4. Tune EXPLOIT_PROB and MERGE_PROB based on desired exploration. 5. Save and re-run the main script (GEPA.py).

Dpareto and Dfeedback instructions

1. Purpose 3. Expected schema. Required keys: question, answer (non-empty strings). Avoid extra keys unless you extend code to read them.
[
  {
    "question": "string input or query",
    "answer": "ground truth string answer"
  },
  ...
]
3. Choosing content 4. Sizing guidelines 5. Difficulty / Distribution Strategy 6. Workflow to build Dpareto 1. Gather raw candidate pairs. 2. Deduplicate (case-insensitive question hash). 3. Remove ambiguous items. 4. Normalize answers. 5. Tag coverage (spread topics). 6. Shuffle with fixed seed; pick top N. 7. Save to Dpareto.json and freeze (commit with version tag). 7. Workflow to build Dfeedback 1. Start with remaining pool not used in Dpareto. 2. Inject a few "stress" / adversarial items (format traps, long inputs). 3. Ensure at least MINI_BATCH_SIZE 2 |Dpareto| total. 4. Optionally rotate / refresh between runs (version the file).

Acknowledgments

I'd like to acknowledge the authors of GEPA paper for their awesome work; the team (developers, engineers, and scientists) behind Gemma 3n, Gemini for their powerful models; and Google Summer of Code 2025 and For the Love of Code 2025 for inspiring me to continue contributing to open-source. #ForTheLoveOfCode

GitHub Stars & Activity

58Stars
4Forks
0Open issues
PythonLanguage

GitHub Popularity

GitHub stars58
Forks4
Open issues0
Primary languagePython
License-
Stars gained today0
Created-
Last pushed-

Trending History

Trending statusnot on today's boards

Related AI Projects

1

microsoft / promptflow

Python★ 11,244⑂ 1,123
2

promptslab / Promptify

Python★ 4,635⑂ 364
3
4

hegelai / prompttools

Python★ 3,055⑂ 256
5

Eladlev / AutoPrompt

Python★ 3,019⑂ 264
6

microsoftarchive / promptbench

Python★ 2,821⑂ 222
7

yaojingang / yao-open-prompts

Python★ 2,817⑂ 461
8

YiVal / YiVal

Python★ 2,134⑂ 328

More AI Rankings