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.
78
79
80
81
82
|
# File 'lib/rubric_llm/rspec.rb', line 78
def initialize(ground_truth, question: nil)
super()
@ground_truth = ground_truth
@question = question
end
|
Instance Method Details
#failure_message ⇒ Object
89
90
91
|
# File 'lib/rubric_llm/rspec.rb', line 89
def failure_message
"expected correctness >= #{threshold}, got #{result[:score] || "nil"}"
end
|
#failure_message_when_negated ⇒ Object
93
94
95
|
# File 'lib/rubric_llm/rspec.rb', line 93
def failure_message_when_negated
"expected correctness < #{threshold}, got #{result[:score]}"
end
|
#matches?(answer) ⇒ Boolean
84
85
86
87
|
# File 'lib/rubric_llm/rspec.rb', line 84
def matches?(answer)
score = evaluate(Metrics::Correctness, question: @question || "", answer:, ground_truth: @ground_truth)
score && score >= threshold
end
|