FailLoud Playground / Guides

How do I check if a RAG answer is actually supported by the retrieved documents?

Short answer

Check the parts of grounding that can be checked deterministically. FailLoud's FL006 unsupported_answer verifies that every citation resolves to a source that was actually retrieved, that every cited source carries text, and that every number in the answer appears in the sources. On the shipped failing RAG example that is 4 errors — two fabricated citations, two invented figures — and exit code 1. What it deliberately does not judge is semantic entailment: no model sits in the verdict path.

The technique

Retrieval gets measured by every dashboard; whether the answer is backed by what was retrieved is measured by nobody. Grounding splits into two kinds of question:

Run the deterministic layer first. An answer that invents citations or figures fails before any judge is consulted — and most production RAG failures start there, not in subtle entailment.

The worked example

$ failloud check examples/rag_failing.json --only FL006
[FL006] unsupported_answer — FAIL
  ✗ $.citations — Citation 'refund_policy' does not resolve to any retrieved
    source — the answer cites a source that was never retrieved.
  ✗ $.answer — Citation [9] does not resolve to any retrieved source.
  ✗ $.answer — Answer states the number 3 but it appears in no cited source.
  ✗ $.answer — Answer states the number 25 but it appears in no cited source.
Verdict: FAIL (4 error(s), 0 warning(s))

Number handling is normalised — 1,200, 1200 and 1200.0 are the same number — and an answer that cites none of its retrieved sources earns a warning, not an error. The check activates only on RAG-shaped documents (an answer plus sources/retrieved/chunks/documents, explicit citations, or inline citation markers); anything else is out of scope and produces no findings.

When to use a judge instead

If the failure you fear is a subtle misreading of a real source, FL006 will pass it and a judged metric (Ragas faithfulness, DeepEval's hallucination metric) is the right second layer. If the failure you fear is invented evidence — the kind that ships confidently and gets quoted downstream — the deterministic check is the gate, because it cannot be talked out of its verdict.