Open, reproducible measurement of prose style, for editors, researchers, and anyone who wants to check what AI detectors are actually measuring.
In a 2023 Stanford study, seven AI detectors flagged on average 61% of essays by non-native English writers as AI-generated. This repo reproduces that result, measures open detectors the same way, and shows why it happens.
Paste a text or upload a file (PDF, Word, OpenDocument, PowerPoint, Excel, CSV, HTML, RTF or plain text). Three open detectors score it, each signal is placed among real human and GPT essays, and a word-by-word heatmap shows what looks "predictable". Everything, including reading uploaded files, runs locally in your browser with transformers.js, so your text never leaves your device. Source: web/.
Commercial AI detectors return one opaque percentage. aicl returns the measurements underneath (sentence-length variation, lexical diversity, repetition, stock-phrase density, perplexity, GLTR rank profiles, Binoculars scores), each with a written definition, a citation, and its known limits.
$ aicl analyze examples/draft.md --compare examples/edited.md
Metric draft.md edited.md Change %
------------------------ -------- --------- ------- -------
Words 198 207 +9 +4.5%
Sentence length, CV 0.320 0.510 +0.191 +59.6%
Paragraph length, CV 0.146 0.332 +0.186 +127.5%
MATTR (w=50) 0.779 0.852 +0.073 +9.3%
MTLD 69.8 112.8 +43.0 +61.7%
Distinct-2 0.929 0.976 +0.047 +5.0%
Stock phrases / 1k words 106.06 0.00 -106.06 -100.0%
...
Sentence-length CV 95% CI (draft.md): 0.221-0.392
Sentence-length CV 95% CI (edited.md): 0.289-0.670Note the overlapping confidence intervals: with 17 sentences, a 60% jump in sentence-length CV is not conclusive. aicl shows the uncertainty instead of hiding it.
pip install ai-content-lab # core: pure Python, no dependencies
pip install "ai-content-lab[lm]" # + perplexity, GLTR, Binoculars (torch, transformers)From source:
git clone https://github.com/ahafarag/aicl && cd aicl
pip install -e ".[dev,lm]" && pytestaicl analyze essay.md # summary table
aicl analyze draft.md --compare final.md # before/after with deltas
aicl analyze essay.md --json # everything, machine-readable
aicl analyze essay.md --lm # + perplexity and surprisal under gpt2
aicl analyze essay.md --lm --model gpt2-medium --tokens --json # per-token surprisal
aicl analyze essay.md --binoculars # + Binoculars score (uncalibrated)
cat essay.txt | aicl analyze - # stdinFrom Python:
from aicl import analyze
r = analyze(open("essay.md").read())
r["sentence_length"]["cv"], r["lexical"]["mtld"], r["stock_phrases"]["per_1k_words"]| Group | Measures | Needs |
|---|---|---|
| Structure | sentence / paragraph / section length: mean, SD, CV, percentiles, bootstrap CI | core |
| Lexical | TTR, MATTR, MTLD | core |
| Repetition | distinct-2/3, sentence-opener diversity, top repeated trigrams | core |
| Style | stock-phrase density by category, punctuation rates | core |
| Predictability | perplexity, surprisal distribution, entropy, GLTR rank buckets | [lm] |
| Zero-shot detector | Binoculars score (observer/performer pair of your choice) | [lm] |
Full definitions, formulas, and caveats: docs/measurement_model.md.
aicl bench measures how often AI-text detectors flag human writing, broken down by who wrote it. Every detector is calibrated the same way and reported with confidence intervals.
aicl bench liang # Liang et al. (2023) essays + recorded 2023 commercial detector scores
aicl bench raid --attacks paraphrase,synonym # stratified RAID sample, per-model and per-attack rows
aicl bench my_data.jsonl # your own labelled dataFull report · protocol · 746 texts, 12 detectors
- At their own 0.5 cut-off, the 2023 commercial detectors flagged 48–76% of human-written TOEFL essays as AI, compared with 0–12% of US 8th-grade essays. The mean across the seven is 61.2%, which reproduces the paper's figure.
- Calibration narrows the gap but doesn't close it. With every detector tuned to flag at most 5% of a held-out pool of human writing, TOEFL essays were still flagged at 11–35% by every detector except the stock-phrase heuristic (0%), against 0–6% for the US essay groups. The most-flagged were GPTZero (35%), Originality.ai (33%) and GLTR (30%).
- One prompt defeats almost everything. GPT-3.5 college essays generated with "use literary language" were detected 0–10% of the time by every model-based detector. The only exception was the crude stock-phrase heuristic (58%), because that prompt produces exactly the vocabulary it counts.
- The best separator was the simplest one. Low sentence-length variation reached AUROC 0.86 (0.82–0.89), ahead of every commercial and model-based detector (0.53–0.73). This reflects 2023-era GPT-3.5 output on short essays, and the RAID results below show it doesn't generalise.
Every group has 31–145 texts, so read the intervals in the report before comparing detectors.
Full report · 984 texts from RAID's abstracts, books and news domains · thresholds calibrated to 5% false positives on held-out human texts
- Rankings flip between datasets. Binoculars was the strongest detector here (AUROC 0.86) but only 5th of 12 on the Liang essays (0.68). Sentence-length variation fell from 0.86 to 0.69, and stock phrases dropped to chance (0.51). A detector's accuracy on one benchmark tells you little about the next.
- Detection depends on which model wrote the text. Binoculars caught 93–97% of GPT-3, ChatGPT and Llama-chat text but only 65% of GPT-4 and 47% of MPT. Over all 11 unattacked generators: Binoculars 77%, perplexity 68%, GLTR 58%.
- Simple edits defeat the simple detectors. Synonym swaps cut perplexity's detection rate from 68% to 29% and GLTR's from 58% to 21%. Paraphrasing and look-alike characters cut perplexity's rate to 39–44%, but not Binoculars' (92–98%). Synonym swaps and whitespace edits brought Binoculars down to 47–56%.
There were only 30 evaluation human texts, so false-positive rates here have wide intervals (up to 0–40%) and aren't a basis for comparison. Use the Liang results for false positives. The Hugging Face Parquet export of RAID covers only part of the dataset, so the books, news and abstracts domains stand in for all eight.
- Descriptive, not a verdict. No number here proves authorship. Detectors misclassify human writing, especially by non-native English writers (Liang et al., 2023).
- Reproducible. Same version, same input, same output. Models, windows, and seeds are reported in every result.
- Honest about uncertainty. Small samples get confidence intervals and warnings, not bigger fonts.
- Built for better writing, not for evading detectors. The editing workflow in SKILL.md improves clarity and specificity and reports the measured change. It does not optimize against detector scores.
- Detector report card on Liang et al. (2023): per-group false-positive rates for open and 2023 commercial detectors.
- Report card on a RAID sample: per-generator and per-attack detection rates.
- Larger RAID human sample, so false-positive rates by domain have useful intervals.
- Stronger open detectors (Binoculars with Falcon-7B, Fast-DetectGPT) on GPU.
- Reference profiles: per-genre distributions so a value can be read as a percentile against human-written text of the same kind.
- In-browser demo with a GLTR-style word heatmap (Hugging Face Space, runs on transformers.js).
- Better sentence segmentation for non-English text.
Contributions are welcome, especially stock-phrase entries backed by a corpus comparison and new measures with a citation.
@software{ai_content_lab,
title = {ai-content-lab: reproducible stylometric measurement for prose},
author = {Abdelrahman},
year = {2026},
url = {https://github.com/ahafarag/aicl}
}MIT