EvaluationCache¶
gepa.core.state.EvaluationCache(_cache: dict[CacheKey, CachedEvaluation[RolloutOutput]] = dict())
dataclass
¶
Bases: Generic[RolloutOutput, DataId]
Cache for storing evaluation results of (candidate, example) pairs.
Functions¶
get(candidate: dict[str, str], example_id: DataId) -> CachedEvaluation[RolloutOutput] | None
¶
Retrieve cached evaluation result if it exists.
put(candidate: dict[str, str], example_id: DataId, output: RolloutOutput, score: float, objective_scores: ObjectiveScores | None = None) -> None
¶
Store an evaluation result in the cache.
Source code in gepa/core/state.py
get_batch(candidate: dict[str, str], example_ids: list[DataId]) -> tuple[dict[DataId, CachedEvaluation[RolloutOutput]], list[DataId]]
¶
Look up cached results for a batch. Returns (cached_results, uncached_ids).
Source code in gepa/core/state.py
put_batch(candidate: dict[str, str], example_ids: list[DataId], outputs: list[RolloutOutput], scores: list[float], objective_scores_list: Sequence[ObjectiveScores] | None = None) -> None
¶
Store evaluation results for a batch of examples.
Source code in gepa/core/state.py
evaluate_with_cache_full(candidate: dict[str, str], example_ids: list[DataId], fetcher: Callable[[list[DataId]], Any], evaluator: Callable[[Any, dict[str, str]], tuple[Any, list[float], Sequence[ObjectiveScores] | None]]) -> tuple[dict[DataId, RolloutOutput], dict[DataId, float], dict[DataId, ObjectiveScores] | None, int]
¶
Evaluate using cache, returning full results.
Returns (outputs_by_id, scores_by_id, objective_scores_by_id, num_actual_evals).