dspy-gepa

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

DSPy GEPA — Generate, Evaluate, Propose, Apply

DSPy GEPA — 生成、评估、提议、应用

GEPA is a DSPy-powered tool for evaluating, optimizing, and generating skill scenarios.
GEPA是一款基于DSPy的工具,用于评估、优化以及生成技能场景。

Quick Start

快速开始

Requires Python 3.10+ with
dspy
,
pyyaml
, and
jsonschema
:
bash
pip install dspy-ai pyyaml jsonschema
需要Python 3.10及以上版本,并安装
dspy
pyyaml
jsonschema
bash
pip install dspy-ai pyyaml jsonschema

Generate New Scenarios

生成新场景

Point GEPA at an existing skill to generate new test scenarios:
bash
python scripts/gepa.py generate \
  --skill-description "Creates FastAPI routers with CRUD endpoints" \
  --skill-name fastapi-router-py \
  --num-scenarios 5 \
  --output tests/scenarios/fastapi-router-py/generated.yaml
Or expand an existing scenario file with more variations:
bash
python scripts/gepa.py generate \
  --scenarios tests/scenarios/fastapi-router-py/scenarios.yaml \
  --num-scenarios 3 \
  --output new-scenarios.yaml
将GEPA指向现有技能以生成新的测试场景:
bash
python scripts/gepa.py generate \
  --skill-description "Creates FastAPI routers with CRUD endpoints" \
  --skill-name fastapi-router-py \
  --num-scenarios 5 \
  --output tests/scenarios/fastapi-router-py/generated.yaml
或者扩展现有场景文件以生成更多变体:
bash
python scripts/gepa.py generate \
  --scenarios tests/scenarios/fastapi-router-py/scenarios.yaml \
  --num-scenarios 3 \
  --output new-scenarios.yaml

Evaluate Scenarios

评估场景

Score a DSPy program against scenario patterns:
bash
python scripts/gepa_evaluate.py \
  --scenarios tests/scenarios/fastapi-router-py/scenarios.yaml
根据场景模式为DSPy程序打分:
bash
python scripts/gepa_evaluate.py \
  --scenarios tests/scenarios/fastapi-router-py/scenarios.yaml

Full GEPA Loop

完整GEPA循环

Evaluate baseline → optimize → evaluate optimized → save:
bash
python scripts/gepa.py optimize \
  --scenarios tests/scenarios/fastapi-router-py/scenarios.yaml \
  --output optimized_program.json
评估基准版本 → 优化 → 评估优化后版本 → 保存:
bash
python scripts/gepa.py optimize \
  --scenarios tests/scenarios/fastapi-router-py/scenarios.yaml \
  --output optimized_program.json

Convert Scenarios to Dataset

将场景转换为数据集

bash
python scripts/scenario_to_dataset.py \
  --scenarios tests/scenarios/fastapi-router-py/scenarios.yaml \
  --output dataset.json
bash
python scripts/scenario_to_dataset.py \
  --scenarios tests/scenarios/fastapi-router-py/scenarios.yaml \
  --output dataset.json

Architecture

架构

See
references/gepa-architecture.md
for the full GEPA loop design and DSPy mapping.
查看
references/gepa-architecture.md
获取完整的GEPA循环设计以及DSPy映射细节。

Metrics

指标

See
references/metrics.md
for pattern-matching scoring details.
查看
references/metrics.md
获取模式匹配打分的详细信息。

Example Output

示例输出

See
examples/sample-run.md
for a complete CLI session with output.
查看
examples/sample-run.md
获取包含输出的完整CLI会话示例。