Mahir Shahriar Tamim

AI Researcher · Explainable & Responsible AI · Vision, Language & Agentic Systems

← All posts

How AI text watermarking works

TL;DR

  • A text watermark is a hidden statistical pattern in which words a model picks. You can’t see it, but anyone with the secret key can count it.
  • The common trick: a key splits the vocabulary into “green” and “red” words at every step, the model leans toward green, and a detector checks if there are too many greens to be chance.
  • It works on long, untouched text from one provider. Short text, code and heavy paraphrasing break it, and it says nothing about whether a person did the thinking.

I keep wondering how much of what I read is written by a model. The usual “AI detectors” guess from style, and honestly they’re not reliable. Watermarking is a different idea: the model itself hides a signal while it writes, so you don’t have to guess. I wanted to understand how that can work without changing the text in any visible way, so I built a small version of it.

writing “the” previous word secret key hash green half model, cat, text … red half dog, sky, word … model samples green words get +δ repeat for every word detecting some text who wrote this? redo split with the key count the green words z = (G − T/2) / √(T/4) z > 4 → watermarked no model needed, only the key
At every step the secret key and the previous word decide which half of the vocabulary is green. The model leans green, the detector counts green.

The green list trick

The scheme most people start from is from Kirchenbauer et al. (2023). Before the model picks each next word, it hashes the previous word together with a secret key. That hash splits the whole vocabulary into two halves, green and red. The split is different at every position, so there’s no fixed list of “watermark words” to spot.

Then the model adds a small bonus, called δ, to the scores of the green words and samples as usual. It doesn’t force green words. Most of the time there’s a perfectly good green option anyway, so the sentence still reads normally. But over a few hundred words, the text ends up with way more green words than it should.

Counting it

The detector doesn’t need the model at all, only the key. It walks through the text, redoes the green/red split for every word, and counts. Normal text, human or unwatermarked, lands near 50% green. If a passage has T words and G of them are green, the z-score is

z = (G - 0.5 × T) / sqrt(0.25 × T)

For example, 120 words with 90 greens gives z ≈ 5.5. Anything above about 4 is basically impossible by luck (less than 1 in 30,000), so you call it watermarked. Try it below: generate some text, then play with the key, the strength and the paraphrase button.

Model writes

A toy word-level model trained on a few paragraphs, so its sentences wander. The counting is the real scheme (γ = 0.5, detection at z = 4). The model writes with the key “key-42”.

Things I noticed while playing with it:

  • Wrong key, no signal. Change the detector key to anything else and the same watermarked text looks completely random. Only whoever holds the key can check it.
  • Short text doesn’t work. At 20 words even fully watermarked text almost never crosses the line. There just aren’t enough words to be confident.
  • δ is a trade-off. A small δ barely changes the writing but the signal is weak. A big δ is easy to detect but bends the word choice more.

Is anyone actually using this?

Yes. Google DeepMind runs SynthID-Text in Gemini and described it in Nature in 2024. It uses a smarter sampling scheme they call tournament sampling instead of a fixed bonus, and they tested it on live traffic to check that people didn’t rate the watermarked answers as worse. They also open-sourced it. OpenAI has said it built a text watermark too, but it hasn’t shipped one widely. There are other designs as well, for example distortion-free watermarks that don’t change the output distribution at all.

Where it breaks

  • Paraphrasing. Every word you swap breaks the chain, because the split for the next word depended on the old one. Light edits leave enough signal, a full rewrite (or running it through another model) can wash it out. The paraphrase button above shows this.
  • Low-entropy text. Code and factual answers often have only one sensible next word, so there’s no room to prefer green. Less choice, less signal.
  • One provider at a time. Each company’s key only detects its own model. And an open-weights model can simply be run without a watermark.

This is not an AI detector. Tools that guess “was this AI?” from style don’t have a key, and they’re unreliable. One study found GPT detectors flag non-native English writers far more often. A watermark avoids that, but only for text it was put into.

What I take from it

Watermarking is clever and the math is surprisingly simple. But it answers a narrow question: did this model write this text, mostly untouched? It can’t tell you if a person did the thinking behind it. If I write something myself and let a model polish it, the watermark (if any) probably gets mixed up with my words anyway. So I don’t think it saves us from the dead-internet feeling. It’s one tool for provenance, not a lie detector. Anyways, I’m curious if anyone has seen it work at scale outside Google.

Papers