xavier-ramirez.com
STAGE 0 · THE DATA PIPELINE · PART 1

From the whole internet to a recipe

Nobody trains a model on the raw web. Follow the four stations that turn the open internet into a small, clean, carefully-blended training recipe — gather, extract, deduplicate, mix. Play with each step.

  1. 01 GATHER
  2. 02 EXTRACT & ENRICH
  3. 03 DEDUPLICATE
  4. 04 THE RECIPE
STATION 01 · GATHER

Gather the raw web

Rank the whole web by authority and keep only the top slice — before fetching a single byte.

GATHER · STEP 1

Which domains even get crawled

You can't crawl the whole web on a fixed budget — so before fetching anything, a lab ranks domains by authority and keeps only the top slice.

  • Authority is a PageRank-style score over inbound links. High-authority hubs — Wikipedia, GitHub, arXiv — sit near the centre.
  • The green ring is the threshold. Inside is kept as a seed; outside is dropped before a single byte is fetched — the highest-leverage number in the pipeline.
  • Pages come from 4 tiers — toggle each below:
  • T1 · Common Crawl — the free public snapshot of the web. Most of the volume, no cost.
  • T2 · In-house bots — the lab's own crawlers (GPTBot, ClaudeBot): heavy JS, OCR, fresh pages.
  • T3 · Search APIs — an index someone else already built; you query it instead of crawling.
  • T4 · Licensed — paid direct feeds (news, Q&A, code): expensive, but high-signal.
AUTHORITY FIELD
1 / 2
Each dot is a candidate domain, placed by authority — bigger and greener means higher.

Drag the threshold — nytimes and medium drop out of the corpus around 85.

Authority = how many other sites link to this one. Raise the bar and you keep fewer, higher-quality domains — and pay less.

YIELD_METRICS
ACCEPTED437,990 / 2.4M
VOLUME10.9 TiB/mo
SHOWN13 / 40
The result of your cut: how many of the 2.4M candidate domains clear the bar, the monthly data volume, and the crawl cost.
GATHER · STEP 2

How little of a page is actually text

A crawled page looks big, but almost none of it is prose a model can learn from. This is one real 104.6 KB page, every rectangle sized by its bytes.

  • Scripts, CSS and markup dominate. The actual sentences — the green cell — are about 10 KB, under 10% of the page.
  • Common Crawl ships 3 versions: WARC (everything), WAT (metadata), WET (just the text). Pre-training mostly uses WET.
  • Keeping the raw bytes buys nothing but provenance — and a huge bill to download and unpack.
GOOD TO KNOW · COMMON CRAWL
A free 9-petabyte archive of the web
Common Crawl is a non-profit that crawls the web every month and publishes it free on AWS Open Data — about 400 TiB per snapshot, 16+ years deep. It's the baseline almost every open model starts from.
ONE FETCHED PAGE · SIZED BY BYTES

Switch WARC / WAT / WET — the readout shows what each version costs to download and unpack.

WARC — the raw payload: headers + HTML + everything. Biggest, exact provenance, mostly noise.

DATASET_TIER · WARC
TRANSFER78 TiB
UNPACKED400 TiB
What one monthly snapshot costs in this format — download size and unpacked size (hosting is free on AWS Open Data).
  1. 01 GATHER
  2. 02 EXTRACT & ENRICH
  3. 03 DEDUPLICATE
  4. 04 THE RECIPE
STATION 02 · EXTRACT & ENRICH

Extract & enrich

Strip pages down to clean text, then blend in denser sources — code, maths and books.

EXTRACT & ENRICH · STEP 1

From a saved page to training bytes

The last step showed how little of a page is text. This is the machine that extracts that text and turns it into something a GPU can train on — fast.

  • A parser strips the page to clean text — 104.6 KB of HTML in, about 18 KB of prose out.
  • Clean text → tokens → a memory-mapped .bin that streams straight from disk (NVMe) into GPU memory (VRAM), with no re-parsing.
  • Parsing raw HTML during training would starve the GPUs, so it's done once, up front.
