Skip to content
Inference Academy

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

16 min · verified 2026-11Pro
Share

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

  1. 1
    ExtractHTML to text, PDFs, code repositories
  2. 2
    Language IDkeep the languages you want
  3. 3
    Quality filterheuristics, then a classifier
  4. 4
    Exact deduphash of normalised text
  5. 5
    Near dedupMinHash plus LSH over shingles
  6. 6
    Scrubpersonal data, secrets
  7. 7
    Decontaminateremove evaluation sets
  8. 8
    Mixweight 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

  1. Deduplication
  2. Personal data and secrets
  3. Decontamination
  4. Mixtures
  5. At real scale
  6. 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?