a research project for RAG faithfulness

Explainable, type-routed hallucination detection for RAG applications

ClaimRoute decomposes a RAG answer into atomic claims, routes each to a type-specific verifier, and returns a per-claim audit trail , not just a score. Backed by a systematic review of 30 published pipelines.

The Problem

Three cross-pipeline weaknesses in the field

A structured reading of 30 hallucination-detection papers published 2023 – mid-2026 found three patterns that no prior survey has reported together. Each is the research gap ClaimRoute addresses.

F1 | Regime transfer

Trained on world knowledge, deployed on supplied context

16 of 30 reviewed papers validate claim-processing methods on world-knowledge data (Wikipedia, Google Search) but deploy them on supplied-context RAG settings without re-validation.

16 / 30 papers | 0 re-validated
F2 | Granularity wall

Finding a hallucination is 20 pp easier than locating it

A consistent 20 – 21 percentage-point gap between response-level and span-level accuracy, across LettuceDetect, FAVA and FullCite. Papers report both as if on one scale.

Δ = 20 – 23 pp | 3 systems
F3 | Typing gap

Claim type moves accuracy by 38–43 pp

Three independent domain studies , legal (LegalHalluLens), financial (FinGround), government (RAGShield) , show claim type is the dominant source of per-case accuracy variance. No general-domain system in the corpus routes claims by type.

Δ = 38 – 43 pp | 0 general-domain routers

"No general-domain verification system in the reviewed corpus routes claims by type. ClaimRoute is that system."

, from the review paper's Section V-C (Typing gap)

Upstream of ClaimRoute

How context reaches the pipeline

ClaimRoute is an evaluation layer. It does not retrieve documents or write prompts. In production, a Context Assembler (your retriever plus a chunker) supplies the supplied context field. ClaimRoute enters at the verification stage, after answer generation.

1
Query
User question arrives at the RAG app
,
2
Retrieval
Embedding search, BM25, or hybrid
,
3
Chunking + rank
Top k passages, 25 sentences each, 10-sentence overlap
,
4
Context assembled
Concatenated passages become the context
,
5
Generator
LLM produces the answer
enters here,
6
ClaimRoute
Decompose, route, verify, audit

ClaimRoute accepts the context verbatim. Default chunker is ChunkingConfig(window_sentences=25, overlap_sentences=10), swappable per sample. Any upstream retriever works, LangChain, LlamaIndex, Haystack, or a hand rolled one.

The Solution

Four layers that route, verify, calibrate, and explain

Each extracted claim is classified by type, routed to a specialist verifier, calibrated against type-specific behaviour, and logged with a full audit trail.

flowchart TB
    S["Sample: question, context, answer"]
    S --> E["Claim Extractor qwen3 32b"]
    E --> C["N typed claims"]
    C --> R{"L1 Type Router"}
    R -->|factual| N["NLI DeBERTa v3 large mnli"]
    R -->|numeric| NUM["Numerical regex and arithmetic"]
    R -->|temporal| T["Temporal dateutil parser"]
    R -->|comparison| CMP["Comparative negation augmented NLI"]
    R -->|other| F["LLM fallback llama 3.3 70b"]
    N --> V["VerificationResult"]
    NUM --> V
    T --> V
    CMP --> V
    F --> V
    V --> P["L3 Platt calibration per type"]
    P --> AG["L3 Noisy OR aggregation"]
    AG --> OUT["Sample P hallucinated"]
    V -.-> AUD["L4 XAI RoutingDecision per claim"]
    AUD -.-> CSV["routing audit csv"]
      
Interactive Demo

Three real-world cases , see it think claim by claim

Each sample shows context, the model's answer, and ClaimRoute's per-claim verdict with the verifier that fired. Examples illustrative; distribution of verdicts matches the actual Kaggle run on RAGTruth-Enhance (n = 1,200).

Try it on your own text

Paste a context and an answer , see claims extracted, typed and verified in real time

End-to-end pipeline running in your browser: sentence splitter → rule-based type classifier → the specialist verifiers from the previous section. Numerical, Temporal and Comparative execute real logic; Factual uses a lexical overlap heuristic (offline preview , DeBERTa runs server-side in production).

no accounts, no API keys, no backend.

Pipeline: split → classify → route → verify → aggregate
Awaiting input
Hit Run full pipeline to see each claim extracted and classified. Each verdict shows the specialist that fired and a one-line reason.

