Class: DSPy::Teleprompt::MIPROv2::MIPROv2Result

Inherits:
OptimizationResult
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dspy/teleprompt/mipro_v2.rb

Overview

Result of MIPROv2 optimization

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(optimized_program:, scores:, history:, evaluated_candidates:, optimization_trace:, bootstrap_statistics:, proposal_statistics:, best_score_name: nil, best_score_value: nil, metadata: {}, best_evaluation_result: nil) ⇒ MIPROv2Result

Returns a new instance of MIPROv2Result.



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 224

def initialize(optimized_program:, scores:, history:, evaluated_candidates:, optimization_trace:, bootstrap_statistics:, proposal_statistics:, best_score_name: nil, best_score_value: nil, metadata: {}, best_evaluation_result: nil)
  super(
    optimized_program: optimized_program,
    scores: scores,
    history: history,
    best_score_name: best_score_name,
    best_score_value: best_score_value,
    metadata: 
  )
  @evaluated_candidates = evaluated_candidates.freeze
  @optimization_trace = optimization_trace.freeze
  @bootstrap_statistics = bootstrap_statistics.freeze
  @proposal_statistics = proposal_statistics.freeze
  @best_evaluation_result = best_evaluation_result&.freeze
end

Instance Attribute Details

#best_evaluation_resultObject (readonly)

Returns the value of attribute best_evaluation_result.



207
208
209
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 207

def best_evaluation_result
  @best_evaluation_result
end

#bootstrap_statisticsObject (readonly)

Returns the value of attribute bootstrap_statistics.



201
202
203
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 201

def bootstrap_statistics
  @bootstrap_statistics
end

#evaluated_candidatesObject (readonly)

Returns the value of attribute evaluated_candidates.



195
196
197
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 195

def evaluated_candidates
  @evaluated_candidates
end

#optimization_traceObject (readonly)

Returns the value of attribute optimization_trace.



198
199
200
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 198

def optimization_trace
  @optimization_trace
end

#proposal_statisticsObject (readonly)

Returns the value of attribute proposal_statistics.



204
205
206
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 204

def proposal_statistics
  @proposal_statistics
end

Instance Method Details

#to_hObject



241
242
243
244
245
246
247
248
249
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 241

def to_h
  super.merge({
    evaluated_candidates: @evaluated_candidates.map(&:to_h),
    optimization_trace: @optimization_trace,
    bootstrap_statistics: @bootstrap_statistics,
    proposal_statistics: @proposal_statistics,
    best_evaluation_result: @best_evaluation_result&.to_h
  })
end