cheatcheck
Can your dataset be solved without reading it?
In 2018, researchers found that a model could get far above chance on the famous SNLI benchmark without ever reading the premise. Annotators had left patterns behind: write "nobody" or "not" and the answer is usually contradiction; add a purpose ("cooking for his friends") and it is usually neutral. Models learned the patterns instead of the task, and the leaderboard looked better than the models were.
The same thing happens in sentiment, hate-speech, fake-news and question-answering datasets, including the ones
students build for a thesis. cheatcheck finds it in one line, before you train anything:
import cheatcheck as cc
report = cc.scan(df, text=["premise", "hypothesis"], label="label")
print(report)
It answers two questions, with proper statistics:
- Shortcuts: can a deliberately dumb model beat guessing using only part of the input (just the hypothesis, just the length, just the first three words)?
- Giveaway words: which words point to one label far more often than chance allows?
Install
pip install cheatcheck # pandas, numpy, scipy
pip install "cheatcheck[plot]" # adds matplotlib for report.plot()
Real data: a public SNLI sample
examples/snli_sample.py scans a public 1,000-pair sample of SNLI:
cheatcheck: 1,000 examples, 3 labels, 2 text fields (premise, hypothesis)
labels: contradiction 31.1%, entailment 36.7%, neutral 32.2%
Shortcuts (5-fold cross-validated naive Bayes, 95% CI):
[OK] premise alone: 36.0% (33.1% to 39.0%), no real gain over guessing
[SHORTCUT] hypothesis alone: 52.2% (49.1% to 55.3%), +15.5 points over guessing (as good as using every field)
[OK] length alone: 40.3% (37.3% to 43.4%), no real gain over guessing
[OK] first three words alone: 40.7% (37.7% to 43.8%), no real gain over guessing
all fields, bag of words (reference): 43.6% (40.6% to 46.7%)
guessing the most common label: 36.7%
Giveaway words (false discovery rate 0.01, at least 1.5x the base rate, seen in at least 10 examples):
[GIVEAWAY] hypothesis 'to': 80 examples, 60% neutral (base rate 32%)
[GIVEAWAY] hypothesis 'for': 38 examples, 68% neutral (base rate 32%)
Verdict: a model can score 52.2% on this data using only the hypothesis (guessing gives 36.7%). Check that your model is not just learning this shortcut.
Even on 1,000 pairs, a word-counting model that never sees the premise is 15.5 points better than guessing, and the purpose words "to" and "for" give away neutral, which reproduces the published finding. See the rows behind any word:
report.examples("for", field="hypothesis", label="neutral")
# A man is cooking for his friends .
# Two teams playing soccer , practicing for the Olympics .
Try it without data
df = cc.make_example() # synthetic NLI pairs with planted shortcuts
print(cc.scan(df, text=["premise", "hypothesis"]))
[OK] premise alone: 33.4% (31.7% to 35.1%), no real gain over guessing
[SHORTCUT] hypothesis alone: 60.8% (59.0% to 62.5%), +26.0 points over guessing (as good as using every field)
[SHORTCUT] length alone: 51.6% (49.8% to 53.4%), +16.9 points over guessing (69% of the gain from using every field)
...
[GIVEAWAY] hypothesis 'because they are bored': 156 examples, 90% neutral (base rate 33%)
[GIVEAWAY] hypothesis 'nobody': 178 examples, 87% contradiction (base rate 35%)
Words that always occur together are merged into one phrase, in reading order. report.plot() draws the
giveaway map: every word, how often it appears, and how strongly it points to one label.
What it checks
| Check | How | Flagged when |
|---|---|---|
| Each text field alone (premise only, hypothesis only, question only, ...) | naive Bayes on words, 5-fold cross-validation | beats guessing the most common label by 3+ points, Holm-adjusted p ≤ 0.01 |
| Length alone | naive Bayes on length bins (bins learned on training folds only) | same |
| First three words alone | naive Bayes on the opening words | same |
| Giveaway words | exact binomial test of each word against the label's base rate (Gardner et al., 2021) | Benjamini-Hochberg false discovery rate ≤ 0.01 and at least 1.5x the base rate |
| All fields together | the same model on everything | reference line only, not tested |
Every accuracy comes with a 95% Wilson interval. All thresholds are arguments of scan().
No false alarms on clean data. On 100 datasets whose labels were shuffled at random (so nothing can predict
them), cheatcheck flagged no giveaway word and no shortcut in any of them
(benchmarks/false_alarms.py).
Works in your language
Most quick scripts split text with re.findall(r"\w+", text), which breaks words in Nepali, Hindi, Bengali,
Tamil, Thai and many other scripts, because vowel signs are not \w:
>>> re.findall(r"\w+", "मलाई नेपाली मन पर्छ।")
['मल', 'ई', 'न', 'प', 'ल', 'मन', 'पर', 'छ']
>>> cc.tokenize("मलाई नेपाली मन पर्छ।")
['मलाई', 'नेपाली', 'मन', 'पर्छ', '।']
cheatcheck keeps combining marks inside words, keeps contractions together ("don't", "n't") and treats
punctuation and emoji as tokens, because "!" can be a giveaway too. You can pass your own tokenizer=.
Command line
cheatcheck train.csv --text premise hypothesis --label label --plot map.png --csv giveaways.csv
Reads CSV, TSV, JSON, JSONL and Parquet. The exit code is 1 when a shortcut is found, so it can guard a data pipeline in CI.
Using the results
report.baselines # one row per check: accuracy, 95% CI, macro-F1, p-values, shortcut flag
report.words # flagged giveaway words with counts, label share, z, p and q values
report.all_words # every tested word, for your own analysis
report.examples("nobody", field="hypothesis", label="contradiction")
report.plot()
scan() accepts a pandas DataFrame, a dict of lists, or anything with .to_pandas(), such as a Hugging Face
Dataset. Use drop_labels=[-1] for SNLI-style unlabelled rows and ngram_range=(1, 2) to test two-word phrases.
What a clean result does and does not mean
A flagged shortcut is strong evidence that a model can cheat; it does not prove that your model does. A clean
result does not prove the dataset is free of artifacts: a word-counting model cannot see patterns that only exist
in the combination of fields, or in word order (Feng et al., 2019). Treat
cheatcheck as a smoke alarm, not a certificate.
Background
- Gururangan et al. (2018), Annotation Artifacts in Natural Language Inference Data. NAACL.
- Poliak et al. (2018), Hypothesis Only Baselines in Natural Language Inference. *SEM.
- Gardner et al. (2021), Competency Problems: On Finding and Removing Artifacts in Language Data. EMNLP.
- Bowman et al. (2015), A large annotated corpus for learning natural language inference. EMNLP.
Related tools
From the same "statistics that lie" toolkit: nacheck (hidden missing values), simpsonscan (Simpson's paradox), chartaudit (misleading charts), pandas-mergeguard (bad merges) and gapnet (group gaps in neural networks).
License
MIT
Metadata
Release files for cheatcheck 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cheatcheck-0.1.0.tar.gz | 33.7 kB | With provenance | Details for cheatcheck-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cheatcheck-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for cheatcheck-0.1.0-py3-none-any.whl |
Total release size: 53.6 kB
Release files / cheatcheck-0.1.0.tar.gz
| Download URL | cheatcheck-0.1.0.tar.gz |
|---|---|
| Size | 33.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dfcf18efbef61d820e59b12d98edde86d55770fa634b373707723ef3dbc07c37
|
|
BLAKE2b-256 checksum How to use checksums |
cbca56e6cb7e14d48f96be6ea83b61c531ed50e925a88f9a7cd45bd770e9f221
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Dec 3, 2026.
Transparency logRelease files / cheatcheck-0.1.0-py3-none-any.whl
| Download URL | cheatcheck-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c2504dd064b39106b5a3347769b003c15dfbacbd6bb3b56e9ba93ae268faaa9e
|
|
BLAKE2b-256 checksum How to use checksums |
ba615b1cb84685c354a06eefa8c959a1632ccaf95514d0add565da72dbe384f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Dec 3, 2026.
Transparency logSecurity for cheatcheck 0.1.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
Both files in this release have been uploaded with provenance metadata.
Attestation for cheatcheck-0.1.0.tar.gz
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 Dec 3, 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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.