{"slug": "catching-silent-ai-citation-hallucinations-with-zero-dependency-deterministic", "title": "Catching Silent AI Citation Hallucinations With Zero-Dependency Deterministic Verification", "summary": "A developer released claimcite v0.7.1, a zero-dependency Python 3.10+ tool that deterministically verifies AI-generated citations by checking DOIs against the doi.org handle API and resolving metadata across PubMed, Crossref, OpenAlex and arXiv. In recorded offline benchmarks the tool flagged a real DOI paired with a fabricated title as a hard error, downgraded a year-only mismatch to a warning with a ±1 tolerance, and confirmed nonexistent identifiers only when authoritative registries reported them missing.", "body_md": "The most dangerous hallucinations in AI-written research notes, health summaries, and technical drafts rarely look obviously wrong. They look impeccably formatted, carry clickable links that return HTTP 200, and read like legitimate scholarship.\n\nA plain link checker misses them — the DOI resolves just fine, except it belongs to an unrelated paper from a decade earlier. Asking a second LLM to \"audit the citations\" fails just as quietly: another model still cannot inspect live registry metadata, retraction records, or exact byte offsets, and it happily hallucinates false alarms on niche real papers.\n\nThis post walks through how **[`claimcite`](https://github.com/wasabihu/claimcite)** (` v0.7.1`, pure Python 3.10+ stdlib, zero third-party runtime dependencies) tackles citation verification deterministically:\n\n`26/26`` 0` false errors`192``<1s`` sessfork` → `XERJ + kbwall` → `claimcite`) by verifying host-free `xerj://` UTF-8 byte spans offline without ever caching private documents to disk;`Not tested ≠ clean`)\nEvery CLI snippet, benchmark metric, and `xerj://` verification output below comes directly from running `benchmarks/run.py`, recorded real responses in `tests/fixtures/`, and a local loopback XERJ check — zero fabricated outputs. Offline reproduction steps are at the end.\n\nAcross real drafts, AI-generated references consistently fail in four quiet ways that slip past skimming eyes. Each output below is produced directly by `claimcite` replaying real recorded registry responses (`53` recorded payloads in `tests/fixtures/`).\n\nLLMs routinely emit a valid, high-citation DOI and bolt it onto a fabricated or misremembered title and year. In `examples/sample.md` (line 7), a claim about green tea halving stroke risk cites `doi:10.1016/s0140-6736(10)61388-8` as a 2021 *Stroke* cohort — when that real DOI actually resolves to a 2011 *Lancet* paper on the global burden of second-hand smoke. Any HTTP-200 link checker passes it silently.\n\nIn the recorded offline benchmark (`err_title_mismatch_doi`), pairing real DOI `10.1007/s10654-019-00524-3` with `Tanaka H (2019). Deep Residual Learning for Image Recognition. Stroke.` triggers a hard title-mismatch error:\n\n```\n- **Error** · line 1 · `doi:10.1007/s10654-019-00524-3`\n  - Coffee consumption and all-cause and cause-specific mortality: a meta-analysis by potential modifiers. (2019)\n  - Study type (as tagged by PubMed): Systematic review / meta-analysis\n  - Title does not match this identifier. Registry title: \"Coffee consumption and all-cause and cause-specific mortality: a meta-analysis by potential modifiers.\"\n```\n\nNotice the restraint when *only* the year is wrong: in `warn_year_mismatch` (`pmid:30221596`, citing the 2018 ASPREE aspirin trial as `2024`), the title matches, so `claimcite` emits a **Warning** rather than a hard CI-breaking **Error** (and grants a `±1` year tolerance for online-first vs. print publication):\n\n```\n- **Warning** · line 1 · `pmid:30221596`\n  - Effect of Aspirin on Disability-free Survival in the Healthy Elderly. (2018)\n  - Study type (as tagged by PubMed): Randomized controlled trial\n  - Year differs: document 2024, registry 2018\n```\n\nModels synthesize syntactically spotless fake identifiers — `doi:10.1001/jama.2022.99999`, `doi:10.9999/does-not-exist-claimcite`, `PMID: 99999999`, or `arXiv:9912.99999`.\n\n`claimcite` checks DOIs against the registrar-agnostic `doi.org/api/handles/` API first, then resolves metadata across PubMed, Crossref, OpenAlex, and the arXiv Atom API (including DataCite `10.48550/arXiv.*` DOIs). It emits an **Error** *only* when the authoritative registry definitively reports the identifier does not exist:\n\n```\n- **Error** · line 1 · `doi:10.9999/does-not-exist-claimcite`\n  - Identifier does not exist\n```\n\nEven more common are hallucinated citations with *no identifier at all*. `claimcite` parses APA, Harvard, MLA, Vancouver, and GB/T 7714 bibliography entries and searches Crossref followed by PubMed by title: \"\"\n\n`ok_unlinked_title_search`) → resolves the real identifier and runs full title/year/quote verification;`warn_unlinked_invented`) → emits a `not_checked_book`, e.g., Kahneman's Training corpora are packed with famous retracted studies. Checking retractions sounds trivial until you inspect real Crossref JSON payloads: **Crossref puts `update-to` on the *retraction notice*, not on the *retracted paper***. The retracted paper carries `updated-by` and `relation.is-retracted-by` (PubMed tags `Retracted Publication` / `RetractionIn`; OpenAlex exposes `is_retracted`).\n\nOn top of that, publishers frequently prepend `RETRACTED:` to the registered title after retraction. `claimcite` strips `_RETRACTED_PREFIX` before fuzzy title comparison so you see a clean retraction error (complete with the notice DOI) rather than a spurious title-mismatch error:\n\n```\n- **Error** · line 1 · `doi:10.1016/s0140-6736(97)11096-0`\n  - RETRACTED: Ileal-lymphoid-nodular hyperplasia, non-specific colitis, and pervasive developmental disorder in children (1998)\n  - This paper has been retracted (notice: doi:10.1016/s0140-6736(10)60175-4)\n```\n\nCrucially, the paired control case `ok_retraction_notice_doi` verifies that citing the **retraction notice itself** (`doi:10.1016/s0140-6736(10)60175-4`) passes cleanly as **OK**.\n\n`[n]` / Uncited `[^n]` Markers\nIn the sneakiest failure mode, the paper, authors, year, and PMID are 100% real — only the quoted words inside quotation marks were invented or exaggerated by the model.\n\nLine 11 of `examples/sample.md` cites real meta-analysis `pmid:33237064` (*Food & Function*, 2020), then fabricates the quote `\"calcium and vitamin D supplementation cured osteoporosis in all women\"`:\n\n```\n- **Warning** · line 11 · `pmid:33237064`\n  - Effects of combined calcium and vitamin D supplementation on osteoporosis in postmenopausal women: a systematic review and meta-analysis of randomized controlled trials. (2020)\n  - Study type (as tagged by PubMed): Systematic review / meta-analysis\n  - Quoted text not found in the abstract (it may be in the full text): “calcium and vitamin D supplementation cured osteoporosis in all women”\n```\n\nBecause legitimate quotes often live in the paper body rather than the abstract, `claimcite` falls back on demand to **PubMed Central (PMC)** and **Europe PMC** open-access JATS XML full text (stripping `<xref>` footnote tags and nested `<ref-list>` blocks), and falls back to **OpenAlex** (`abstract_inverted_index`) when Crossref lacks an abstract. It also flags dangling body markers (`[2]`) and uncited footnote entries (`[^1]`) as **Error** while ignoring statistical intervals (` 60 [52-68] years`, `[0, 1]`).\n\n`claimcite` specifies `dependencies = []` in `pyproject.toml` (Python 3.10+ stdlib only):\n\n`uvx claimcite mcp`, `pipx install claimcite`, GitHub Actions, `pre-commit`, and stdio MCP run cleanly on Linux, macOS, and Windows with zero native wheel failures.`0.15s`` 192/192``0.8s`` v0.7.1`).` ok` / `warning` / `error` / `not_checked` strictly separates authoritative failures from network errors, paywalls, or bot walls so CI gates never cry wolf.\nIn private RAG pipelines, retrieval often finds the right paragraph and then the LLM silently flips `$42.8M` into `$48.2M` — or drifts a span offset into the middle of a multi-byte UTF-8 character.\n\n`claimcite` shares a strict host-free URI contract with [`kbwall`](https://github.com/wasabihu/kbwall) and [` XERJ`](https://github.com/xerj-org/xerj) (` xerj://<index>/<doc_id>#b=<byte_start>[-<byte_end>][&f=<field>]`, forbidding `host:port` inside documents):\n\n```\n# Citation check\n\n2 ok · 0 warnings · 2 errors · 0 not checked\n\n- **OK** · line 1 · `xerj://fin-filings/q3-2026-memo#b=8-68&f=text`\n  - XERJ span verified (fin-filings/q3-2026-memo, field text)\n- **OK** · line 2 · `xerj://fin-filings/q3-2026-memo#b=69-160&f=text`\n  - XERJ span verified (fin-filings/q3-2026-memo, field text)\n- **Error** · line 3 · `xerj://fin-filings/q3-2026-memo#b=8-68&f=text`\n  - Quoted text not found in XERJ span: “Revenue recognized in Q3 2026 reached $48.2M”\n- **Error** · line 4 · `xerj://fin-filings/q3-2026-memo#b=70-160&f=text`\n  - XERJ span offset is out of range or splits a UTF-8 character (byte range 70-160 starts inside a UTF-8 codepoint)\n```\n\nFive hard security & privacy invariants guard local verification (`src/claimcite/xerj.py` & `mcp.py`, hardened further in `v0.7.1` with [`SECURITY.md`](https://github.com/wasabihu/claimcite/blob/main/SECURITY.md)):\n\n`ProxyHandler({})`) & zero `3xx` redirects`10 MiB` hard cap.`POST /_mget`` XERJ_URL` and optional `CLAIMCITE_ALLOWED_ROOT` (blocking symlink suffix-bypass & outside-root escapes) are read strictly from process environment variables — never exposed as MCP tool arguments.`Not Tested ≠ Clean`)\n\n```\ngit clone https://github.com/wasabihu/claimcite.git\ncd claimcite\nuv run pytest -q                # 192 passed in ~0.8s (v0.7.1)\nuv run python benchmarks/run.py # 26/26 (100.0%), false_errors=0\n```\n\nMCP config (`uvx claimcite mcp` — PyPI & Official MCP Registry `io.github.wasabihu/claimcite`):\n\n```\n{\n  \"mcpServers\": {\n    \"claimcite\": {\n      \"command\": \"uvx\",\n      \"args\": [\"claimcite\", \"mcp\"]\n    }\n  }\n}\n```\n\n`llms.txt`):` XERJ``kbwall`` vericorpus`", "url": "https://wpnews.pro/news/catching-silent-ai-citation-hallucinations-with-zero-dependency-deterministic", "canonical_source": "https://dev.to/wasabi_hu_d2b4b4d9b9f6bda/catching-silent-ai-citation-hallucinations-with-zero-dependency-deterministic-verification-52in", "published_at": "2026-11-30 05:34:32+00:00", "updated_at": "2026-11-30 05:45:59.596272+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-safety", "generative-ai", "ai-agents"], "entities": ["claimcite", "PubMed", "Crossref", "OpenAlex", "arXiv", "doi.org"], "also_reported_by": [], "takeaway": "Verifying citations against live registry metadata (doi.org handles, PubMed, Crossref, OpenAlex, arXiv) catches real-DOI/fake-title mismatches that HTTP-200 link checkers and second-LLM audits miss, while reserving hard errors for definitively nonexistent identifiers and warning on year-only mismatc", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/catching-silent-ai-citation-hallucinations-with-zero-dependency-deterministic", "markdown": "https://wpnews.pro/news/catching-silent-ai-citation-hallucinations-with-zero-dependency-deterministic.md", "text": "https://wpnews.pro/news/catching-silent-ai-citation-hallucinations-with-zero-dependency-deterministic.txt", "jsonld": "https://wpnews.pro/news/catching-silent-ai-citation-hallucinations-with-zero-dependency-deterministic.jsonld"}}