PAGE → PARSER → TOKENS → .BIN

Try the parsers — a crude regex keeps more, but the nav and ad junk it lets through ends up in your corpus.

Trafilatura — a purpose-built article extractor. Best at dropping nav and ads while keeping the text. The default.

PARSER_BENCHMARK · Trafilatura
IN104.6 KB html
OUT18.2 KB
DROPPED82.6%
A per-page benchmark: bytes in, clean bytes out, and the share discarded as noise — multiplied across billions of pages.
EXTRACT & ENRICH · STEP 2

Why mix in code and maths

Raw web text is mostly chatter — thin on step-by-step reasoning. Labs deliberately blend in denser sources, but the mix is a balancing act.

  • Add code, maths and books. They're a tiny slice of the web but carry the most logic and structure.
  • Keep 15–30% web text. It keeps the model's everyday language natural — and holds overfitting at bay.
  • Don't overdo it. Lean too hard on a small, specialised pile and the model re-reads it until it memorises it instead of learning the pattern.
IN PLAIN WORDS
Overfitting & epochs
One full pass over the data is an epoch. Re-read a tiny pile many times and the model memorises it — like cramming answers instead of understanding — so labs cap re-reads and keep general web text in the mix.
SET THE TRAINING MIX

Drag Maths up: its small pile gets re-read past the 1.2× limit and the bar turns red — that's overfitting.

Balanced: strong reasoning, no overfitting, and web text above 15%.

  1. 01 GATHER
  2. 02 EXTRACT & ENRICH
  3. 03 DEDUPLICATE
  4. 04 THE RECIPE
STATION 03 · DEDUPLICATE

Strip the repeats

Remove exact, near, and reworded copies so the model learns instead of memorising.

DEDUPLICATE · STEP 1

Why repeated text destroys capacity

See a sentence 100 times in training and a model stops learning it and starts memorising it — prompt the opening words and it recites the rest verbatim. Deduplication is an information-density dial.

  • Repeats over-index the weights. Attention locks onto the exact token sequence, so the model regurgitates instead of reasoning — a privacy and copyright risk.
  • Removing duplicate bytes buys diversity. In a fixed compute budget, every dropped repeat makes room for a new fact, code pattern, or argument.
  • The green gate drops copies before the weights. Unique docs pass; byte-for-byte copies are filtered out up front.
  • *Too aggressive and you clip useful repetition* — idioms, math identities, core syntax. The dial has a sweet spot.
MEMORIZATION RISK · DEDUP GATE
1 / 2
Duplicate documents (red) pour into the weight matrix; the connections stiffen into memorised, rigid paths.

Duplicate copies (red) are blocked at the green gate; only the unique documents reach the weights.

DEDUPLICATE · STEP 2

The 3-stage dedup funnel

Dedup is a balancing act: strip too little and the model memorises; strip too much and you lose useful repetition. A staged funnel gets the density up while keeping enough volume.

  • Each stage removes its slice at its own cost — exact (fast CPU), fuzzy LSH (fast hash), semantic (GPU vectors).
  • Order matters: cheap stages first, so the expensive GPU pass only sees what survived.
  • Aim for density, not maximum removal — a pristine, high-reasoning-density corpus that still retains at least half its tokens.
3-STAGE DEDUP FUNNEL

Toggle the three stages — each removes its slice; all three together hit high density while still retaining over half the volume.

OFF · Stage 1 · Exact — drops ~15% of raw boilerplate and byte-identical files. Ultra-fast CPU.OFF · Stage 2 · Fuzzy LSH — drops ~20% of near-duplicate sites via MinHash + LSH. Fast hashing.OFF · Stage 3 · SemDeDup — drops ~10% of conceptual overlap via GPU embeddings. The costly polish.

  1. 01 GATHER
  2. 02 EXTRACT & ENRICH
  3. 03 DEDUPLICATE
  4. 04 THE RECIPE
