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.
94
95
96
97
|
# File 'lib/rubric_llm/rspec.rb', line 94
def initialize(question)
super()
@question = question
end
|
Instance Method Details
#failure_message ⇒ Object
104
105
106
|
# File 'lib/rubric_llm/rspec.rb', line 104
def failure_message
"expected relevance >= #{threshold}, got #{result[:score] || "nil"}"
end
|
#failure_message_when_negated ⇒ Object
108
109
110
|
# File 'lib/rubric_llm/rspec.rb', line 108
def failure_message_when_negated
"expected relevance < #{threshold}, got #{result[:score]}"
end
|
#matches?(answer) ⇒ Boolean
99
100
101
102
|
# File 'lib/rubric_llm/rspec.rb', line 99
def matches?(answer)
score = evaluate(Metrics::Relevance, question: @question, answer:)
score && score >= threshold
end
|