How Pangram detects AI-generated content

A look at how Pangram is trained to detect AI-generated text with a near-zero false positive rate.

01

Overview

Pangram Text is designed to detect AI-generated content with a near-zero false positive rate. Our rigorous training approach minimizes errors and allows the model to detect AI text by analyzing and understanding subtle cues in the writing.

How Pangram is trained: misclassified human examples are mined and mirrored with LLM-generated text before the model is retrained.
Fig. 1. Overview of how Pangram is trained to separate human and AI-generated text.
02

Initial training process

Our classifier uses a traditional language model architecture. It receives input text and tokenizes it. Then, the model turns each token into an embedding, which is a vector of numbers representing the meaning of each token.

The input is passed through the neural network, producing an output embedding. A classifier head transforms the output embedding into a 0 or 1 prediction, where 0 is the human label and 1 is the AI label.

Each token is converted into an embedding vector and plotted in 3D space.
Fig. 2. Each token is turned into an embedding — a vector of numbers representing its meaning — which the model plots in a high-dimensional space (shown here in 3D).

We train an initial model on a small but diverse dataset of approximately 1 million documents comprised of public and licensed human-written text. The dataset also includes AI-generated text produced by GPT-4 and other frontier language models. The result of training is a neural network capable of reliably predicting whether text was authored by human or AI.

Text is tokenized and passed through the network to a classifier head and embeddings, and softmax produces a prediction.
Fig. 3. The initial model is trained on roughly one million human and AI-generated documents.
03

Continued improvement through iteration

Hard Negative Mining

The initial model was already quite effective, but we wanted to maximize accuracy and reduce any possibility of false positives (incorrectly predicting human-authored documents as AI-generated). To do this, we developed an algorithm specifically for AI detection models.

With the initial dataset, our model did not have enough signal to go from 99% accurate to 99.999% accurate. While the model learns the initial patterns in the data quickly, the model needs to see hard edge cases in order to precisely distinguish between human and AI text.

We solve this by using the model to search large datasets for false positives and augmenting the initial training set with these additional hard examples before retraining. After several cycles of this, the resulting model exhibits a near-zero false positive rate as well as overall improved performance on held-out evaluation sets.

The model mines large datasets for hard examples, which are added to the training set before retraining.
Fig. 4. The model mines large datasets for hard examples, which are added to the training set before retraining.

Mirror Prompts

We design the AI side of the dataset to closely resemble the human side in style, tone, and semantic content. For each human example, we generate an AI-generated example that matches the original document on as many axes as possible, to ensure that our model learns to classify documents solely based on specific characteristics of LLM writing.

For each human document we generate a mirrored AI document matched on style, tone, and content.
Fig. 5. For each human document we generate a mirrored AI document matched on style, tone, and content.

Retrain

We train the model with the updated training set and evaluate the model's performance at each step. Using this method, we are able to reduce errors and increase the accuracy of our model beyond what is possible with normal training.

Each retraining cycle is evaluated, steadily reducing errors beyond what normal training achieves.
Fig. 6. Each retraining cycle is evaluated, steadily reducing errors beyond what normal training achieves.
04

Learn more

Check out our full technical white paper on arXiv where we go in-depth on training details, performance, and other experiments.

arxiv.orgTechnical Report on the Pangram AI-generated Text Classifier
    How AI Detection Works | Pangram Labs