AIToday
Ahead of AI (Sebastian Raschka)Published: Aug 15, 2026, 22:00 JST4 min read

How to Build an AI Text Detector: A DIY Project

How to Build an AI Text Detector: A DIY Project

Key takeaway

  • A new tutorial shows how to build a working AI text detector by fine-tuning a DistilBERT classifier, inspired by Substack's recent launch of its own built-in detector.

  • Beyond filtering spam, such detectors can help writers refine their own work—fixing grammar and readability—while ensuring it does not sound AI-generated.

  • The project illustrates both how AI detectors function and how to use a scorer or verifier with language models, though the author notes that detection is inherently a moving target as new models evolve to evade existing patterns.

3 Key Points

  1. What happened

    A tutorial explains how to build an AI text detector from scratch, inspired by Substack's recently launched AI detector feature in its UI. The project involves fine-tuning a DistilBERT classifier to return a 0–100 score indicating how likely a text is AI-generated.

  2. Why it matters

    AI detectors have practical uses beyond flagging spam—they can help writers improve grammar and clarity without inadvertently making their own writing sound AI-generated and triggering detection. The tutorial also demonstrates how to build a verifier-based LLM application, a broader technique beyond reasoning models trained on math and code.

  3. What to watch

    The tutorial acknowledges a fundamental limitation: AI detection is a cat-and-mouse game. As LLMs evolve to avoid detection patterns, detectors must be updated in turn. False positives (human text flagged as AI) are also likely to occur.

In Depth

Read the full story

Substack's launch of a built-in AI detector feature in its user interface inspired this tutorial project. The author, noticing concurrent interest in small language model (SLM) demonstrations, decided to combine the two themes by building a simple AI text detector from scratch. The primary educational goal is twofold: to explain how AI detectors work in practice, and to use the detector as a verifier for training a small language model to produce text that evades detection. This second objective highlights a broader application—using a scorer or verifier model alongside language models—beyond the more familiar use case of reasoning models trained on mathematics and code.

The tutorial outlines several practical motivations for AI detection. Beyond filtering spam, detectors can serve writers by identifying when AI-assisted editing tools (like grammar checkers or ChatGPT) have inadvertently made their writing sound AI-generated. For instance, a writer who wants to improve the spelling and grammar of a lengthy article might ask a detector to ensure the polished version still scores as human-written. This turns the detector into a collaborative writing aid rather than merely a content-moderation tool.

The technical approach mirrors methods used by Pangram models, which the author believes power Substack's detector. Rather than adopting all detection strategies in the literature—which range from supervised classifiers and perturbation-based probability tests to perplexity measures and watermarking—the tutorial focuses on a single, straightforward approach: fine-tuning a DistilBERT classifier to output a 0–100 score. This score represents the classifier's estimated probability that a given text is AI-generated, based on its training distribution. The tutorial will deliver not only a functional API that can be called by humans and automated agents, but also a browser-based user interface that displays a whole-text score and highlights scores for individual text chunks.

The author acknowledges a critical limitation: AI detection is fundamentally a cat-and-mouse game. Once a detector learns to flag a particular pattern associated with AI-generated text, the next LLM may incidentally or deliberately evolve to avoid that pattern, rendering the detector obsolete until it is retrained. False positives—human-written text incorrectly flagged as AI—are also likely to occur. These inherent limitations mean that no detector can be a permanent solution, only a snapshot in an ongoing competition between generation and detection.

Context & Analysis

Substack's recent launch of a built-in AI detector feature triggered interest in understanding how such detectors work. The tutorial responds to this interest by offering a hands-on educational project that breaks down the mechanics of detection and applies them in a real-world context. The author references earlier work on AI-text detection approaches—supervised classifiers, perturbation-based probability tests, perplexity measures, and watermarking—and positions the DistilBERT classifier as a practical middle ground, similar to the method behind Substack's own feature (which the author understands to be based on Pangram models).

The project frames AI detection not merely as a content-moderation tool but as a utility for writers themselves. This reframes the detector as a collaborative rather than adversarial tool: writers using grammar-checking or AI-assisted editing can query the detector to ensure their personal voice is preserved. This dual-use perspective reflects a real tension in the writing workflow—the temptation to over-polish text with AI can inadvertently make human writing sound machine-generated.

The author is transparent about the fundamental fragility of the approach: detection will always lag behind generative capability. As LLMs evolve, intentionally or incidentally, to avoid detection patterns, the detector becomes outdated and must be retrained. Combined with the risk of false positives, this suggests that no AI detector can be a foolproof solution—only a tool in an ongoing arms race.

FAQ

What model does the tutorial use to build the detector?
The project fine-tunes a DistilBERT classifier to return a 0–100 probability score indicating how likely a text is AI-generated.
What is one practical use for an AI detector besides catching spam?
Writers can use an AI detector to improve their own writing—for example, to fix grammar and readability with a tool like ChatGPT while ensuring the text does not score high as AI-generated and trigger detection.
What is the main limitation of AI detectors mentioned in the article?
AI detection is a cat-and-mouse game: as AI detectors learn to flag certain patterns, the next LLM may avoid those patterns, forcing the detector to be updated, and the cycle repeats. False positives (human text flagged as AI) are also likely.
Ahead of AI (Sebastian Raschka)Read Original Article

Get AI news like this every morning

AI-summarized, only the topics you pick — one digest a day via Email, Slack, or Discord.

Free · takes 30 seconds · unsubscribe anytime

Ask AI

Ask AI anything about this article. Q&As are published on this page for other readers too.

Next articleAI-generated books flood Amazon, cutting sales for human authors

The AI news that matters, in one minute each morning.

Sign up free