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)
dataclass
¶
Bases: Generic[RolloutOutput, DataId]
Immutable snapshot of a GEPA run with convenience accessors.
- candidates: list of proposed candidates (component_name -> component_text)
- parents: lineage info; for each candidate i, parents[i] is a list of parent indices or None
- val_aggregate_scores: per-candidate aggregate score on the validation set (higher is better)
- val_subscores: per-candidate mapping from validation id to score on the validation set (sparse dict)
- val_aggregate_subscores: optional per-candidate aggregate subscores across objectives
- per_val_instance_best_candidates: for each val instance t, a set of candidate indices achieving the current best score on t
- per_objective_best_candidates: optional per-objective set of candidate indices achieving best aggregate subscore
- discovery_eval_counts: number of metric calls accumulated up to the discovery of each candidate
Optional fields: - best_outputs_valset: per-task best outputs on the validation set. [task_idx -> [(program_idx_1, output_1), (program_idx_2, output_2), ...]]
Run-level metadata: - total_metric_calls: total number of metric calls made across the run - num_full_val_evals: number of full validation evaluations performed - run_dir: where artifacts were written (if any) - seed: RNG seed for reproducibility (if known) - tracked_scores: optional tracked aggregate scores (if different from val_aggregate_scores)
Convenience: - best_idx: candidate index with the highest val_aggregate_scores - best_candidate: the program text mapping for best_idx - non_dominated_indices(): candidate indices that are not dominated across per-instance pareto fronts - lineage(idx): parent chain from base to idx - diff(parent_idx, child_idx, only_changed=True): component-wise diff between two candidates - best_k(k): top-k candidates by aggregate val score - instance_winners(t): set of candidates on the pareto front for val instance t - to_dict(...), save_json(...): serialization helpers
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: dict[str, str]
property
¶
Functions¶
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) -> GEPAResult[RolloutOutput, DataId]
staticmethod
¶
Build a GEPAResult from a GEPAState.