Evaluations
evaluations ¶
MaxEvaluationsStopper for stopping evolution after a set number of evaluations.
This module provides a stopper that terminates evolution when the total number of evaluations reaches a configured limit, useful for controlling API costs.
| ATTRIBUTE | DESCRIPTION |
|---|---|
MaxEvaluationsStopper | Stop evolution after maximum evaluations. TYPE: |
Examples:
Basic usage:
from gepa_adk.adapters.stoppers import MaxEvaluationsStopper
stopper = MaxEvaluationsStopper(1000) # Stop after 1000 evaluations
With EvolutionConfig:
from gepa_adk.domain.models import EvolutionConfig
from gepa_adk.adapters.stoppers import MaxEvaluationsStopper
config = EvolutionConfig(
max_iterations=100,
stop_callbacks=[MaxEvaluationsStopper(5000)],
)
Note
This stopper is particularly useful for controlling API costs when using expensive model evaluations. The evaluation count is cumulative across all iterations.
MaxEvaluationsStopper ¶
Stop evolution after maximum number of evaluations.
Useful for controlling API costs when evaluations are expensive. Checks the total_evaluations field from StopperState against the configured limit.
| ATTRIBUTE | DESCRIPTION |
|---|---|
max_evaluations | Maximum number of evaluate() calls allowed. TYPE: |
Examples:
Stop after 1000 evaluations:
Check if evolution should stop:
Note
Any evaluation count at or above the limit triggers a stop. This handles the case where batch evaluations cause the count to exceed the exact limit.
Source code in src/gepa_adk/adapters/stoppers/evaluations.py
__init__ ¶
Initialize the stopper with maximum evaluation count.
| PARAMETER | DESCRIPTION |
|---|---|
max_evaluations | Maximum number of evaluate() calls allowed. Must be a positive integer. TYPE: |
| RAISES | DESCRIPTION |
|---|---|
ValueError | If max_evaluations is not positive. |
Note
Configure this value based on your API budget. Each evaluation typically corresponds to one model API call.
Source code in src/gepa_adk/adapters/stoppers/evaluations.py
__call__ ¶
__call__(state: StopperState) -> bool
Check if evolution should stop based on evaluation count.
| PARAMETER | DESCRIPTION |
|---|---|
state | Current evolution state snapshot containing the total_evaluations count. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
bool | True if total_evaluations >= max_evaluations, False otherwise. |
Note
Once this returns True, evolution should terminate to stay within the configured evaluation budget.