"The system that cannot explain why it thinks a claim is wrong cannot be trusted with the claim at all."

, on L4 explainability

Side by side comparison

Same input, three verification strategies, honest differences

Runs the Playground input through three variants: ClaimRoute (type routing + NLI fallback), B (uniform NLI, lexical heuristic offline), and Always flag (predicts hallucinated on every claim). Highlights where they agree and where they diverge.

Hit Run comparison to see ClaimRoute vs uniform NLI vs Always flag on the Playground inputs.
Specialist verifiers at work

Five claim types, five mechanisms , click Run to see each one think

Every claim L1 routes gets a verifier tuned to its logical structure. These five demos run in your browser , Numerical, Temporal and Comparative execute real logic on the inputs you type; NLI and LLM fallback reveal traced output from the actual pipeline's behaviour on representative samples.

numeric regex + word2num + arithmetic

Numerical verifier

Extracts digits and spelled-out numbers from both sides, normalizes units, performs arithmetic equality within a 1% tolerance. Catches numeric contradictions that NLI's contradiction head is silent on.

temporal dateutil + quarter resolver

Temporal verifier

Parses dates and relative time expressions (quarters, fiscal years, "last month"), computes interval overlap. Raises VerificationUnsupported when either side is unparseable, triggering the LLM fallback.

comparison negation-augmented NLI

Comparative verifier

For "higher/lower/better/worse" claims, runs NLI on the original and on a logically negated version, combines verdicts. Three modes: plain NLI, regex-negation, LLM-generated negation.

factual DeBERTa-v3-large-mnli

NLI verifier

435M-parameter DeBERTa-v3-large trained on MNLI + FEVER + ANLI + LING + WaNLI. 3-class classifier over (claim, context) pairs. Batched across chunks, runs on T4 in <1 s per claim.

other / fallback llama-3.3-70b via Groq

LLM fallback verifier

Catch-all for subjective claims and specialists that raise VerificationUnsupported. Constrained JSON prompt returns verdict + confidence + one-line reason. Logged in L4 audit as verifier_used = llm_fallback.

L1 router type classifier → dispatch

How L1 picks the specialist

Every claim goes through a rule-based pre-classifier first (regex + heuristics for numeric / temporal / comparison keywords). Rule hit → classifier_confidence = 1.0. Rule miss → fall back to the extractor's own type label with classifier_confidence = 0.75. Both decisions are logged to L4.

if regex_matches_number(claim) → route to Numerical
elif regex_matches_date(claim) → route to Temporal
elif comparative_keyword(claim) → route to Comparative
elif extractor_type in (factual, entity) → NLI
else → route to LLM fallback

"One uniform verifier for every claim is like one wrench for every bolt , it works, until the bolt is hex."

, design principle of ClaimRoute's L1 router

Measured Results

Three variants, two corpora, paired significance

Fixed splitter, fixed judge, same 1,200 and 400 samples. Only the verification strategy varies. 1,000-iteration bootstrap for 95% CI, paired McNemar exact two-sided for A vs B.

F1 by variant and corpus

A vs B outcome space (Enhance, n = 1,200)

Corpus Variant n F1 95% CI P R McNemar vs B
RAGTruth-EnhanceA routed12000.507[0.469, 0.542]0.7510.383p = 0.39
RAGTruth-EnhanceB NLI only12000.485[0.446, 0.521]0.7660.354,
RAGTruth-EnhanceC det. only12000.128[0.097, 0.161]0.7040.070p ≪ 10⁻²⁰
RAGTruth++A routed4000.283[0.223, 0.343]0.8360.171p = 0.02
RAGTruth++B NLI only4000.244[0.184, 0.307]0.8110.144,
RAGTruth++C det. only4000.108[0.064, 0.159]1.0000.057p < 10⁻³

"Routing is a recall mechanism that trades precision at the current operating point , this is the empirical motivation for L2."

, from docs/results-2026-11-16.md

Recall gain from routing
+24

True hallucinations A catches that uniform NLI misses. The numeric and temporal specialists fire on claims where NLI's contradiction head is silent.

Precision loss from routing
−17

Clean samples A flags that uniform NLI does not. Specialists cry wolf on some factually consistent claims , exactly the signal that motivates L2.

