LayaEval logoLayaEval/RAG Checks/Contradiction Detection
RAG-019RAG · Staying truthfullayaeval.ContradictionDetection

Contradiction Detection

Does the answer say the opposite of the sources?

SOURCEOpens at 9amANSWEROpens at 9amThey agree
Simulation state:
When it passes

They agree.

Threshold satisfied: evaluation score <= 0.20.

When it fails

They disagree.

Violation detected: execution flagged for human review or fallback routing.

SDK Specification

ParameterValueDescription
ClassContradictionDetectionPython evaluator class in layaeval
Required Fields"context", "response"Arguments expected in the call signature
Default Threshold<= 0.20Passes when risk score is at or below this value
CategoryRAG EvaluationStaying truthful (Does every line come from the pages, with nothing made up?)

Python Example

pip install layaeval
contradiction-detection.py
1from layaeval import ContradictionDetection
2
3metric = ContradictionDetection(threshold=0.20) # passes when risk is at or below 0.20
4
5res = metric(
6 context="Paris is the capital of France.",
7 response="Paris is the capital of France.",
8)
9
10print(res.passed, res.value, res.confidence)

Related RAG Checks

Other checks in Staying truthful

View all 42 checks →