feat: add CitationConsistencyChecker — deterministic, zero-token RAG citation validator - #12142
Conversation
…ator Addresses deepset-ai#10973 (proposed by @DYNOSuprovo): a runtime, zero-token guardrail that verifies quote-style citations appear verbatim in the retrieved Document they cite. Routes each citation to consistent/inconsistent, catching fabricated quotes, frankenquotes, and misattributed quotes without a model — so it does not degrade on long contexts and needs no external API. Complements an LLM-based groundedness check (e.g. deepset-ai#11031) as a cheap deterministic first stage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@antondziatkovskii is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @Palo-Alto-AI-Research-Lab, thanks a lot for your contribution! 🙏 We noticed that the Contributor License Agreement (CLA) check ( To get your PR reviewed, please sign the CLA via the link in the |
|
Thanks for signing the CLA, @Palo-Alto-AI-Research-Lab! 🎉 This PR is now ready for review again and the reviewer has been re-assigned. |
|
Thank you for taking the time to contribute to Haystack. After reviewing the PR, my impression is that the new dataclass + component do not provide enough additional value to justify the future maintenance effort, so I am closing this PR. If you'd like to contribute to Haystack, Contributions wanted issues are a good place to find ideas that are currently a priority for the project. |
Addresses #10973, proposed by @DYNOSuprovo, who asked for a runtime groundedness/verification guardrail that runs locally without external API calls.
What this adds
A new
CitationConsistencyCheckervalidator (haystack.components.validators) plus a smallCitationdataclass. It sits after a Generator that produces answers with explicit quote-style citations and, using no model and no tokens, checks that each quoted passage appears verbatim in the retrievedDocumentit is attributed to. Each citation is routed to aconsistentorinconsistentoutput with itsstatusfilled in.It catches the three failure modes an LLM judge is worst at, precisely because they read as fluent and supportive:
Why deterministic, and why complementary rather than competing
@DYNOSuprovo raised the "lost-in-the-middle" degradation on the LLM-based approach in #11031 (checking claims against entire document payloads). Because this component is pure normalized-substring matching, it does not read a long context and cannot be sweet-talked by a persuasive citation — it does not degrade with context length and needs no external API, which is exactly the local-verification property that was requested. It is intended as a cheap first stage in front of an LLM groundedness checker (such as #11031), not a replacement: the deterministic gate rejects the impossible-to-support quotes for free, so only genuinely ambiguous "does this real quote support the claim?" cases need a model.
API
An optional
treat_misattributed_as_consistentflag controls whether a quote found in the wrong retrieved document is tolerated (default: no).Tests & tooling
to_dict/from_dict/ pipeline serialization roundtrip. All green.ruff checkandruff formatclean; lazy import wired invalidators/__init__.py; release note added.Note on provenance
The standalone, framework-agnostic version of this gate — plus an optional burden-of-proof LLM judge for the ambiguous sufficiency case — is maintained here: https://github.com/Palo-Alto-AI-Research-Lab/verbatim-citation-gate . This PR inlines only the deterministic gate so the component keeps Haystack’s zero-extra-dependency contract.