Identity
| Name | THE DETECT LAW v8.1, package detect-law 0.3.0 |
|---|---|
| Type | Zero-shot, metric-based. No classifier is trained on AI text. |
| Decision rule | Integer-only (int32) sequential statistical test, written in C |
| Language | English (RAID is English-only) |
| Licence | Code: all rights reserved. Paper: CC BY-NC-ND 4.0, doi:10.5281/zenodo.23257822 |
Models
| Role | Careful mode (default) | Official mode (RAID submission) |
|---|---|---|
| A · base model | Llama-3.2-1B | Llama-3.2-1B |
| B · instruct model | Llama-3.2-1B-Instruct, 4-bit | Llama-3.2-1B-Instruct, full precision |
| Memory | About 3 GB | About 5 GB |
Both modes flagged the same 0.22% of held-out human texts; official mode catches slightly more AI text.
How a text is checked
- Normalise. Unicode NFKC, remove invisible format characters (zero-width spaces, soft hyphens), map Cyrillic and Greek look-alike letters to Latin, collapse spacing.
- Clean (app only). Skip headings, table fragments and equation lead-ins, and everything from a References heading on. PDFs are reflowed into paragraphs first.
- Window. Split into 200-token windows, each scored from a fresh start-of-text token; a final window under 100 tokens joins the one before. The RAID run read the first 1,024 tokens of each text.
- Measure every token, with one forward pass of each model:
- Surprise: how predictable the token is under model A, against that position's own expected value.
- Contrast: how much more the instruct model B prefers the token than the base model A does, against the expected gap.
- Repetition: whether tokens repeat within the window, against how much probability A already gives tokens it has seen.
- Decide. An integer sequential test over the three signals stops early when the evidence is decisive, or finishes with an end-of-text test. Its human baseline allows for differences between texts. Every constant comes from 3,200 human RAID training texts (400 per domain). The rule keeps 24 int32 words of state and uses no floating point.
Output
| Verdict | AI evidence, No evidence of AI, or Undecided |
|---|---|
| Evidence | A z-score for each signal: surprise, contrast, repetition |
| Score | law_score = Σ max(z, 0)² × 256, an integer. Benchmark scale: √(law_score ÷ 256) |
| Also returned | Tokens read vs tokens in the text, whether it stopped early, time taken |
Accuracy on RAID
| Official evaluation, 672,000 texts | 5% FPR | 1% FPR | AUROC |
|---|---|---|---|
| All texts, including 11 attacks | 88.99% | 81.37% | 96.48 |
| No attacks | 92.33% | 86.54% | 97.61 |
| By AI model | 99.6–100% on Llama 2 chat, ChatGPT and Mistral chat; 82–88% on base models with random sampling |
|---|---|
| By kind of writing | 89.4% (poetry) to 95.0% (books) |
| Under attack | No loss from look-alike letters, zero-width characters or extra spacing. Hardest: paraphrasing (76.6%) and synonym swaps (80.8%). |
| Human texts flagged | 0.22% of 3,200 held-out texts; worst kind of writing poetry 1.25%; none of the texts over 600 tokens |
| Standing | Top zero-shot detector on RAID; 27th of 44 overall. Trained commercial detectors score higher. |
AI text caught at a fixed false-positive rate (FPR) on human text. Official results from RAID's evaluation service, 8 October 2026.
Speed and cost
| Hardware | Tokens per second |
|---|---|
| A40 GPU (the full RAID test set in about 4.3 hours) | about 12,800 |
| Kaggle T4 GPU | about 1,000 |
| Mac M4 Pro (MLX) | about 750–900 |
| 4-core CPU | about 430 |
One forward pass of each 1B model per token, with no perturbations or sampling. About $0.01–0.03 per million words on rented GPUs.
Interfaces
| Web app | Runs locally on port 8765. Paste text, or drop .txt, .md, .docx or .pdf files, several at once. |
|---|---|
| Command line | detect-law file1.pdf file2.docx … |
| HTTP API | /v1/detect (text), /v1/detect-file (file bytes), /v1/health, /v1/info |
| MCP server | Tools check_text, check_file, about_detect_law for Claude |
| Limits | 300,000 characters per text, 20 MB per file. Text never leaves the computer. |
Known limits
- Texts under about 120 words are often Undecided.
- Paraphrased text and base models with plain random sampling are the hardest cases.
- RAID's AI models date from 2023. Short texts from current frontier models are harder to catch.
- Scanned PDFs (page images only) contain no text to read.
- The constants were set on RAID's human training texts.
- Not yet tested on non-native English writers.
A verdict is statistical evidence, not proof. Send AI verdicts to a person for review, never to automatic penalties.