Catch fabricated RAG citations before they reach the user: a zero-token verbatim gate + a burden-of-proof judge, framework-agnostic.
Checks that a quote an AI cites really appears word for word in the source document, before the answer reaches the user.
Who it's for: developers whose chatbot or RAG system (a bot that answers from your documents) shows citations. What you get: a free, instant verdict per quote (found, not found, or quoted from the wrong document), plus an optional second check by a model of your choice.
pip install verbatim-citation-gate.pip install -e . and then python examples/demo.py (the demo fails with ModuleNotFoundError if the package is not installed).Done when: a made-up quote prints not_found and a real quote prints found. No API key or internet is needed for this first check.
Want an AI agent to do it for you? Paste this to Claude Code / Codex / Cursor: "Read the 'For AI agents' section of https://github.com/tonydzi/verbatim-citation-gate and set it up for me."
pip install verbatim-citation-gate (0.3.2 on PyPI, checked 2026-11-16).pip install verbatim-citation-gate
# latest main instead of the release:
pip install "git+https://github.com/tonydzi/verbatim-citation-gate"
# from a clone, with the test extra:
pip install -e ".[test]"
quote_gate(quote, doc_id, docs) where docs is a dict of doc id to full text.llm_call=<function(system, user) -> str> to audit_citation(...). Wire it to the human's own model client. See examples/quickstart.py.python -c "from verbatim_citation_gate import quote_gate; d={'a':'Body weight was unchanged in both arms.'}; print(quote_gate('Body weight was unchanged in both arms.','a',d), quote_gate('Dramatic weight loss.','a',d))"
# expected: found not_found
pytest -q # from a clone, after the test extra: 46 passed
Without installing, from a clone: PYTHONPATH=src python examples/demo.py (PowerShell: $env:PYTHONPATH="src"; python examples/demo.py) prints, among other lines, 4 citations audited - 3 rejected for free, 1 reached the model and exits 0. Without PYTHONPATH and without installing it exits 1 with ModuleNotFoundError. Both Verify commands can fail: the one-liner prints something other than found not_found if the gate is broken, and pytest -q reports failures; pytest needs pip install -e ".[test]" first (or PYTHONPATH=src python -m pytest -q tests).
pip uninstall verbatim-citation-gate
found verdict only means the words exist in the document. It does not mean the claim is true.Catch fabricated RAG citations before they reach the user. A two-stage, framework-agnostic auditor for quote-style citations.
The deterministic half is src/verbatim_citation_gate/gate.py: zero dependencies, zero tokens.
The model half is src/verbatim_citation_gate/judge.py, and plugs into whatever LLM your pipeline already speaks.

pip install verbatim-citation-gate
from verbatim_citation_gate import quote_gate
docs = {"veltranib-rct": "... Body weight was unchanged in both arms."}
quote_gate("Body weight was unchanged in both arms.", "veltranib-rct", docs) # 'found'
quote_gate("Veltranib produced dramatic weight loss.", "veltranib-rct", docs) # 'not_found'
That is stage 1, and it is the whole offline half: no key, no network, no tokens.
The run in the animation above is examples/demo.py — python examples/demo.py
reproduces it, model calls counted by the demo itself.
Stage 2 (the judge) needs a model and is one argument away — see Use below.
📖 Docs: https://tonydzi.github.io/verbatim-citation-gate/ — the two stages, the API, the verdicts, and every known limit with its issue.
RAG systems love to cite. The problem is how they fail — a quote that reads as authoritative and word-for-word can still be one of three things, each with its own case in tests/test_gate.py:
test_fabrication_is_not_found),test_frankenquote_is_not_found), ortest_misattributed_real_quote_from_wrong_doc).A judge model, asked "does this quote support this claim?", waves all three through: they read as fluent and supportive. The fix is to ask the cheaper, prior q
quote_gate and span_gate silently reject every citation when docs is a Mapping that is not a dict
https://github.com/tonydzi/verbatim-citation-gate/issues/17
Labels: bug, good first issue, accepted
Add a runnable example wiring the gate into one RAG framework (LlamaIndex, LangChain or Haystack)
https://github.com/tonydzi/verbatim-citation-gate/issues/11
Labels: help wanted, accepted
Publish to PyPI so the one-line install works (maintainer account step)
https://github.com/tonydzi/verbatim-citation-gate/issues/8
Labels: enhancement, help wanted, internal
One-word quotes return "found": agree and add a minimum-evidence rule
https://github.com/tonydzi/verbatim-citation-gate/issues/4
Labels: help wanted, accepted
No CONTRIBUTING document was found. Please check the README and open issues.