GEPAResult¶
gepa.core.result.GEPAResult(candidates: list[dict[str, str]], parents: list[list[ProgramIdx | None]], val_aggregate_scores: list[float], val_subscores: list[dict[DataId, float]], per_val_instance_best_candidates: dict[DataId, set[ProgramIdx]], discovery_eval_counts: list[int], val_aggregate_subscores: list[dict[str, float]] | None = None, per_objective_best_candidates: dict[str, set[ProgramIdx]] | None = None, objective_pareto_front: dict[str, float] | None = None, best_outputs_valset: dict[DataId, list[tuple[ProgramIdx, RolloutOutput]]] | None = None, total_metric_calls: int | None = None, num_full_val_evals: int | None = None, run_dir: str | None = None, seed: int | None = None, _str_candidate_key: str | None = None)
dataclass
¶
Bases: Generic[RolloutOutput, DataId]
Immutable snapshot returned by :func:~gepa.optimize_anything.optimize_anything.
Key attributes
best_candidate: The optimized parameter(s) — dict[str, str] or plain
str when seed_candidate was a string.
best_idx: Index of the highest-scoring candidate.
val_aggregate_scores: Per-candidate average validation score (higher is better).
candidates: All candidates explored during optimization.
parents: Lineage — parents[i] is a list of parent indices for candidate i.
per_val_instance_best_candidates: Pareto frontier — per validation example,
the set of candidate indices achieving the best score.
best_refiner_prompt: The refiner prompt from the best candidate (if refiner was enabled).
Serialization
to_dict() / from_dict() for JSON-safe round-tripping.
Example::
result = optimize_anything(...)
print(result.best_candidate)
print(result.val_aggregate_scores[result.best_idx])
Attributes¶
candidates: list[dict[str, str]]
instance-attribute
¶
parents: list[list[ProgramIdx | None]]
instance-attribute
¶
val_aggregate_scores: list[float]
instance-attribute
¶
val_subscores: list[dict[DataId, float]]
instance-attribute
¶
per_val_instance_best_candidates: dict[DataId, set[ProgramIdx]]
instance-attribute
¶
discovery_eval_counts: list[int]
instance-attribute
¶
val_aggregate_subscores: list[dict[str, float]] | None = None
class-attribute
instance-attribute
¶
per_objective_best_candidates: dict[str, set[ProgramIdx]] | None = None
class-attribute
instance-attribute
¶
objective_pareto_front: dict[str, float] | None = None
class-attribute
instance-attribute
¶
best_outputs_valset: dict[DataId, list[tuple[ProgramIdx, RolloutOutput]]] | None = None
class-attribute
instance-attribute
¶
total_metric_calls: int | None = None
class-attribute
instance-attribute
¶
num_full_val_evals: int | None = None
class-attribute
instance-attribute
¶
run_dir: str | None = None
class-attribute
instance-attribute
¶
seed: int | None = None
class-attribute
instance-attribute
¶
num_candidates: int
property
¶
num_val_instances: int
property
¶
best_idx: int
property
¶
best_candidate: str | dict[str, str]
property
¶
Return the best candidate.
When optimize_anything was called with a str seed_candidate,
returns the plain str value. Otherwise returns the full
dict[str, str] parameter mapping.
best_refiner_prompt: str | None
property
¶
Return the refiner prompt from the best candidate, or None if
the refiner was not enabled.
Functions¶
candidate_tree_dot() -> str
¶
Generate a Graphviz DOT string of the candidate lineage tree.
Source code in gepa/core/result.py
candidate_tree_html() -> str
¶
Generate a self-contained HTML page rendering the candidate tree.
Source code in gepa/core/result.py
to_dict() -> dict[str, Any]
¶
Source code in gepa/core/result.py
from_dict(d: dict[str, Any]) -> GEPAResult[RolloutOutput, DataId]
staticmethod
¶
Source code in gepa/core/result.py
from_state(state: GEPAState[RolloutOutput, DataId], run_dir: str | None = None, seed: int | None = None, str_candidate_key: str | None = None) -> GEPAResult[RolloutOutput, DataId]
staticmethod
¶
Build a GEPAResult from a GEPAState.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
str_candidate_key
|
str | None
|
When set, |
None
|