Skip to main content

GEPA reflective prompt evolution optimizer for superred

Project description

superred-optimizer-gepa

A GEPA (Genetic-Pareto) reflective prompt evolution optimizer for the superred red-teaming framework.

GEPA treats the attack prompt as a single evolving candidate. Each superred run rolls out one candidate; at the end of a run, a separate reflection LM call inspects that rollout (score, target reply, evaluator feedback) and proposes a revised candidate for the next run to try. Across many runs this grows a small pool of candidates by reflective mutation rather than gradient-free search or manual prompt engineering.

Reference: Agrawal et al., "GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning," arXiv:2507.19457 (ICLR 2026). The reflective meta-prompt is reproduced verbatim from the official gepa-ai/gepa reference implementation (MIT-licensed) — see ASSUMPTIONS.md for the exact source files and every deliberate departure this superred port makes (all forced by superred's single-Goal, single-instance session model, where GEPA's paper assumes a full training set to batch and Pareto-select over).

For an agent-target variant of this same reflective loop (surface discovery, tool-return injection), see superred-optimizer-gepa-agentic.

Install

pip install superred-optimizer-gepa

Usage

from gepa_optimizer import GEPAOptimizer

optimizer = GEPAOptimizer(max_attempts=20)

Wire it into a Controller like any other superred optimizer — see the framework's architecture overview and a target's README (e.g. superred-target-chatbot) for a full Controller.run() example.

Behaviour notes

  • One run = one rollout of one candidate. The seed candidate is the adversarial goal's own description; each later candidate is proposed by the reflection LM from the best-scoring candidate's most recent rollout.
  • Runs in all four adversarial information-access settings without a setting flag. Settings without a score signal collapse candidate selection to latest-wins on ties; settings with feedback drive score-based parent selection and success early-stop. max_no_signal_runs (disabled by default) bounds cost in the score-blind settings.
  • No acceptance test / single-instance Pareto. The paper's acceptance test replays a candidate on a fixed minibatch before keeping it; superred's single-Goal, single-attempt-per-run model makes that replay impossible, so every rolled-out candidate enters the pool and parent selection collapses to current-best. Documented as a deliberate departure, not an oversight.
  • Reflection parse failures (malformed or missing fenced-code-block output) do not crash the run — the optimizer logs a warning and skips that mutation, keeping the previous best candidate as the parent.

License

MIT for this port's code. The reflective meta-prompt text is reproduced verbatim from gepa-ai/gepa (MIT License, Copyright (c) 2025 Lakshya A Agrawal and the GEPA contributors) — see the attribution comment in src/gepa_optimizer/prompts.py and ASSUMPTIONS.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

superred_optimizer_gepa-0.1.0.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

superred_optimizer_gepa-0.1.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file superred_optimizer_gepa-0.1.0.tar.gz.

File metadata

  • Download URL: superred_optimizer_gepa-0.1.0.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for superred_optimizer_gepa-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0bd9467a0968e58664a2b853961caf9cb14d0a837f4aa0feac8a133d265d663a
MD5 7fef2875b6aabaf782ed3cf0132e11bb
BLAKE2b-256 cf739ecdd3f8ce2b36933587d1205df7de16ef2cc278908118cc4d1241a88a3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for superred_optimizer_gepa-0.1.0.tar.gz:

Publisher: release.yml on RoldSI/superred-modules

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file superred_optimizer_gepa-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for superred_optimizer_gepa-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f03eee0c4ccc0a807af7a25af1c02dc904e3e195efc01b9865c25d565689b8d
MD5 67b767c587099e35d80690e312c4706c
BLAKE2b-256 bdebaa10273a8caef59349ee1b03d9d4d0d68d4af52cf30484632a338706e55f

See more details on using hashes here.

Provenance

The following attestation bundles were made for superred_optimizer_gepa-0.1.0-py3-none-any.whl:

Publisher: release.yml on RoldSI/superred-modules

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page