MIPROv2Optimizer

class MIPROv2Optimizer<Input, Output, InputLabel>(metaModel: LLModel, autoMode: AutoRunMode = AutoRunMode.LIGHT, numCandidatesOverride: Int? = null, numTrialsOverride: Int? = null, maxBootstrappedDemos: Int = 4, maxTotalDemos: Int = 8, includeLabeledExamples: Boolean = true, proposerConfig: InstructionProposerConfig = InstructionProposerConfig(), val storagePath: ResilientPath, randomSeed: Long = 42, parallelism: Int = 1) : AgentOptimizer<Input, Output, InputLabel>

MIPRO v2 optimizer that tunes instructions and demonstrations via a 3-stage pipeline:

  1. Demo generation: creates diverse candidate demo sets via bootstrapping.

  2. Instruction proposal: generates instruction variants via a meta-LLM.

  3. Grid search: evaluates random (instruction, demo set) combinations on a validation set.

Produces an OptimizationArtifact with the best-scoring instruction and demo set for each optimizable module (strategy-level and per-subgraph).

Parameters

metaModel

LLM model for meta-LLM calls (instruction proposal, dataset summarization).

autoMode

Preset mode controlling defaults (LIGHT/MEDIUM/HEAVY).

numCandidatesOverride

Manual override for number of candidates per module.

numTrialsOverride

Manual override for grid search trials.

maxBootstrappedDemos

Max demos per bootstrap run.

maxTotalDemos

Total demo slots (bootstrapped and labeled).

includeLabeledExamples

Whether bootstrap uses labeled fallback.

proposerConfig

Configuration for an instruction proposal.

storagePath

File path to save/load the optimization artifact.

randomSeed

Seed for reproducibility.

parallelism

Max concurrent operations (bootstrap runs, instruction proposals).

Constructors

Link copied to clipboard
constructor(metaModel: LLModel, autoMode: AutoRunMode = AutoRunMode.LIGHT, numCandidatesOverride: Int? = null, numTrialsOverride: Int? = null, maxBootstrappedDemos: Int = 4, maxTotalDemos: Int = 8, includeLabeledExamples: Boolean = true, proposerConfig: InstructionProposerConfig = InstructionProposerConfig(), storagePath: ResilientPath, randomSeed: Long = 42, parallelism: Int = 1)

Types

Link copied to clipboard
object Companion

Persistence helpers for the optimized OptimizationArtifact.

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override fun loadOptimizedAgent(baseAgent: GraphAIAgent<Input, Output>): GraphAIAgent<Input, Output>

Loads training artifacts produced by train and applies them to the given baseAgent.

Link copied to clipboard
open suspend override fun train(session: TrainingSession<Input, Output, InputLabel>): TrainingResult

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.