Honest About Failures

Three cases ClaimRoute currently gets wrong

Every detection system has blind spots. Documenting them is the first step to closing them. These three motivate the Gate 2 and Gate 3 work on our roadmap.

Failure 1 | NLI silent

Paraphrased contradictions slip past the NLI head

DeBERTa-MNLI's contradiction head averages 0.07 across 158 evaluations. On a paraphrased contradiction , the context says "profit margin declined 2%" and the answer says "profitability was roughly stable" , NLI returns neutral, not contradicted.

context: "profit margin declined 2%"
answer: "profitability was roughly stable"
→ verdict: entailed (wrong)
Fix pathFine-tune contradiction head on paraphrase-pair contradictions (DocNLI-style). Logged in gate1-progress.md F3.
Failure 2 | Numeric regex

Spelled-out numbers bypass the numerical verifier

The numerical verifier parses digits with regex. An answer that says "twelve thousand dollars" instead of "$12,000" doesn't match the pattern, so the claim falls through to NLI, which treats it as a factual claim and misses the arithmetic error.

context: "revenue grew by $15,000"
answer: "revenue grew by twelve thousand dollars"
→ routed as factual, verdict: entailed
Fix pathAdd word2number preprocessing ahead of regex. One file, 50 lines.
Failure 3 | Temporal leak

dateutil can't parse relative dates , temporal → LLM fallback

In the Gate 1 slice, 2 / 3 temporal-labelled claims were served by the LLM fallback instead of the dateutil-based TemporalVerifier, because the verifier raises VerificationUnsupported whenever dateutil fails to parse either side.

claim: "earnings were up compared to last quarter"
→ dateutil fails on "last quarter"
→ falls back to LLM, routing metadata lost
Fix pathAdd a resolver for relative expressions (quarter / fiscal year / week-of). L2's confidence gate will then route, not fall.
Positioning

Where ClaimRoute fits among published systems

Not every system reports F1 on the same corpus; this table normalises what each reports on grounded (R3) data. Reproduced numbers are from each system's own paper.

System Verifier Reported corpus F1 / Acc Per-claim attribution Open weights Routing by claim type
HHEM-2.1 (Vectara)fine-tuned T5AggreFact0.78sentence-levelyesno
Lynx-70BLlama-3 fine-tuneHaluBench0.874noyesno
LettuceDetect-LModernBERT tokensRAGTruth0.792 / 0.589*span-levelyesno
MiniCheck-FT5770M encoderLLM-AggreFact0.774noyesno
FAVAtrained editorFAVABench0.594 / 0.366*span-levelyesno
ClaimRoute (ours)type router + specialistsRAGTruth-Enhance0.507per-claim XAI audityesyes

* Example-level / span-level split: reports the granularity wall from the review's F2 finding. ClaimRoute's F1 is lower in absolute terms than fine-tuned systems; the differentiator is per-claim XAI attribution and routing-by-type, both of which no other system reports.

Cost & Performance

Runs on free-tier GPU with sub-second per-claim verification

Measured on the Kaggle 2× T4 kernel (claimroute-full-eval-v2, run 2026-11-11) over 1,600 samples.

Mean latency per sample
4.2s
includes claim extraction + verification + aggregation
Claims verified per second
2.1/s
dual-GPU DataParallel on the NLI batch
Cost per 1,000 samples
$0.00
Groq free tier + Kaggle 30 h GPU/week
Peak GPU memory
0.9 GB
DeBERTa-v3-large, batch size 1 / chunk
Deploy & Integrate

Drop-in integration with the RAG eval stack

ClaimRoute is designed to plug into existing evaluation workflows, not replace them. Planned integrations ship Dec 2026.

Install and run

# Clone and verify a sample git clone https://github.com/parshvi1508/ClaimRoute.git cd ClaimRoute && pip install -e . from claimroute.pipeline import ClaimRoutePipeline pipeline = ClaimRoutePipeline() result = await pipeline.averify(sample) print(result.summary.p_hallucinated_noisy_or) 0.31 # sample-level P(hallucinated) # Inspect the per-claim audit trail for claim in result.claims: print(claim.verifier_used, claim.status.value)

RAGAS custom metric (coming Dec)

