Class: RubricLLM::RSpecMatchers::FaithfulnessMatcher
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 FaithfulnessMatcher.
56
57
58
59
60
61
|
# File 'lib/rubric_llm/rspec.rb', line 56
def initialize(context, question: nil)
super()
require_context!(context)
@context = context
@question = question
end
|
Instance Method Details
#failure_message ⇒ Object
68
69
70
|
# File 'lib/rubric_llm/rspec.rb', line 68
def failure_message
"expected faithfulness >= #{threshold}, got #{result[:score] || "nil"}"
end
|
#failure_message_when_negated ⇒ Object
72
73
74
|
# File 'lib/rubric_llm/rspec.rb', line 72
def failure_message_when_negated
"expected faithfulness < #{threshold}, got #{result[:score]}"
end
|
#matches?(answer) ⇒ Boolean
63
64
65
66
|
# File 'lib/rubric_llm/rspec.rb', line 63
def matches?(answer)
score = evaluate(Metrics::Faithfulness, question: @question || "", answer:, context: @context)
score && score >= threshold
end
|