N-gram
Also called Shingle
An n-gram is a run of n consecutive words taken from a text — the unit that similarity and duplicate-detection systems compare, because matching runs of words is far more discriminating than matching individual ones.
Last reviewed 15 August 2026 · The HumanFlow team
In plain English
Slide a window n words wide along a sentence and write down what you see at each step. Those overlapping runs are the n-grams.
Two texts sharing many long runs are near-duplicates. Two texts sharing only single words are just written in the same language.
A worked example
The 4-grams of a short sentence, and what happens when a second text shares some of them.
text A detectors measure predictability rather than authorship
4-grams [detectors measure predictability rather]
[measure predictability rather than]
[predictability rather than authorship]
text B detectors measure predictability rather than intent
shared 2 of 3 runs → highly similar
text C authorship is measured by other means entirely
shared 0 of 3 runs → unrelated, despite sharing wordsText C shares "authorship", "measure" and "detectors" in spirit, yet shares no 4-gram at all. Single-word overlap said similar; run overlap said unrelated, and run overlap was right.
Text B changed one word in six and kept two runs out of three. That is what near-duplication looks like numerically, and why raising n makes a comparison stricter.
This is not only a detection technique. This site's own build fails if two pages in the same family share too many 8-grams — the same method, pointed at our own writing.
Why it matters for AI detection
It is the mechanism behind similarity scores. When a report says your text matches a source, it has found shared runs, and the percentage is built from how many.
It also explains why light paraphrasing collapses a similarity score while changing almost nothing about the borrowing. Replace one word in every run and the runs stop matching, though the debt to the source is identical — which is why integrity policies name that behaviour specifically rather than relying on the number.
And it is why quoting properly is safe. A cited block quote produces the same matching runs as an uncited one; what differs is the attribution, which no n-gram comparison can see.
Commonly confused with
- Similarity score
- N-grams are the unit compared; the similarity score is the total those comparisons add up to. The score is a summary of run matches.
- Perplexity
- N-grams compare one text against another. Perplexity compares a text against a model's expectations, with no second text involved.
Read next
Part of the AI detection glossary.