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.



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 213

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.



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

def best_evaluation_result
  @best_evaluation_result
end

#bootstrap_statisticsObject (readonly)

Returns the value of attribute bootstrap_statistics.



190
191
192
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 190

def bootstrap_statistics
  @bootstrap_statistics
end

#evaluated_candidatesObject (readonly)

Returns the value of attribute evaluated_candidates.



184
185
186
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 184

def evaluated_candidates
  @evaluated_candidates
end

#optimization_traceObject (readonly)

Returns the value of attribute optimization_trace.



187
188
189
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 187

def optimization_trace
  @optimization_trace
end

#proposal_statisticsObject (readonly)

Returns the value of attribute proposal_statistics.



193
194
195
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 193

def proposal_statistics
  @proposal_statistics
end

Instance Method Details

#to_hObject



230
231
232
233
234
235
236
237
238
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 230

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