# Wrap ClaimRoute as a RAGAS metric from ragas import evaluate from claimroute.integrations.ragas import ( ClaimRouteFaithfulness ) metric = ClaimRouteFaithfulness() scores = evaluate(dataset, metrics=[metric]) # Every row carries a routing_audit column # with per-claim attribution for XAI. scores["routing_audit"][0]
Team & Stack

Built by two researchers with a supervisor and an opinionated stack

Small team, open tooling, reproducible pipeline.

PJ

Parshvi Jain

Lead researcher | Systems + evaluation
github.com/parshvi1508
YS

Yashvi Singhal

Co-author | Review paper, IAA coding
yashvisinghal2005@gmail.com
SJ

Sapna Jain

Supervisor | ABES Engineering College
sapnajain115@gmail.com

Stack

Python 3.13 PyTorch 2.11 HuggingFace Transformers DeBERTa-v3-large-mnli Llama-3.3-70B via Groq Qwen3-32B extractor Weights & Biases Pydantic Kaggle 2× T4 GPU FastAPI (planned) RAGAS integration (Dec)
Roadmap

Where we're taking this

Sep – Oct 2026
Architecture code-complete, 30-paper review drafted
Four layers L1 – L4 shipped. Systematic protocol applied.
Nov 11, 2026
First real A/B/C evaluation × 2 corpora
1,600 paired decisions. Bootstrap CI and McNemar computed.
Nov 16, 2026
Leakage finding published
402 / 816 RAGTruth++ messages byte-identical to Enhance.
Nov – Dec 2026
Review paper submission + RAGAS wrapper + failure fixes
Target venue: Natural Language Engineering. Ship RAGAS custom metric. Close failures 1 – 3.
Jan 2027
L2 learned router + full 2,675-sample Enhance run
Train the confidence gate on the precision/recall trade quantified above. Close the significance gap on A vs B.
Feb 2027
System paper submission
Add FinQA as a truly independent R3 corpus. Target: ACL / EMNLP Findings.
L3 calibration, measured

Platt scaling cuts ECE by 87% on the routed pipeline

Sample-level Platt (sigmoid logistic) fit on the raw Noisy-OR probabilities against gold hallucination labels. 10-bin equal-width Expected Calibration Error before and after calibration. Numbers are from the 2026-11-24 analysis script, not estimates.

Reliability diagram, A routed on Enhance

VariantnECE rawECE PlattReduction
A routed12000.15210.019287.4%
B NLI only12000.16290.019488.1%
C det only12000.35700.063582.2%

Platt does not change ranking so F1 and AUPRC are unchanged. The ECE reduction says the raw system had a systematic probability bias that L3 corrects. C det only had an ECE of 0.36 because it flagged almost nothing (recall 0.07), so its default low-probability region was systematically under-confident about the few true hallucinations it did predict.

Per-task McNemar on RAGTruth-Enhance

Break the overall A vs B p=0.39 down by task. No task shows a significant routing contribution at this n. A vs C stays highly significant everywhere, confirming NLI fallback carries the system.

Taskn A vs B netA vs B pverdict A vs C netA vs C pverdict
QA367+50.3323not significant+240.021p < 0.05
Data2txt441+30.6476not significant+112<1e-20highly sig
Summary392-11.0000B barely wins+170.006highly sig
Paired significance tool

Run McNemar on your own paired system comparisons

Paste one row per sample, three space- or tab-separated binary values (gold model_A model_B, 0 or 1 each). Get the 2x2 contingency table, net advantage, and the exact two-sided binomial p. Pure client-side, stdlib math.

Format: y_true y_pred_A y_pred_B per line. Example shows 10 rows where A agrees with gold more often than B.

Hit Compute McNemar to see the paired contingency table and the exact two-sided p-value.
Live from the repository

Real activity, real commits, real audit rows

Snapshot of the repository at publish time. The badges, commits, and audit rows below come from the actual repository state, not boilerplate.

license Apache-2.0 python 3.13 PRs welcome kaggle complete samples 1,600 review 30 papers

Sample rows from the Gate 1 routing audit (real data)

From enhance_A.jsonl on Kaggle kernel claimroute-full-eval-v2, 1,200 samples run 2026-11-11. The pipeline tagged each with task type, claim count, verdict breakdown, noisy-OR probability, and gold label.

sample_id task n_claims contra entail NIC P(hall) gold pred match
View as CSV (copy and paste into a spreadsheet)