Skip to content
The Daily Triptych243 / 365
From crawl to train set

Automated quality filters and staged deduplication thin a raw web crawl into a corpus usable for pretraining.

II · THE IDEA · ARTIFICIAL INTELLIGENCE

Cleaning Web-Scale Training Data

data · filtering and deduplication · T5/C4; Lee et al. 2021 · Common Crawl derived corpora

▶ Listen · narrated

A web crawl is mostly repetition: the same article scraped under many addresses, plus menus and spam. Train on that untouched and a model relearns the same passages again and again.

At a glance

Raw source
Massive web crawls such as Common Crawl, noisy by default
C4 cleaning
Language filter, punctuation heuristics, blocklists, span deduplication
Duplicate types
Exact copies, near-duplicates, and shared long substrings
Main methods
Hashing for exact matches; MinHash for near-duplicate documents
Observed gains
Better models, less train–test overlap, reduced memorisation

Think of the open web as a vast second-hand bookshop. The same pamphlet has been photocopied hundreds of times over, half the shelves hold torn menus and adverts, and a few corners are places you would not send a child. Before you hand that shop to a student who will read day and night, you hire staff who are fast rather than thoughtful.

One team clears out sections in languages you did not ask for, pages that are mostly computer code, pages that are only buttons with no real sentences, and anything matching a list of banned words or banned websites. A second team stamps every book with a fingerprint. Where two fingerprints match, the copy is thrown away. Books that are nearly the same — a few words changed, a new date on the cover — are treated as one book. Long paragraphs that turn up inside otherwise different books are cut too, so the student does not learn the same passage from twenty sources.

That is automated filtering and deduplication. The student is the language model, and the tidied shelves are corpora such as C4. The staff never read for meaning; they apply quick rules across an enormous space. You lose some strange but genuine writing, and clever spam still slips past. What you gain is a student whose memory is spent on new material rather than on repeats and rubbish.

Look closer

  1. Heuristics decide what counts as text

    In building C4 from Common Crawl, pages were kept only if a language detector labelled them English. Lines that did not end in terminal punctuation were dropped, as were pages with too few sentences. Blocklists removed pages containing words from a banned list and pages from blacklisted domains. Pages that looked like pure filler placeholder text or were dominated by Javascript source were discarded. None of these rules understands meaning; each is a cheap, corpus-wide gate.

  2. Duplication is not only whole pages

    Lee and colleagues separate exact duplicate documents, near-duplicate documents, and long shared substrings that can appear inside otherwise different pages. Exact matches fall to hashing. Near-duplicates are found with MinHash over sets of n-grams so that rewritten or lightly altered copies still collide. Substring deduplication targets repeated passages that survive document-level passes — boilerplate, syndication, and copied paragraphs.

  3. Train and evaluation can secretly overlap

    When the same or nearly the same text sits in both the training split and a held-out evaluation set, perplexity and related scores stop measuring generalisation cleanly. Deduplication across splits is therefore not only a training concern: it is a measurement concern. After removing overlaps, reported improvements from scale look less contaminated by copies of the test data.

The story

Web-scale training data does not arrive as a curated library. It arrives as a crawl — an automated sweep that saves billions of pages exactly as it finds them. Mixed in with the writing are navigation bars, spam, machine-generated filler, mirrored sites, and the same article saved under many different addresses. Two lines of work turn that pile into something a language model can learn from. The first is quality filtering: throwing out pages that fail simple tests. The second is deduplication: removing copies. The Colossal Clean Crawled Corpus, known as C4, was built for the T5 transfer-learning study and shows the first. Lee and colleagues studied the second directly.

C4 begins with Common Crawl, a large public archive of web pages, and applies automatic rules rather than human judgement. A language detector — a program that guesses which language a page is written in — keeps the English pages and drops the rest. A line filter deletes any line that does not end in a full stop, question mark or similar closing punctuation. The reasoning is mechanical: real sentences usually end that way, and menu items and stray fragments usually do not. Pages holding fewer than a set number of sentences go too. A blocklist of banned words and a blacklist of banned domains remove pages tied to offensive or adult material. Pages that are mostly placeholder filler text, or mostly Javascript source code rather than prose, are discarded. Finally, any three-sentence span that appears more than once in the corpus is kept only once. What survives is still web text, but with much of the obvious rubbish gone.

These rules are crude on purpose. A line without a full stop may be a heading or a line of poetry. A page caught by the blocklist may be news reporting or fiction. The designers accepted those mistakes because every rule has to run across an enormous archive, so only cheap tests are affordable. The consequence is that the filter's habits — a preference for English, for conventional punctuation, for prose that looks like an article — pass into every model trained on the result.

