Building a pretraining corpus
Describe the pipeline: web crawl → text extraction → language ID → heuristic and model-based quality filters → deduplication → domain mixture weights. Explain how each step shapes the distribution the model learns to imitate.
Builds on: The next-token cross-entropy objective
What the animation says
The model imitates its data
Training minimizes the loss, and that is maximum likelihood. It pulls the model toward whatever text you feed it. A raw web crawl is full of menus, spam, and copies of the same page. And a few languages dominate it. So choosing what text, in what proportions, is not housekeeping. It defines what the model learns to predict.
The pipeline
The crawl sets what can be learned at all. Extraction turns HTML into main text. Leftover boilerplate becomes text the model learns to write. Language ID keeps pages it's confident about, in chosen languages. Unsure ones drop out. Heuristic rules cut pages that are too short, too symbol-heavy, or full of repeated lines. A quality classifier keeps pages resembling trusted text, like encyclopedias and textbooks. Then deduplication, then mixture weights. Your model keeps writing 'Accept all cookies'. Tap the step that let it in.
Every step reweights
Each step is a reweighting of the crawl. Filtering multiplies each page's frequency by keep, which is one or zero. Survivors keep their raw proportions. The rest vanish. But a page copied fifty times counts fifty times. Deduplication collapses it. After that, how much does it weigh compared to a page seen once?
Mixture weights
Equal. One copy, one vote. Now mixing. Each training token comes from a domain with probability equal to its weight. So the loss splits into a sum over domains: weight times that domain's mean loss. The weights add to one. The loss is lowest when the model matches this reweighted data. After filtering: web has 900 billion unique tokens, code 80, books 20. We train on 1000 billion tokens, weighted 70, 20, and 10 percent. How often is each book token seen?
Weights vs. repeats
Ten percent of a thousand billion is one hundred billion book tokens. Divided by twenty billion unique, that's five passes. Code: two hundred over eighty is two and a half passes. Web: seven hundred of nine hundred, about zero point seven eight passes. Some web text is never seen. Books now drive ten percent of the loss instead of two. But repeats teach less each time. Every step picks the distribution your model will imitate.
The pipeline, step by step
Every step is a reweighting
Mixture weights override natural sizes
Remember
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.
Bytewise
All courses