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.
52
53
54
55
56
|
# File 'lib/rubric_llm/rspec.rb', line 52
def initialize(context, question: nil)
super()
@context = context
@question = question
end
|
Instance Method Details
#failure_message ⇒ Object
63
64
65
|
# File 'lib/rubric_llm/rspec.rb', line 63
def failure_message
"expected faithfulness >= #{threshold}, got #{result[:score] || "nil"}"
end
|
#failure_message_when_negated ⇒ Object
67
68
69
|
# File 'lib/rubric_llm/rspec.rb', line 67
def failure_message_when_negated
"expected faithfulness < #{threshold}, got #{result[:score]}"
end
|
#matches?(answer) ⇒ Boolean
58
59
60
61
|
# File 'lib/rubric_llm/rspec.rb', line 58
def matches?(answer)
score = evaluate(Metrics::Faithfulness, question: @question || "", answer:, context: @context)
score && score >= threshold
end
|