Class: RubricLLM::RSpecMatchers::RelevanceMatcher
Instance Attribute Summary
Attributes inherited from BaseMatcher
#config, #result, #threshold
Instance Method Summary
collapse
Methods inherited from BaseMatcher
#with_config, #with_threshold
Constructor Details
Returns a new instance of RelevanceMatcher.
99
100
101
102
|
# File 'lib/rubric_llm/rspec.rb', line 99
def initialize(question)
super()
@question = question
end
|
Instance Method Details
#failure_message ⇒ Object
109
110
111
|
# File 'lib/rubric_llm/rspec.rb', line 109
def failure_message
"expected relevance >= #{threshold}, got #{result[:score] || "nil"}"
end
|
#failure_message_when_negated ⇒ Object
113
114
115
|
# File 'lib/rubric_llm/rspec.rb', line 113
def failure_message_when_negated
"expected relevance < #{threshold}, got #{result[:score]}"
end
|
#matches?(answer) ⇒ Boolean
104
105
106
107
|
# File 'lib/rubric_llm/rspec.rb', line 104
def matches?(answer)
score = evaluate(Metrics::Relevance, question: @question, answer:)
score && score >= threshold
end
|