STATION 04 · THE RECIPE

Blend the recipe

Decide how much of each kind of text — and manufacture more of the dense stuff when it runs out.

THE RECIPE · STEP 1

Why the natural web mix fails

The raw web is about 82% general chatter and almost no code or math. Train on it as-is and most of the model's capacity learns to autocomplete blog posts — so labs deliberately rewrite the mix.

  • A data recipe is the exact % of tokens from each domain a model sees — not the web's natural proportions, but a blend tuned for reasoning per compute dollar.
  • Density buys reasoning. Code and maths are under 5% of the web but carry most of the multi-step logic signal, so labs upsample them hard.
  • But you can't starve general web text. Drop it below ~15% and language itself degrades — idioms, world knowledge, fluency. Web text is the regularizer that keeps the model writing like a human.
  • Four presets to try — scroll or tap them, then fine-tune the sliders.
DOMAIN MIX · NATURAL vs YOUR RECIPE

Drag the four shares (they renormalise to 100%) or scroll the presets — push code + maths past 80% and linguistic drift trips.

Balanced recipe — a Llama-3-style blend: web trimmed to ~20%, code, maths and books lifted. High reasoning, language still healthy.

THE RECIPE · STEP 2

Manufacturing more high-density text

When the human supply of dense text runs dry, labs make more — a frontier model rewrites messy web pages into clean, textbook-style prose.

  • Pick a messy seed — a rambling blog post that contains real knowledge but reads like a forum comment.
  • A teacher model rewrites it into a structured chapter: definitions, worked steps, exercises, clean code. Microsoft's Phi and Hugging Face's Cosmopedia did exactly this.
  • One seed becomes many dense tokens — the same facts at far higher educational density, for a teacher-API cost you can budget.
WEB SEED → TEACHER MODEL → TEXTBOOK
UNCURATED WEB SEED
hey guys so Dijkstra's algorithm is pretty cool for finding
shortest paths lol. basically u use a min-heap / priority queue.
heres a snippet i wrote last night hope it works
def d(g,s): ... # TODO clean this up later
SYNTHETIC TEXTBOOK · generated
Dijkstra's algorithm finds shortest paths in a weighted graph using a min-heap / priority queue. It processes the nearest unvisited vertex first, relaxing its edges, until every distance is final.

Switch Paraphrase vs Full textbook rewrite — the same seed comes back richer or thinner.

Simple paraphrase — reword the seed. Cheap, but it inherits the seed's gaps and adds little density.

THE RECIPE · STEP 3

Locking the recipe

Real and synthetic streams are clean, deduplicated, and verified. The last step blends all five into one multi-trillion-token schedule the trainer reads start to finish.

  • Five streams, one budget. Web, code, maths, synthetic textbooks, and books / Q&A — each a fixed slice of a ~15-trillion-token schedule.
  • Synthetic now stands beside human data — verified dense text earns a real share, not a footnote.
  • This is the hand-off to serialization: the locked mix goes to pre-tokenization and binary serialization — the .bin/.idx files the GPUs stream.
FINAL RECIPE · RAW WEB vs FRONTIER

Set the five shares (they renormalise to 100%) — aim for an estimated benchmark above 88 while keeping web as the language anchor.

Each slider is a stream's share of the 15T-token budget; they renormalise to 100%. Synthetic and code/maths lift the benchmark; web keeps the language grounded.

EXPLAIN IT BACK
The web is free and nearly infinite. Why spend so much engineering to shrink, clean and re-blend it instead of just training on all of it?
NEXT: PART 2 · INSIDE THE PIPELINE

You've walked the whole pipeline end to end. Part 2 opens each station up — the robots.txt and copyright rules, the code and PDF cleanup, the three dedup algorithms, and the temperature and epoch knobs that tune the recipe. Same four stations, one level deeper.

Back to the roadmapContinue to Part 2
Language: English