Skip to content

ScoreThresholdStopper

gepa.utils.stop_condition.ScoreThresholdStopper(threshold: float)

Bases: StopperProtocol

Stop callback that stops when a score threshold is reached.

Source code in gepa/utils/stop_condition.py
def __init__(self, threshold: float):
    self.threshold = threshold

Attributes

threshold = threshold instance-attribute

Functions

__call__(gepa_state: GEPAState) -> bool

Source code in gepa/utils/stop_condition.py
def __call__(self, gepa_state: GEPAState) -> bool:
    # return true if score threshold is reached
    try:
        current_best_score = (
            max(gepa_state.program_full_scores_val_set) if gepa_state.program_full_scores_val_set else 0.0
        )
        return current_best_score >= self.threshold
    except Exception:
        return False