RAG-020RAG · Staying truthfullayaeval.ContextConflictDetection

Context Conflict

Do two fetched sources disagree with each other?

SOURCE A$180 a nightSOURCE B$180 a nightThey agree
Simulation state:
When it passes

Sources agree.

Threshold satisfied: evaluation score <= 0.30.

When it fails

Sources conflict.

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

SDK Specification

ParameterValueDescription
ClassContextConflictDetectionPython evaluator class in layaeval
Required Fields"query", "retrieved_context"Arguments expected in the call signature
Default Threshold<= 0.30Passes 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
context-conflict.py
1from layaeval import ContextConflictDetection
2
3metric = ContextConflictDetection(threshold=0.30) # passes when risk is at or below 0.30
4
5res = metric(
6 query="What is the capital of France?",
7 retrieved_context="Paris is the capital of France, with 2.1M residents.",
8)
9
10print(res.passed, res.value, res.confidence)

Related RAG Checks

Other checks in Staying truthful

View all 42 checks →