Module: RubricLLM::Assertions
- Defined in:
- lib/rubric_llm/minitest.rb
Instance Method Summary collapse
- #assert_correct(answer, ground_truth, question: "", threshold: 0.8, config: RubricLLM.config) ⇒ Object
- #assert_faithful(answer, context, question: "", threshold: 0.8, config: RubricLLM.config) ⇒ Object
- #assert_relevant(question, answer, threshold: 0.8, config: RubricLLM.config) ⇒ Object
- #refute_hallucination(answer, context, question: "", threshold: 0.8, config: RubricLLM.config) ⇒ Object
Instance Method Details
#assert_correct(answer, ground_truth, question: "", threshold: 0.8, config: RubricLLM.config) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/rubric_llm/minitest.rb', line 23 def assert_correct(answer, ground_truth, question: "", threshold: 0.8, config: RubricLLM.config) result = evaluate_metric(Metrics::Correctness, question:, answer:, ground_truth:, config:) score = result[:score] assert score && score >= threshold, "Expected correctness >= #{threshold}, got #{score || "nil"}.#{failure_details(result)}" end |
#assert_faithful(answer, context, question: "", threshold: 0.8, config: RubricLLM.config) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/rubric_llm/minitest.rb', line 7 def assert_faithful(answer, context, question: "", threshold: 0.8, config: RubricLLM.config) result = evaluate_metric(Metrics::Faithfulness, question:, answer:, context:, config:) score = result[:score] assert score && score >= threshold, "Expected faithfulness >= #{threshold}, got #{score || "nil"}.#{failure_details(result)}" end |
#assert_relevant(question, answer, threshold: 0.8, config: RubricLLM.config) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rubric_llm/minitest.rb', line 15 def assert_relevant(question, answer, threshold: 0.8, config: RubricLLM.config) result = evaluate_metric(Metrics::Relevance, question:, answer:, config:) score = result[:score] assert score && score >= threshold, "Expected relevance >= #{threshold}, got #{score || "nil"}.#{failure_details(result)}" end |
#refute_hallucination(answer, context, question: "", threshold: 0.8, config: RubricLLM.config) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/rubric_llm/minitest.rb', line 31 def refute_hallucination(answer, context, question: "", threshold: 0.8, config: RubricLLM.config) result = evaluate_metric(Metrics::Faithfulness, question:, answer:, context:, config:) score = result[:score] assert score && score >= threshold, "Detected hallucination: faithfulness #{score || "nil"} < #{threshold}.#{failure_details(result)}" end |