Class: RubricLLM::RSpecMatchers::CorrectnessMatcher
Instance Attribute Summary
Attributes inherited from BaseMatcher
#config, #result, #threshold
Instance Method Summary
collapse
Methods inherited from BaseMatcher
#with_config, #with_threshold
Constructor Details
#initialize(ground_truth, question: nil) ⇒ CorrectnessMatcher
Returns a new instance of CorrectnessMatcher.
73
74
75
76
77
|
# File 'lib/rubric_llm/rspec.rb', line 73
def initialize(ground_truth, question: nil)
super()
@ground_truth = ground_truth
@question = question
end
|
Instance Method Details
#failure_message ⇒ Object
84
85
86
|
# File 'lib/rubric_llm/rspec.rb', line 84
def failure_message
"expected correctness >= #{threshold}, got #{result[:score] || "nil"}"
end
|
#failure_message_when_negated ⇒ Object
88
89
90
|
# File 'lib/rubric_llm/rspec.rb', line 88
def failure_message_when_negated
"expected correctness < #{threshold}, got #{result[:score]}"
end
|
#matches?(answer) ⇒ Boolean
79
80
81
82
|
# File 'lib/rubric_llm/rspec.rb', line 79
def matches?(answer)
score = evaluate(Metrics::Correctness, question: @question || "", answer:, ground_truth: @ground_truth)
score && score >= threshold
end
|