Skip to content

Commit d81dd4c

Browse files
[docs] Add GEPA gepa_kwargs documentation (#8998)
* Add GEPA gepa_kwargs documentation * Remove unnecessary arguments * Add MLflow args
1 parent 7dabab8 commit d81dd4c

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

dspy/teleprompt/gepa/gepa.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def metric(
243243
Note: When both instruction_proposer and reflection_lm are set, the instruction_proposer is called
244244
in the reflection_lm context. However, reflection_lm is optional when using a custom instruction_proposer.
245245
Custom instruction proposers can invoke their own LLMs if needed.
246-
component_selector: Custom component selector implementing the ReflectionComponentSelector protocol,
246+
component_selector: Custom component selector implementing the [ReflectionComponentSelector](https://github.com/gepa-ai/gepa/blob/main/src/gepa/proposer/reflective_mutation/base.py) protocol,
247247
or a string specifying a built-in selector strategy. Controls which components (predictors) are selected
248248
for optimization at each iteration. Defaults to 'round_robin' strategy which cycles through components
249249
one at a time. Available string options: 'round_robin' (cycles through components sequentially),
@@ -274,7 +274,34 @@ def metric(
274274
called with and without the pred_name. This flag (defaults to True) determines whether a warning is
275275
raised if a mismatch in module-level and predictor-level score is detected.
276276
seed: The random seed to use for reproducibility. Default is 0.
277-
gepa_kwargs: (Optional) provide additional kwargs to be passed to [gepa.optimize](https://github.com/gepa-ai/gepa/blob/main/src/gepa/api.py) method
277+
gepa_kwargs: (Optional) Additional keyword arguments to pass directly to [gepa.optimize](https://github.com/gepa-ai/gepa/blob/main/src/gepa/api.py).
278+
Useful for accessing advanced GEPA features not directly exposed through DSPy's GEPA interface.
279+
280+
Available parameters:
281+
- batch_sampler: Strategy for selecting training examples. Can be a [BatchSampler](https://github.com/gepa-ai/gepa/blob/main/src/gepa/strategies/batch_sampler.py) instance or a string
282+
('epoch_shuffled'). Defaults to 'epoch_shuffled'. Only valid when reflection_minibatch_size is None.
283+
- merge_val_overlap_floor: Minimum number of shared validation ids required between parents before
284+
attempting a merge subsample. Only relevant when using `val_evaluation_policy` other than 'full_eval'.
285+
Default is 5.
286+
- stop_callbacks: Optional stopper(s) that return True when optimization should stop. Can be a single
287+
[StopperProtocol](https://github.com/gepa-ai/gepa/blob/main/src/gepa/utils/stop_condition.py) or a list of StopperProtocol instances.
288+
Examples: [FileStopper](https://github.com/gepa-ai/gepa/blob/main/src/gepa/utils/stop_condition.py),
289+
[TimeoutStopCondition](https://github.com/gepa-ai/gepa/blob/main/src/gepa/utils/stop_condition.py),
290+
[SignalStopper](https://github.com/gepa-ai/gepa/blob/main/src/gepa/utils/stop_condition.py),
291+
[NoImprovementStopper](https://github.com/gepa-ai/gepa/blob/main/src/gepa/utils/stop_condition.py),
292+
or custom stopping logic. Note: This overrides the default
293+
max_metric_calls stopping condition.
294+
- use_cloudpickle: Use cloudpickle instead of pickle for serialization. Can be helpful when the
295+
serialized state contains dynamically generated DSPy signatures. Default is False.
296+
- val_evaluation_policy: Strategy controlling which validation ids to score each iteration. Can be
297+
'full_eval' (evaluate every id each time) or an [EvaluationPolicy](https://github.com/gepa-ai/gepa/blob/main/src/gepa/strategies/eval_policy.py) instance. Default is 'full_eval'.
298+
- use_mlflow: If True, enables MLflow integration to log optimization progress.
299+
MLflow can be used alongside Weights & Biases (WandB).
300+
- mlflow_tracking_uri: The tracking URI to use for MLflow (when use_mlflow=True).
301+
- mlflow_experiment_name: The experiment name to use for MLflow (when use_mlflow=True).
302+
303+
Note: Parameters already handled by DSPy's GEPA class will be overridden by the direct parameters
304+
and should not be passed through gepa_kwargs.
278305
279306
Note:
280307
Budget Configuration: Exactly one of `auto`, `max_full_evals`, or `max_metric_calls` must be provided.

0 commit comments

Comments
 (0)