Most of the web is not training data. Common Crawl holds billions of pages: menus, spam, machine-generated lists, other languages and the same article copied a thousand times. FineWeb turns it into 15 T tokens by extracting text from the HTML, keeping English, applying quality filters, and deduplicating, and it measures every choice by training small models on the result (Penedo et al. 2024). CS336 Assignment 4 builds the same pipeline (handout and tests).
Heuristic filters. Gopher’s rules remove pages with too few or too many words, implausible word lengths, many lines trailing off in ”…”, or few alphabetic words (Rae et al. 2021, appendix A). They are cheap and transparent but blunt: they also drop tables, code and poetry. Classifiers trained to recognise reference-quality text are the other common approach.
Deduplication. Repeated text wastes compute and gets memorised (Lee et al. 2022). Lines that repeat across a corpus are mostly boilerplate, so exact line deduplication removes them. Near-duplicate documents need a similarity: the Jaccard similarity of their sets of word n-grams. Comparing every pair is quadratic, so MinHash summarises each set by a short signature whose agreement rate estimates Jaccard, and locality-sensitive hashing compares only documents whose signatures agree on a whole band (Leskovec, Rajaraman and Ullman, chapter 3).
Personal information. Regular expressions mask email addresses, phone numbers and IP addresses. They miss names and addresses and also catch false positives; real pipelines combine several methods and still leak some (CS336 Assignment 4, section on PII).
#2seaside-digest.net/tidepoolsremoved: near-duplicate of #0
#3deals4u.biz/winremoved: word count
12 words · mean length 4.4 · 100% alphabetic · 0% of lines end in …
#4stats-dump.info/tableremoved: alphabetic words
116 words · mean length 3.7 · 25% alphabetic · 0% of lines end in …
#5top10-lists.com/beachesremoved: lines ending in …
118 words · mean length 3.8 · 93% alphabetic · 100% of lines end in …
#6breadlab.example/basic-loafkept
Good bread needs only flour, water, salt and time. Mix the dough, let it rest
for half an hour, then fold it every thirty minutes for two hours to build
strength without kneading. Shape the loaf, let it rise overnight in the fridge,
and bake it in a very hot covered pot. Our recipe server at |||IP_ADDRESS||| hosts
printable versions of every step, with timings for different flours.
#7mirror.breadlab.example/basic-loafremoved: near-duplicate of #6
#8spokes-and-chains.org/chain-carekept
A bicycle chain wears slowly and stretches as its pins and rollers wear,
and a stretched chain grinds down the cassette and chainrings. Measure it
every few months with a simple chain checker. Clean the chain with a rag,
apply one drop of lubricant to each roller, and wipe off the excess so that
dirt has nothing to stick to. A new chain costs far less than a new
drivetrain.
#9link-farm.example/indexremoved: mean word length
56 words · mean length 59.3 · 100% alphabetic · 0% of lines end in …
100 hashes; steepest near s ≈ (1/b)1/r = 0.55P(candidate) at J = 0.5: 0.470, at J = 0.9: 1.000candidates found: 2, merged (J ≥ 0.70): 2
after
documents
words
raw crawl
10
784
quality
6
482
MinHash
4
330
line dedup
4
282
Ten pages from an imaginary crawl. The quality filter applies the Gopher rules and says which rule a page failed. MinHash then compares 5-word shingles: #2 is #0 syndicated, rewrapped with a different header, and #7 is an exact mirror of #6. Dots on the S-curve are the pairs of pages that passed the filter, filled when LSH made them candidates; only candidates are checked against the threshold. Raise r to make the curve steeper and later, raise b to move it left. Exact line deduplication across what remains then strikes out the site's shared menu and footer, which would otherwise be repeated in every page it crawled. Last, email addresses, phone numbers and IP addresses are masked.
Left: ten sample web pages, each marked kept or removed with the reason, after the stages chosen with the buttons: quality filter, MinHash deduplication, exact line deduplication and PII masking. Removed lines are struck through and masked text is highlighted. Right: the LSH S-curve, the probability that a pair of pages becomes a candidate against its Jaccard similarity, for the rows per band, bands and threshold set with sliders, with one dot per pair of pages that passed the filter. Below it, a table of pages and words left after each stage. Keyboard: Tab to a stage button and press Enter; Tab to the sliders and use the arrow keys.
PII masking, quality filters and deduplicationstubs/m5_5_data.py
Loading starter file…
Prefer your own editor? Edit exercises/stubs/m5_5_data.py and run mlc check 5.5. The tests are identical; import the results on the progress page.
Hints · exact_line_dedup0/3 revealed
Hints · lsh_candidates0/3 revealed
Hints · minhash_dedup0/3 revealed
Then run it on real web text. Open notebooks/5.5-data-pipeline.ipynb on Kaggle (no GPU needed, internet on) and paste in your file. It streams 3,000 pages from one Common Crawl WET file, keeps English with fastText’s language identifier, and runs your filters and deduplication, printing what each stage removed. Look at the removed pages: do you agree with each decision?