ATRIUMsearch → argument graph
Article · 2026-08-15 · 6 moments

Building an AI Text Detector From Scratch

An End-to-End Project With Dataset Construction, Model Training, Local Deployment, and RLVR ✦ AI generated

01
Context

AI checkers are fundamentally a cat-and-mouse game in which detectors learn to catch a pattern and the next LLM may avoid it, so detectors must constantly be updated and will inevitably produce false positives.

The author gives a disclaimer that AI detection is a cat-and-mouse game: detectors catch patterns, newer LLMs evade them, detectors get updated, and false positives are likely.

transcript

the author: Disclaimer: AI checkers are essentially a cat-and-mouse game. AI checkers may learn to detect a certain pattern that is indicative of AI-generated content. Then, the next LLM may incidentally or deliberately not exhibit that pattern and avoid detection. The AI checker then has to be updated to detect said LLM, and so forth. Plus, it's also likely to encounter false positives (human written text flagged as AI-generated), but more on that later.

02
Example

An AI checker can detect whether your own writing has been overpolished into text that sounds AI-generated, so it can help improve writing while avoiding being flagged as spam.

The author explains practical uses of an AI detector: filtering spam and helping writers polish their work without turning it into overpolished, AI-sounding text that gets flagged.

transcript

the author: In practice, such a detector can be used to filter out spammy content, but also to potentially improve your personal writing without turning it into AI-generated text. For example, if you wrote a lengthy article and want to improve spelling and grammar, it is tempting (and actually useful) to use a grammar checker to polish it and improve readability. There are different services for that, including general-purpose LLMs like ChatGPT. However, this also runs the risk that these tools turn your writing, even though it's still your own writing, into something that is then overpolished and now sounds like AI and gets flagged as spammy content. For example, with an AI checker, one could say, "Fix my grammar while ensuring that my text still scores 0% AI-generated."

gives example · 1

03
Context

An AI text detector can be built from scratch as a small educational project by fine-tuning a classifier model, and it can also be used as a verifier to train a small language model that produces text avoiding detection.

The author introduces the project: building an AI text detector to explain how AI detection works, motivated by Substack's new feature, and using the detector as a verifier for training an SLM that bypasses detection.

transcript

the author: Substack recently launched its AI detector feature in the UI, which is super interesting. Separately, lots of people asked me about interesting local do-it-yourself LLM projects as demos to show what small language models (SLMs) are capable of. Putting one and one together, I thought it would be interesting to show how an AI detector can be implemented. I will also use it as a verifier to train a small language model to produce text that avoids detection. This is a small educational project for studying the limitations of AI detectors and exploring a verifier-based LLM application beyond regular reasoning models trained on math and code.

explains mechanism · 1provides context · 1

04
Mechanism

The detector will be built by fine-tuning a DistilBERT classifier, a method similar to Pangram models, which are believed to power Substack's AI detection feature.

The author details the method: fine-tuning a DistilBERT classifier, similar to the Pangram models he believes back Substack's AI detection feature.

transcript

the author: Here, we are going to develop a method similar to Pangram models, which, as far as I know, are behind Substack AI detection feature. ... For this, we are going to fine-tune a DistilBERT classifier (similar to what I described in one of my early Substack articles, Finetuning Large Language Models), but more details on that later when we get to that stage.

05
Context

The project's goals are to illustrate how AI detectors work through an applied end-to-end LLM project, producing an AI-detector API and a user-friendly UI for humans and agents.

The author states the project goals: to show an applied end-to-end LLM project and to produce an AI-detector API usable by humans and agents, plus a user-friendly UI.

transcript

the author: There are several goals of this project. The overarching goal is, of course, to illustrate how AI detectors work and show an applied end-to-end LLM project including evaluation, training, and local deployment for real-world use. The outcome of this is an AI-detector API that can be used by humans and agents, and a user-friendly UI.

06
Mechanism

There are different approaches to detecting AI-written text—from supervised classifiers and perturbation-based probability tests to perplexity measures and watermarking—and this tutorial builds a model returning a 0-100 score.

The author outlines the detection approaches and introduces the specific method used: a classifier that returns a 0-100 score indicating how likely text is AI-generated.

transcript

the author: In essence, there are different ways to detect AI-written text, from supervised classifiers and perturbation-based probability tests to perplexity measures and watermarking. In this tutorial, we will build a model that returns a 0-100 score. It's essentially a classifier with an estimated probability score. The probability score will denote how likely a text is AI-generated according to the classifier. (Or, to be precise the score is the classifier's estimated probability for the AI-generated class based on its training distribution. However, we shouldn't interpreted it as a general probability that the text was written by AI.)

Highlight slides
Related episodes