Deduplication fixes a different problem. When the same page appears twice in the training set, the model is taught the same words twice, and that second pass buys nothing new. Near-duplicates do the same damage less visibly: a mirror with a few words changed, a template page with only the date swapped, a syndicated story republished on ten sites. Lee and colleagues found that a large share of web-derived training text is redundant in this way, and that long identical passages also turn up inside documents that are otherwise quite different.

Their pipeline works in layers. Identical documents are caught by hashing: each document is reduced to a short fingerprint, and matching fingerprints mean matching text. Near-duplicates are caught by MinHash, which builds a compact sketch from each document's overlapping word sequences, so that two texts sharing most of their phrasing produce similar sketches and can be merged even though no exact match exists. A final pass hunts for long stretches of text repeated across documents — footers, syndicated paragraphs, boilerplate — and strips those.

The reported effects are practical. For a fixed amount of computing, models trained on deduplicated data do better, because their capacity goes on varied examples instead of repeats. Memorisation drops: when an unusual passage appears once rather than dozens of times, the model is far less likely to reproduce it word for word when prompted. And when the training set and the evaluation set are deduplicated against each other, the test scores measure something real. Otherwise a model can score well simply because the test text was sitting in its training data under another address.

So filtering and deduplication sit upstream of every argument about model architecture. The same transformer will pick up different habits from a crawl still stuffed with copies of one FAQ than from a crawl stripped and uniqued. Neither step is neutral and neither is finished: toxicity filters cannot read context, quality rules bin odd but genuine writing, and approximate matching both merges texts it should not and misses copies it should catch. Skip them, though, and the training run is mostly a study of the web's own repetition and debris.

Why it mattered then

When T5 and related work turned to Common Crawl-scale text, raw web dumps stopped being a curiosity and became the training set itself. Noise a small hand-picked corpus could shrug off now dominated: English mixed with other languages, pages that were mostly scripts and menus, adult and offensive material, and the same content mirrored across domains. C4's pipeline was the pragmatic answer — automatic, repeatable by anyone with the same recipe, and blunt enough to turn a crawl into text a single text-to-text model could train on. Scale also made duplication both invisible and costly. One article under many addresses, shared footers, and site templates inflated the token count without adding anything new to learn from. Lee and colleagues made that cost countable. They measured how much of a corpus was redundant, showed how text shared between the training and test sets could push scores up for no real reason, and traced verbatim memorisation to how often a passage had been seen. After that, filtering and deduplication were part of building a serious pretraining set, not optional tidying.

Why it matters now

Training runs, open and closed alike, still start from crawls or mixtures derived from them. Every new corpus inherits the same three decisions: what to bin as toxic or low quality, how hard to press on near-copies, and how to keep the evaluation set honest when the web has already copied the same text onto both sides of the train–test line. Those choices reach further than efficiency. Blocklists and language filters decide whose writing is represented. Duplicate tokens decide how much of the compute budget is wasted. Repeated strings decide how often a model recites its training data word for word, which is where privacy risk lives. And test contamination decides whether a benchmark number means anything. Anyone comparing models is therefore partly comparing data recipes. Two runs with the same architecture and different cleaning rules are not the same experiment. Reading a model card, estimating training cost, or judging a claim about scale all depend on knowing what the filters and the deduplicator did first.

The surprising detail

Deduplication is not just about saving disk space or shortening a training run. Lee and colleagues tie it to whether the scores can be trusted at all: leave overlapping text in both the training and test sets, and a model looks stronger only because it has already read the answers in another guise. The same work links repeated passages to memorisation, so a decision made about redundancy also changes how often a model recites its training text verbatim. Quality filtering hides a quieter surprise. Its most useful signals are about how text looks, not what it says — whether a line ends in a full stop, how many sentences a page holds, how much of it is code. The corpus is shaped as much by typography as by meaning.

What is disputed

Published pipelines describe the main C4 rules and the Lee et al. deduplication methods, but exact thresholds, blocklist contents and match rates vary by implementation and crawl snapshot. Reported gains depend on the base corpus and model size; treat quantitative improvements as directional evidence from those studies, not universal constants.

Remember this

Web-scale training sets are built by blunt filters and copy removal. Those choices shape quality, honest evaluation and memorisation as much as model size does.

Test yourself

A team trains on a filtered crawl and reports strong held-out perplexity. Name two distinct reasons that figure might still overstate how well the model generalises, one tied to filtering limits and one to duplication.

Go deeper

Image: Original diagram, The Daily Triptych. Licence: Original work. Source.

← Back to day 243