Class: DSPy::Teleprompt::GEPA
- Inherits:
-
Teleprompter
- Object
- Teleprompter
- DSPy::Teleprompt::GEPA
- Extended by:
- T::Sig
- Defined in:
- lib/dspy/teleprompt/gepa.rb
Overview
GEPA: Genetic-Pareto Reflective Prompt Evolution optimizer Uses natural language reflection to evolve prompts through genetic algorithms and Pareto frontier selection for maintaining diverse high-performing candidates
Defined Under Namespace
Classes: CrossoverEngine, CrossoverType, ExecutionTrace, FitnessEvaluator, FitnessScore, GEPAConfig, GeneticEngine, InstructionProposer, MutationEngine, MutationType, ParetoSelector, ReflectionEngine, ReflectionResult, TraceCollector
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Attributes inherited from Teleprompter
Instance Method Summary collapse
- #compile(program, trainset:, valset: nil) ⇒ Object
-
#initialize(metric: nil, config: nil) ⇒ GEPA
constructor
A new instance of GEPA.
Methods inherited from Teleprompter
#create_evaluator, #ensure_typed_examples, #evaluate_program, #save_results, #validate_inputs
Constructor Details
#initialize(metric: nil, config: nil) ⇒ GEPA
Returns a new instance of GEPA.
2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 |
# File 'lib/dspy/teleprompt/gepa.rb', line 2476 def initialize(metric: nil, config: nil) @config = config || GEPAConfig.new # Validate that reflection_lm is configured unless @config.reflection_lm raise ArgumentError, "reflection_lm must be configured for GEPA optimization. Set config.reflection_lm to a DSPy::LM instance." end super(metric: metric, config: @config) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
2468 2469 2470 |
# File 'lib/dspy/teleprompt/gepa.rb', line 2468 def config @config end |
Instance Method Details
#compile(program, trainset:, valset: nil) ⇒ Object
2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 |
# File 'lib/dspy/teleprompt/gepa.rb', line 2496 def compile(program, trainset:, valset: nil) validate_inputs(program, trainset, valset) instrument_step('gepa_compile', { trainset_size: trainset.size, valset_size: valset&.size || 0, num_generations: @config.num_generations, population_size: @config.population_size }) do # Always perform full GEPA genetic algorithm optimization perform_gepa_optimization(program, trainset, valset) end end |