GEPAOptimizer

class GEPAOptimizer<Input, Output, InputLabel>(gepaFeedback: GEPAFeedback<Input, Output, InputLabel>, feedbackValSplitFn: (TrainSet<Input, InputLabel>) -> GEPATrainSetSplit<Input, InputLabel>, reflectionModel: LLModel, val storagePath: ResilientPath, numRollouts: Int, feedbackBatchSize: Int = 3, skipPerfectFeedbackBatches: Boolean = true, perfectScoreThreshold: Double = 1.0, randomSeed: Long = 42, moduleSelectionStrategy: GEPAModuleSelectionStrategy = GEPAModuleSelectionStrategy.ROUND_ROBIN, useStructuredOutput: Boolean = false, requireThinkingFieldInOutput: Boolean = false, mergeConfig: GEPAMergeConfig = GEPAMergeConfig(), failureScore: Double = 0.0, feedbackFailureRateThreshold: Double = 1.0, validationFailureRateThreshold: Double = 0.9, seedValidationFailureRateThreshold: Double = 0.0, abortOnFailureRateExceeded: Boolean = true) : AgentOptimizer<Input, Output, InputLabel>

GEPA optimizer, based on "GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning" (https://arxiv.org/abs/2507.19457).

Training splits the dataset into feedback and validation sets, proposes instruction updates from module-level textual feedback, and keeps candidates that improve over their parent on feedback batches. Accepted candidates are evaluated on the validation set and tracked in a Pareto-style candidate pool.

Constructors

Link copied to clipboard
constructor(gepaFeedback: GEPAFeedback<Input, Output, InputLabel>, feedbackValSplitFn: (TrainSet<Input, InputLabel>) -> GEPATrainSetSplit<Input, InputLabel>, reflectionModel: LLModel, storagePath: ResilientPath, numRollouts: Int, feedbackBatchSize: Int = 3, skipPerfectFeedbackBatches: Boolean = true, perfectScoreThreshold: Double = 1.0, randomSeed: Long = 42, moduleSelectionStrategy: GEPAModuleSelectionStrategy = GEPAModuleSelectionStrategy.ROUND_ROBIN, useStructuredOutput: Boolean = false, requireThinkingFieldInOutput: Boolean = false, mergeConfig: GEPAMergeConfig = GEPAMergeConfig(), failureScore: Double = 0.0, feedbackFailureRateThreshold: Double = 1.0, validationFailureRateThreshold: Double = 0.9, seedValidationFailureRateThreshold: Double = 0.0, abortOnFailureRateExceeded: Boolean = true)

Types

Link copied to clipboard
object Companion

Utilities for reading GEPA artifacts from persistent storage.

Properties

Link copied to clipboard

Path where the best optimization artifact is written and later loaded from.

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.