A real data pipeline: cleaning, filtering and deduplication
What happens to text before pretraining: extraction, language identification, heuristic and model-based quality filters, exact and near-duplicate removal with MinHash and locality-sensitive hashing, personal-data scrubbing, benchmark decontamination and data mixtures. With a runnable pipeline that shows each stage.
By Sandip Maity, Applied AI Engineer
Model quality is set as much by data as by architecture. Every open pretraining dataset of note is the output of a long pipeline that throws most of the raw web away. This lesson builds that pipeline in miniature so each stage is visible, then describes how the real ones scale it up.
#The stages
- 1ExtractHTML to text, PDFs, code repositories
- 2Language IDkeep the languages you want
- 3Quality filterheuristics, then a classifier
- 4Exact deduphash of normalised text
- 5Near dedupMinHash plus LSH over shingles
- 6Scrubpersonal data, secrets
- 7Decontaminateremove evaluation sets
- 8Mixweight sources and tokenise
#Quality filters
Cheap heuristics remove a lot of junk: very short documents, high ratios of symbols or digits, many repeated lines or sentences, lines without punctuation (menus and navigation), and lists of keywords. After heuristics, many pipelines train a small quality classifier (for example on text that looks like reference or educational material versus random web text) and keep documents above a threshold. Classifier filtering can raise downstream benchmark scores a lot, but it also narrows the data's style and topics, so mixtures usually keep some unfiltered sources.
Pro content
Keep reading with Inference Academy Pro
Unlock the rest of this lesson, plus every advanced lesson, hands-on lab, the larger playground models and completion certificates.
Still to come in this lesson
- Deduplication
- Personal data and secrets
- Decontamination
- Mixtures
- At real scale
- Exercises
You will be able to answer
- Why remove near-duplicates, not just exact duplicates?
- What does a MinHash signature estimate?
- Why use LSH banding with MinHash?
- Two documents say the same thing in different words. Will 5-gram MinHash dedup remove one?
- What is benchmark decontamination?