table.optimize(labels, metric) tunes the instructions of a table’s own LM step against rows
you’ve labeled, using the GEPA optimizer.
labelsis a DataFrame or list of dicts with the table’s key column(s), such astrial(ortrialandstepfor a step-level table), plus the right answer.metricis an output column to match exactly (strings case-insensitively), or a functionfn(row, label)returning a score, or(score, feedback)so GEPA knows what went wrong.budgetcaps how many example runs GEPA makes (default 60).val_frac(default 0.3) is the share of labels held out to score before and after.
.optimize_report has train and held-out
scores before and after, the candidates, and the LM calls and cost of running the step
(reflection calls aren’t counted).
Example: classify steps
examples/optimize_step_kinds.py labels each step from its real tool calls (edit, test, explore or other), then tunes a
classifier that only sees the step’s one-sentence summary:
Next steps
Choose a model
Pick the model the tuned step runs on.
Python SDK
Every
optimize argument.