Sebastian Raschka builds an AI text detector and a model that avoids it

Sebastian Raschka builds an AI text detector and a model that avoids it

Substack recently added an AI-detector feature to its interface, and that is the starting point for a hands-on tutorial published on Sebastian Raschka's Substack, titled 'Building an AI Text Detector From Scratch: An End-to-End Project With Dataset Construction, Model Training, Local Deployment, and RLVR.' The stated motivation is twofold: readers had been asking for interesting, do-it-yourself local LLM projects that show what small language models (SLMs) can do, and the tutorial sets out to explain how AI detectors work by building a simple one. The detector then doubles as a verifier: the plan is to use it to train a small language model to produce text that avoids detection, described explicitly as a way to study the limitations of AI detectors and to explore verifier-based LLM training outside the usual math-and-code reasoning setups.

Two practical uses are given for a detector like this: filtering out spammy AI-generated content, and helping someone polish their own writing without it drifting into text that reads as AI-written. The risk singled out is that grammar and polishing tools, including general-purpose chatbots, can turn genuinely human writing into prose that is technically still the writer's own words but sounds machine-generated and gets flagged as spam. As an example, the article imagines asking an AI checker to 'fix my grammar while ensuring that my text still scores 0% AI-generated.' A disclaimer follows: AI checkers are called 'essentially a cat-and-mouse game,' where a checker learns to spot a pattern typical of AI writing, a later LLM stops exhibiting that pattern, by accident or by design, and avoids detection, and the checker then has to be updated to catch it again. The write-up also warns the detector is likely to produce false positives: human-written text wrongly flagged as AI-generated.

On method, the approach is said to resemble Pangram's models, described, with an explicit hedge ('as far as I know'), as the technology behind Substack's own detector. The classifier itself is a fine-tuned DistilBERT model, built the way an earlier Substack article, 'Finetuning Large Language Models,' described, and it returns a 0-100 score: the classifier's own estimated probability that a text belongs to the 'AI-generated' class, which the author is careful to note should not be read as a general probability that a given text was actually written by AI. The stated end product is an AI-detector API usable by both humans and agents, plus a browser-based UI, shown in a preview screenshot, that scores a whole text and can also highlight scores for individual chunks. The freely accessible part of the article ends right after the DistilBERT approach is introduced; it is gated for paid subscribers beyond that point, so the dataset construction, the actual training run, local deployment, and the RLVR step named in the subtitle are not covered in the portion available without a subscription.

Key facts

  • Substack recently added an AI-detector feature to its interface, and Sebastian Raschka responds with a Substack tutorial that builds a similar text detector from scratch, framed as a demo of what small language models (SLMs) can do.
  • The detector doubles as a verifier: the stated plan is to use it to train a small language model to write text that avoids detection, an explicit study of AI-detector limitations and of verifier-based LLM training beyond the usual math-and-code reasoning setups.
  • The classifier is a fine-tuned DistilBERT model that returns a 0-100 score, described as the classifier's own estimated probability of the 'AI-generated' class rather than a general probability that a text was actually written by AI.
  • The method is said to resemble Pangram's models, credited, with an explicit hedge ('as far as I know'), as the technology behind Substack's own detector; the stated end product is an API usable by humans and agents plus a browser UI that scores a whole text and highlights individual chunks.
  • The article warns AI checkers are prone to false positives and calls detection a 'cat-and-mouse game'; the freely accessible preview ends at a paywall before it covers dataset construction, the training run, local deployment, or the 'RLVR' step named in the subtitle.

Why it matters

Substack just added an AI-detector score to its own interface, the news this tutorial opens with, so an open, from-scratch account of how such a detector is actually built matters for understanding what these scores can and cannot mean. The write-up situates its approach, a supervised classifier, among the detection techniques it lists from an earlier 2023 article: perturbation-based probability tests, perplexity measures, and watermarking, alongside supervised classifiers like the one built here. It is also explicit that its own 0-100 score is a classifier's estimated probability, not a certified fact about who wrote a text, a distinction that can get lost when a platform simply displays a number. Layering a second step on top, using the detector as a verifier to train a small model to produce text that avoids it, turns the project into a live test of how brittle these systems are. The author frames that as a template for building any verifier or scorer used to train or grade other LLM outputs, not just detectors, beyond the usual math and coding reasoning benchmarks.

Who it affects

Writers who use grammar or polishing tools are a direct audience: the article's own worry is that a genuinely human draft can come out of a polishing pass sounding machine-generated and get flagged as spam, which is why it imagines someone asking a checker to confirm a cleaned-up text still 'scores 0% AI-generated.' Substack itself, whose new AI-detection feature triggered the tutorial, is relevant too: the write-up names Pangram's models as the technology behind that feature, hedged explicitly with 'as far as I know' rather than stated as confirmed fact. Beyond that, the tutorial targets anyone building or studying small, locally deployable classifiers and verifier-based training setups, the exact kind of do-it-yourself project it says readers had been asking for.

How to use it

The tutorial's stated end product is an AI-detector API usable by both humans and agents, plus a browser UI, shown in a preview screenshot, that scores a whole text and can also highlight scores for individual chunks. The classifier is a fine-tuned DistilBERT model, built the way an earlier Substack article, 'Finetuning Large Language Models,' described. The freely accessible preview cuts off right after that method overview, though: the walkthrough for the dataset, the actual training run, local deployment, and the step the subtitle calls 'RLVR' all sit behind a paid-subscriber wall, so none of those steps are available to read without a subscription.

How solid is it

This is a first-person, hands-on build log on a personal Substack, not a peer-reviewed study, and the free preview stops before any results appear: no accuracy, precision, recall, or false-positive rate is given for the detector, and no dataset or evaluation figures are given for either the detector or the small model meant to avoid it. The claim that Pangram's models sit behind Substack's own detector is explicitly hedged ('as far as I know'), not stated as a confirmed fact. The write-up is also candid about the exercise's limits, describing AI detection generally as a cat-and-mouse game rather than a solved problem. One note on sourcing: the article's post header prints the byline 'Sebastian Raschka, PhD,' matching the source's crawl metadata and its personal-domain URL, while the tutorial's own first-person references to 'my early Substack articles' confirm it is a first-person account on the author's own Substack.

Risks and caveats

The author's own disclaimer: detectors are liable to false positives, meaning genuinely human-written text can get flagged as AI-generated, and any pattern a detector learns to catch can be circumvented once the next generation of LLMs stops exhibiting it, whether by accident or by design. That is exactly the loop the project sets up on purpose: the detector doubles as a verifier for training a model to produce text that avoids it. The worked example, asking a checker to fix grammar 'while ensuring that my text still scores 0% AI-generated,' points at the same tension: a polishing pass can push authentic writing toward a style that reads as machine-generated even though every word is still the writer's own.

“AI checkers are essentially a cat-and-mouse game.”

— the author