How does Pangram work?
pls note: all em dashes were human generated.
AI writing is everywhere nowadays, and while AI patterns are easy to see, they are hard to reliably detect. My purpose here is to explain how Pangram works, and how AI detection works more broadly.
Take these two passages. Which one of them seems like AI to you?
In an age of slop, this article—written carefully, entirely with human hands—stands as a kairotic reminder that human writing will always provide valuable insights over AI writing.
What next? Writing is an act of thinking, it’s also evidence of thinking posited by the author. We don’t have that guarantee anymore, and in fairness, it might matter less as AI writing gets more accurate and sounds better. Regardless, in the age of slop, I’m glad Pangram exists and helps make that distinction better.
Pangram is an AI detector—that actually works—and can identify AI tells in diverse arrays of writing styles and documents. Detecting AI is not just a matter of authenticity, it’s a load-bearing asset that preserves human connection. In this blog we will delve into how Pangram works—the nuts, the bolts, and the screws.
100% human written
A person wrote every word of this para, start to finish. I’m saying this cause so much stuff that gets published now comes from a machine.
The question is “What happens to writing?” For basically all of human history, a piece of text was proof that someone somewhere spent time thinking about it. That guarantee disappeared sometime in the last few years, and I don’t think we’ve priced in what that means.
Tools like Pangram are an attempt to get some of that guarantee back. Pangram detects AI writing, and it’s one of the few detectors I’ve seen that holds up when you test it seriously. You can throw wildly different kinds of text at it, student essays, emails, longform blog posts, research papers, etc. and it will tell you which passages came from an AI model.
100% AI written
Checked with Pangram.
On the face of it, Passage 1 has various common tells of AI writing, and Passage 2 sounds crisp. Most readers would say the latter is much better written and sounds more human.
But the answer is the opposite. I wrote Passage 1, and Pangram marks it 100% human written. Passage 2, meanwhile, was generated by an LLM (Fable 5.1) and ‘humanized’ with some creative prompting. Pangram correctly flags it as 100% AI written.Results hold up if you test the passages separately; if tested together, both are marked as AI, and we will explore why in Step 4.
When I pasted these passages into Pangram, what was happening?
But first, what is Pangram?
Pangram is an AI detector that judges whether text (and now images) was created by a human or a machine. Pangram is itself a type of AI model known as a classifier. Classifiers take inputs and sort them into pre-determined categories.
Pangram is also (imo) the only AI detector that’s reliably accurate.In my testing I found Pangram was by far the best overall, and GPTZero was a distant second. It can distinguish between AI-written text, AI-edited text and mixed human-AI text. The newest version, Pangram 4, according to internal benchmarks, has a false positive rate of 0.0041% and a false negative rate of 0.3396%.It wrongly flags human writing as AI 1 in 24,000 cases.
It misses AI writing 1 in 294 cases.
As you can see from the passages up top, Pangram does not rely purely on the common tells and vocabulary of AI. So, if AI patterns and common words aren’t solely what Pangram is looking for, how does it work?
How LLMs write and why it leaves traces
For a crude explanation of how LLMs work, they’re ‘next-word probability machines’. An LLM reads all previous text, calculates a probability for every possible next token—for now, think of it like a word or word fragment—in its vocabulary, and then samples from a freshly computed pool of choices at every step.
If you ask an LLM to finish this sentence:
“I’m gonna take my dog for a ___”
‘Walk’ would likely be the highest probability choice. ‘Stroll’ or ‘Run’ would also be somewhere in the likely candidates pool. While ‘Coup’ or ‘Funeral’ would be quite unlikely, but maybe not impossible.
A model almost always picks a likely word, but not always the likeliest. Each pick is a weighted draw from the probabilities above.
If models always chose the highest probability token, the writing would be robotic and sound flat. Instead, modern models sample stochastically from the distribution (sort of like rolling a weighted die) to add variation to their output.
If models sample words with some randomness, why does AI writing still leave traces?
Simple, humans are more likely to take their dogs to a funeral or sudden coup.
‘Raw’ models which have only been trained on data have a diverse range of output. To make sure this output is usable and helpful, models go through additional training like reinforcement learning (RL), so that those probabilities are biased towards giving the preferred or ‘right’ answer. RL involves human or AI evaluators who rate various possible responses based on set guidelines.
Unlike maths or code, there’s no ‘right’ answer for open-ended writing, it’s whatever the evaluators rate the highest. The model learns the goal is to optimize for these ratings.
This post-training process gives LLMs their distinct voice.
The model is more likely to be rewarded during training if it goes with safer, more structured picks that sound appealing to the human reader, which means its output gets less diverse (this is called mode collapse). In turn, this loss of stylistic variance imbues LLMs with distinct and detectable quirks.
Of course, predictable writing doesn’t automatically mean AI. After all, humans take their dogs for walks as well. And humans do use words like ‘delve’ or ‘load-bearing’. The trace builds up over repeated token-picks as LLMs sample from that smaller set of likely choices hundreds or thousands of times in a row.
How did earlier AI detectors try to catch these traces and why didn’t it work?
Only interested in Pangram? Skip this section.
Other than looking at overused words and phrases—not to mention the constant reliance on em dashes—older detectors would rely on two primary indicators of AI writing.
First, perplexity, which is how unexpected, or surprising each word in a piece of text is to an LLM.
- Low Perplexity: I’m gonna take my dog for a walk.
- High Perplexity: I’m gonna take my dog for a funeral.
To find the perplexity, older detectors turned individual token probabilities into an average score that measures surprises across the entire document. If a document has a perplexity of 1, it means each token was totally predictable. If the doc has a perplexity of 50, it roughly means that at each step, it was like the model was choosing amongst 50 plausible options.
Second, burstiness, which is the variation in perplexity from sentence to sentence.
Human writing has rhythm, it ebbs and flows. You’ll see short sentences with random quixotic words. Words that might sound clunky. Three word sentences—in the wrong place.
Extremely long sentences interspersed throughout because that’s how humans think. We change our minds, think of different connections mid-way through, sometimes use words not in tune with the dictionary definition.This is why some AI humanizers effectively make writing worse for a cheap way to evade AI-detection.
AI writing is more predictable: it has structure and it flows neatly from start to finish. Generally speaking:
- Human writing → higher perplexity and burstiness
- AI writing → lower perplexity and burstiness
Unfortunately this approach, while informative, isn’t reliable and generated a lot of false positives.
Humans can write formulaically, which is especially true when writing technical docs or briefs. Some AI detectors (not Pangram) even marked the US Constitution as AI-written. The text is so ubiquitous that it was repeatedly fed into the training data of LLMs, which memorized it verbatim. AI models used to detect AI could predict every next word, which meant the entire document had low perplexity, and was marked as AI-written.
So, how does Pangram get near-zero errors?
Pangram has been trained to recognize patterns that lie underneath text.
The standard ML method to draw a boundary between categories is to train a neural network on massive datasets. So, why not take 10 million human-written blogs and generate 10 million AI-written blogs to train the classifier to separate them?In practice, when classifying AI text, accuracy doesn’t obey normal scaling laws and performance saturates around 40,000 examples per domain.
The problem is that a model trained in this simple manner learns shortcuts and overfits on superficial features instead of learning the deeper patterns of AI-writing. It latches onto (a) overused phrases like “Let’s dive in.” or “The key point is”, (b) topics that are naturally more common with AI than humans, (c) uniform document and sentence length, (d) the polished, semi-formal explanatory tone most LLMs default to.
Relying on these shortcuts could mean a detector falsely flags writing by a non-native speaker, or a person who naturally overuses some of the same terms AI does.Or unnaturally; humans are beginning to write and speak more like AI as a result of conversing with LLMs which brings a new challenge to AI detection. Or, it might totally miss text that’s been prompted to remove obvious AI-associated phrases and tells. You get the gist of it.
To avoid these traps, Pangram’s training relies on 3 things:
1. AI twins & AI edits of human writing
Pangram Labs used synthetic mirror prompting to build its training dataset. For every human document,Pangram is trained on writing before LLMs contaminated the internet commons, quite similar to pre-nuke steel, so text written in 2021 or earlier. they created an AI document that matched the original in topic, length, and tone.
To create AI twins, they provide LLMs with the text, ask for a title, then separately prompt the LLM to write about the topic.
Now, the human version and the machine version of each pair are matched as closely as possible, and the main differentiating factor is who wrote them.
Human writing and AI mirror
The is one of the most recognizable , intimately connected with and untamed . A symbol of places, significant in faiths and folktales of many civilizations, inspire millions of people around the globe, from the monasteries in Bhutan to the catwalks of Milan.
Sadly, are on the brink of extinction. Just over a century ago, 100,000 roamed across Asia. , approximately live in a mere five per cent of their historic range. The largest can now be found in India, home to half of all remaining .
Few creatures command the imagination like the , an emblem of raw and majesty. In Buddhist traditions, they are celebrated as one of the four protective , while numerous Indigenous communities view them as ancestral spirits defending the forest. The symbolism spans continents. It prowls through mythology, national identity, and modern media as most charismatic icon.
Yet, a tragic paradox defines their existence: while their mythical status endures, their physical reality is rapidly vanishing. have plummeted to roughly individuals . We immortalize in our art and folklore, yet we fail to protect their earthly survival.
Sources: WWF (human text); Gemini 3.1 Pro (AI text).
If the topic is ‘cultural significance and endangerment of Tigers’ for instance, the commonalities cancel out and the difference left for the neural network to analyze is the machine-ness of the writing.The differences show up in words, patterns, linkages, tone etc.
Pangram learns to ignore the common features and identify the underlying patterns distinguishing human and AI writing. Over millions of examples, human and AI writing settle onto opposite sides of a boundary. The model finds the features that make AI text distinctive and learns to draw that boundary on its own.
That covers 100% human vs. 100% AI.
But, a lot of writing now is mixed human-AI. To figure out how to detect those, the Pangram team also compared human documents with an AI-edited version of the same document. This is done clause-by-clause:
- If the AI clause matches the original nearly word for word, it’s labeled human.
- If the AI clause matches the idea of the original, but with new words, it’s labeled AI-assisted.
- If the AI clause does not match the original at all, it’s labeled AI-generated.
Any spelling or grammatical fixes are marked as human.
2. Retraining on the mistakes it makes
To make sure borderline cases are not falsely identified as AI, Pangram uses hard negative mining.
Neural networks learn only when they err.Well, to be more precise, they learn mostly by making mistakes and from near-misses.
If the training dataset is easy to classify, the model rarely makes mistakes, and the gradient—the correction signal that tells the model how to adjust its internal parameters—also nearly zeroes out.
When this happens, the model’s learning plateaus, and it’s not able to handle edge cases that have subtler tells. These false positives mostly come from more structured sources like Wikipedia articles, emails, academic writing, and Q&As.
Hard negative mining restores this learning signal:
- The model is trained on pre-2022 human docs and their AI twins.
- It’s then tested on harder-to-classify human documents it’s never seen before to isolate false positives.
- Synthetic mirrors are generated for these misclassified human examples.
- These false positives and their AI twins are added to the main dataset, and the model is retrained.
3. Training against humanizers
Humanization, as the name implies, is a process of making AI writing seem more human. Humanizers are tools or sets of prompts used to rewrite AI-text to evade AI detectors or just to make AI-writing sound better. These tools use tricks like substituting synonyms, making small typos, swapping in homoglyphs, changing case, etc.
To make sure the model catches these tricks, the Pangram team included humanized versions of AI texts in the training data, so it still learns and recognizes the underlying features of AI writing.
Now, what happens when we run text through Pangram?
Peeking under Pangram 4’s hood
Pangram’s model architecture is based on a pre-trained Mixture-of-Experts (MoE) model with a causal backbone.In plain words: the model reads text in one direction from left to right.
An MoE model has different parts for specialized tasks, and a router sends the input to the relevant parts.
This model is adapted using LoRA (which reduces the cost of fine-tuning),Fine-tuning involves taking an existing model and training it some more on a narrower task. along with additional classification heads that do specialized tasks.
The pipeline looks like:
Let’s take this sentence:
I saw a massive bat flying through the moonlit sky.
Step 0: Tokenize - maps text to numbers
Pangram first breaks the input text into tokens and maps each tokenFor max pedantry, a token, whether it’s a word, word fragment, or punctuation mark, is the smallest indivisible unit in the model’s vocabulary. to an integer ID:
[I, saw, a, massive, bat, flying, through, the, moon, lit, sky, .]
[40, 8274, 261, 18965, 10639, 28022, 1819, 290, 28479, 32758, 17307, 13]
Source: Used OpenAI tokenizer to illustrate the example.
How the split happens depends on the model’s tokenizer. A longer word (like moonlit) could be split into several tokens.
Step 1: Repeat2 - it reads twice
Pangram uses a causal language-model backbone, meaning it processes text strictly left to right. That makes sense for an LLM generating the next token. It cannot look at words it has not written yet. But to detect AI-writing, it helps to see the whole passage at once since the meaning and usage of a word also depends on following words. It’s like a mystery show; when you’re watching the first time, you guess things and miss out on clues. On a rewatch you can catch hidden details that point to the right answer.
Consider this sequence:
I will die if they run out of coke zero
When the model evaluates die it can’t look at “if they run out of coke zero” for context, so “I will die” looks far more dramatic than it is. Pangram fixes this problem using Repeat2—long docs are divided into overlapping 512-token windows, and each window is fed twice to the model.
At die, Pangram sees: I willAt die, Pangram sees: I will die if they run out of coke zero, I will
Pangram scores only the second copy, allowing every token to look back and get a fuller, more contextual picture.
Step 2: Contextualize - turns tokens into points
Words don’t have fixed meanings. The meaning of a token changes based on what surrounds it. Consider the word ‘bat’:
I saw a massive bat flying through the moonlit sky.
Vs.
He swung the heavy bat, driving the ball deep into left field.
Each token is represented by an embedding, a vector of numbers located in a high-dimensional space.
While frontier models can have 10,000+ dimensions, classification models like Pangram typically use 4,096,Pangram Labs haven’t published this figure, but 4,096 is common for open models.
I’m picking a number for simplicity. meaning each token is represented by 4,096 numbers.
The position of the vector encodes information the model can use to interpret the token in context. The embeddings of tokens that are used in similar contexts or share similar concepts will be closer together. At first, the embeddings for both ‘bats’ will have the same representation, since isolated, the model can’t tell if ‘bat’ refers to sports gear or the animal.
Through attention, transformer layers add contextual information to each token’s representation by weighting which surrounding tokens are most relevant. On the second copy, attention will connect the first ‘bat’ to ‘massive’, ‘flying’, ‘moonlit’, and ‘sky’, and the second ‘bat’ to ‘swung’, ‘ball’ and ‘field’. And the vectors for both will come to represent either the animal or the sports equipment.
Pull to contextualize
At the input both bats are the same point.
As the passage goes through more layers of the transformer, the vectors separate into different regions.This is a representative 2D space, the actual space will have thousands of dimensions.
Pangram computes this contextual representation for all tokens in the document. If the passage contains S tokens (such as 512) and each token is represented by D numbers (such as 4,096), we get a matrix H with 512 rows (each row represents a token) and 4,096 columns (each column is one axis in the 4,096-dimensional space).
| 1 | 2 | 3 | 4 | … | 4,096 | |
|---|---|---|---|---|---|---|
| massive | 0.218 | −0.604 | 0.377 | 0.052 | … | −0.072 |
| bat | 0.412 | −0.238 | 0.891 | 0.077 | … | 0.258 |
| flying | 0.305 | −0.517 | 0.712 | −0.146 | … | 0.144 |
| moon | 0.471 | −0.362 | 0.655 | 0.214 | … | 0.318 |
| lit | 0.503 | −0.329 | 0.618 | 0.249 | … | 0.351 |
| sky | 0.267 | −0.452 | 0.803 | 0.118 | … | −0.287 |
| swung | 0.861 | 0.209 | −0.115 | 0.497 | … | −0.319 |
| bat | 0.929 | 0.174 | −0.044 | 0.551 | … | −0.205 |
| ball | 0.774 | 0.326 | −0.208 | 0.612 | … | −0.264 |
| field | 0.695 | 0.281 | −0.162 | 0.430 | … | −0.241 |
| . | 0.552 | 0.198 | −0.121 | 0.376 | … | −0.178 |
These vectors capture each word’s contextual meaning, and importantly, they also encode the underlying clues that point to who the author is.
Step 3: Classify - who’s the author?
This step is what differentiates Pangram from other language models. LLMs like Claude or ChatGPT use vector representations to predict the next token, looping again and again.
Pangram uses those vectors to ask a simple question: who wrote this?
The output from Step 2 becomes the input for the four specialized heads attached to Pangram’s shared backbone:
-
A tokenwise provenance head assigns each token raw scores across three provenance classes: Human, AI-assisted, and AI-generated.Since the token windows overlap, many tokens are scored more than once; those scores are then averaged.
Token: “goblins” Human 0.7 AI-assisted −0.4 AI-generated 1.8
-
A 15-bucket segment head places the 512-token window on a scale from 0 to 1 (all human to all AI).
-
A binary mixed-authorship head checks whether the window contains a mix of human and AI writing.
-
A 4-class humanizer head activates only when AI is detected and classifies text into Human, AI-generated, Humanized-AI, or Mixed-authorship categories.This head is trained as a stop-gradient probe to spot AI-humanizing tactics, and unlike the other heads it can’t change the shared model since in testing letting it do so concentrated false positives in academic and ESL writing.
The tokenwise head slices through this vector space to give each token three scores: Human, AI-assisted, and AI-generated.
The model maps text so H is a constellation of S tokens in the D-dimensional space.
Step 4: Decode - cleans up the noise
In Step 3, the tokenwise head scores each token, but if we pick the label (Human, AI-assisted, or AI-generated) with the highest score for each token individually, the result would be a noisy sequence like:
But authorship usually only changes in larger chunks such as whole sentences or paras. Humans are unlikely to type two words, paste an AI word, type three words, paste two AI words, and so on.
Converting these local token-predictions into something useful requires the use of a post-processing step called a conditional random field (CRF). The idea is, instead of maximizing scores for each token, the CRF looks for the highest scoring sequence across three states (human, AI-assisted, AI-generated) using the Viterbi algorithm.
The CRF is looking for the boundary point
The CRF also applies a mathematical penalty for transitioning:
- Staying in the current state (HUMAN —> HUMAN or AI —> AI) is free.
- Switching states (HUMAN —> AI or AI —> HUMAN), especially back and forth, is expensive.When the binary head detects genuinely mixed text, it informs the CRF to ease the transition penalty.
The switch won’t activate just to mark an ambiguous word in the midst of a human sentence, because it would mean paying the penalty twice. Once to enter AI state, and once again to switch back to HUMAN. The system requires consistently strong evidence across multiple tokens to justify switching.
In this blog’s intro, I noted that Passage 1 is incorrectly marked AI when both passages are tested together but correctly marked when tested on their own; this smoothness penalty is possibly why.In this scenario, I found GPTZero fared better and correctly IDed my mixed-authorship passages even when tested together.
Basically, to find the best sequence, the CRF looks at token-level evidence (u) for each token and transition evidence (τ) between adjacent tokens:
TotalScore = Σi ui(Ti) + Σi τi(Ti, Ti+1)
- TotalScore: The CRF looks for the highest scoring sequence across three states (human, AI-assisted, AI-generated).
- Token-level evidence (u): Using the scores from Step 3, does this token look like human, AI-assisted, or AI-generated writing?
- Transition evidence (τ): How much would it cost to switch here?
- Label (Ti): human, AI-assisted or AI-generated, for token i. Ti+1 is the next token’s label.
Finally, the path with the max score is chosen with Viterbi. And for the last bit of cleanup, Pangram aligns decoded blocks with sentence boundaries, so instead of marking jagged phrases, the model highlights whole sentences. The result is clean spans:
Step 5: Aggregate - provides the final score
Since authorship isn’t all-or-nothing, the final result needs to reflect the mix of human, AI-assisted and AI-generated text. After decoding, Pangram counts the characters assigned to each class, and that’s what you see on the screen. A doc with 600 human characters, 200 AI-assisted characters, 200 AI-generated characters, would show up as 60% human, 20% AI-assisted, and 20% AI-generated.
Pangram works, with a few limitations
One, there’s not enough signal for Pangram to reliably score short texts < 50 words. And, it works best when there’s at least 250-500 words.
Two, the model is deliberately not optimized to deal with tight factual writing or constrained queries like “Who was the first emperor of Rome?”
Three, the model is optimized to minimize false positives as they’re considerably more damaging than false negatives. The trade-off is that certain kinds of AI-text can avoid detection entirely. Epoch AI tested Pangram 3.3.2 on AI-text prompted to mimic real authors, and it missed 10% of the time. Pangram 4 missed 2.86% of the same Epoch dataset.
Four, it works best for English, with lower accuracy for other languages. However, on the datasets they tested, Pangram had much lower false positives for those languages.I’m fully guessing here but they probably tested non-English languages less.
Five, for docs of mixed provenance, the context and smoothness penalty could cause small portions to be incorrectly flagged as Human or AI.
Six, the model doesn’t account for humans who write like AI (on purpose or otherwise). People have started absorbing AI-isms, and in time might sound and write a lot more like LLMs do. Now, I think it’s very unlikely someone can write exactly like an LLM even on purpose for > 1000 words. But if a detector was better at distinguishing such writing, it would earn more trust.
Till then, writing is both an act and evidence of thinking. I’m just glad Pangram exists to check the proof.