optimizer = dspy.GEPA( metric=metric_with_feedback, auto="medium", reflection_minibatch_size=3, candidate_selection_strategy="pareto", reflection_lm=dspy.LM("gpt-5", temperature=1.0, max_tokens=32000), use_merge=True, track_stats=True, ) optimized = optimizer.compile(program, trainset=train, valset=val)