RAG-019RAG · Staying truthfullayaeval.ContradictionDetection
Contradiction Detection
Does the answer say the opposite of the sources?
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
| Parameter | Value | Description |
|---|---|---|
| Class | ContradictionDetection | Python evaluator class in layaeval |
| Required Fields | "context", "response" | Arguments expected in the call signature |
| Default Threshold | <= 0.20 | Passes when risk score is at or below this value |
| Category | RAG Evaluation | Staying truthful (Does every line come from the pages, with nothing made up?) |
Python Example
contradiction-detection.py
1from layaeval import ContradictionDetection23metric = ContradictionDetection(threshold=0.20) # passes when risk is at or below 0.2045res = metric(6 context="Paris is the capital of France.",7 response="Paris is the capital of France.",8)910print(res.passed, res.value, res.confidence)
Related RAG Checks
Other checks in Staying truthful
RAG-006Read →
Groundedness
Is each sentence in the answer backed by the sources?
RAG-007Read →
Strict Groundedness
A yes or no: is every claim proven? One gap fails it.
RAG-008Read →
Hallucination Risk
Did the answer invent facts that aren't in the sources?
RAG-014Read →
Context Utilization
Did the answer use the useful facts it was given?
RAG-018Read →
Claim Support
Is this single claim backed by the evidence?
RAG-020Read →
Context Conflict
Do two fetched sources disagree with each other?