MIPROv2Optimizer
MIPRO v2 optimizer that tunes instructions and demonstrations via a 3-stage pipeline:
Demo generation: creates diverse candidate demo sets via bootstrapping.
Instruction proposal: generates instruction variants via a meta-LLM.
Grid search: evaluates random (instruction, demo set) combinations on a validation set.
The training dataset is shuffled with validationSplitSeed and split in DSPy's MIPROv2 proportions: 20 % goes to demo generation and instruction proposal, and the validation set is drawn from the other 80 %. No candidate is therefore scored on an item its demos or instructions were built from.
Produces an OptimizationArtifact with the best-scoring instruction and demo set for each optimizable module (strategy-level and per-subgraph).
Parameters
LLM model for meta-LLM calls (instruction proposal, dataset summarization).
Preset mode controlling defaults (LIGHT/MEDIUM/HEAVY).
Manual override for number of candidates per module.
Manual override for the validation-set size used to score candidates. The validation set can't be larger than the 80 % of the dataset left after the demo-generation items.
Manual override for grid search trials.
Max demos per bootstrap run.
Total demo slots (bootstrapped and labeled).
Whether bootstrap uses labeled fallback.
Configuration for an instruction proposal.
File path to save/load the optimization artifact.
Seed for reproducibility.
Seed of the shuffle that decides which items generate demos and which validate. Kept apart from randomSeed, so runs with different randomSeed values validate on the same items.
Max concurrent operations (bootstrap runs, instruction proposals).
Constructors
Types
Persistence helpers for the optimized OptimizationArtifact.
Functions
Trains the agent using the provided session, which gives access to a TrainingSession.use block where the training scope (agent, dataset, tracked execution methods) is available.