check-hallucinations
A command-line tool to detect hallucinated references in BibTeX files before submitting a paper to arXiv.
An entry whose doi names a record with its title, authors and year is confirmed by that DOI. Otherwise, it looks up each reference (Semantic Scholar, then OpenAlex when Semantic Scholar has no matching title; arXiv; the web page of a @misc), and checks that the paper found is the one the entry describes: same title, same authors, same year, and a DOI that resolves to that title.
Titles are decoded from LaTeX to Unicode before the lookup (Protokolls{\"a}tze is looked up as Protokollsätze), and compared whatever their punctuation and markup: &, #, +, %, ?, :, parentheses, quotes, dashes, LaTeX accents and commands (D\&C, C\#, Bissyand{\'e}, \emph{x}), and venue names or section numbers (I.—Knowing How and Knowing that) that some records prefix to the title. Symbols that change the meaning stay: C, C++ and C# are different titles.
Installation
pip install check-hallucinations
Usage
check-hallucinations references.bib # silent when every entry is confirmed
check-hallucinations --json references.bib # findings as a JSON array, [] when clean
check-hallucinations -v references.bib # also list each confirmed entry with its URL
One line per finding, file:line: rule: key: message:
references.bib:5: authors-mismatch: wrongauthors: first author smith is not an author; the paper is by Ashish Vaswani, Noam Shazeer, N. Parmar, J. Uszkoreit, ...
references.bib:5: year-mismatch: wrongauthors: year 2009, but the paper is from 2017
references.bib:9: doi-mismatch: wrongdoi: doi 10.1038/nature14539 is 'Deep learning'
references.bib:13: not-found: fake: not found in SemanticScholar: A Unified Theory of Self-Healing Compilers for Quantum Blockchains
Exit status: 0 every entry confirmed, 1 findings, 2 the file cannot be read. This makes it usable as a CI step.
Rules
not-found,title-mismatch: no paper with this title (the closest title is given).authors-mismatch: the first author is not an author of the paper found, or fewer than half of the authors are. Last names are compared, LaTeX accents and diacritics removed;and othersis ignored.year-mismatch: the year differs from the paper's by more than two (preprint, online-first and issue years differ, and Semantic Scholar may date a later version). A@bookdated before the record found is not a mismatch: the record is a later edition or reprint.
A title is shared by reviews, reprints and later papers ("The Concept of Mind" is also the title of reviews of Ryle's book). Among the first five Semantic Scholar candidates with the title, the first with the entry's authors and year is taken, else the first with its authors; when that one still differs from the entry, OpenAlex is asked, and its work is taken if it fits better. authors-mismatch and year-mismatch are reported only when no candidate fits.
doi-not-found,doi-mismatch: thedoifield does not exist, or resolves (doi.org, Crossref and DataCite) to another title. A DOI without Crossref or DataCite record (AI Magazine's10.1609/aimag.*) exists when the Handle System resolves it, and its title is OpenAlex's.arxiv-not-found,arxiv-mismatch: an arXiv@miscwhose identifier does not exist or has another title.web-mismatch,web-not-found,no-url: a web@miscwhose page shows another title (in its<title>, or each colon-separated part of the entry's title as a phrase of its headings and text), is gone, or has no URL (theurlfield, orhowpublishedas plain text or\url{}).no-title,unparsed: an entry without title, a block that is not valid BibTeX.unchecked: a lookup failed (network, rate limit). The entry is neither confirmed nor refuted; run again.
misc entries with an arXiv identifier are checked on arXiv, other misc entries on their web page.
API key
By default the tool uses the public Semantic Scholar API (rate-limited). For higher throughput, set the SEMANTICSCHOLAR_API_KEY environment variable (or store it with keyring set check-hallucinations ss_api_key):
export SEMANTICSCHOLAR_API_KEY=your-key-here
check-hallucinations references.bib
Answers are cached in ~/.cache/check-hallucinations.
Library
process_bibtex_file(path) prints the per-entry report of earlier versions (now with author, year and DOI mismatches as extra lines); check_entry(entry) returns the findings of one parsed entry.
Development
uv venv && uv pip install -e '.[dev]'
.venv/bin/pytest && .venv/bin/ruff check . && .venv/bin/mypy check_hallucinations tests scripts
.venv/bin/python scripts/live_check.py [more-real.bib ...] # network: silent when the lookup is right
uv tool install --editable . --force # the command on PATH, in its own environment, running this checkout
A pip install --user of the checkout runs with the system Python's packages, and fails with module 'bibtexparser' has no attribute 'parse_string' where that Python has bibtexparser 1.
The live check runs the lookup on scripts/corpus/real/ (real papers with difficult titles: every entry must be confirmed) and scripts/corpus/invented/ (every entry must be reported). Add a title that the tool gets wrong to the corpus before fixing it.
License
MIT
Metadata
Release files for check-hallucinations 0.23.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| check_hallucinations-0.23.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / check_hallucinations-0.23.0-py3-none-any.whl
| Download URL | check_hallucinations-0.23.0-py3-none-any.whl |
|---|---|
| Size | 17.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f92e4648ba3c9765e75e40ab7e689c6d1efebdee3f81042fd9c07a6244babaa
|
|
BLAKE2b-256 checksum How to use checksums |
3d7cbafd37f7e9531d22dc80ff6078f7431eb77b94f1036efa7017414f92c622
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logSecurity for check-hallucinations 0.23.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 1 file in this release has been uploaded with provenance metadata.
Attestation for check_hallucinations-0.23.0-py3-none-any.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.