xavier-ramirez.com

The life of an LLM

The model you chat with is the last step of a six-stage assembly line. Here is each stage — what actually happens, the tools and hardware labs use, and where the money goes.

THE PIPELINE
01Gather data02Clean & tokenize03Pretrain04Fine-tune & align05Evaluate06Host / serve

Step through the pipeline. Each stage shows a real before → after, plus what the lab does, the tools, the hardware, and the spend.

STAGE 01 / 06

Gather data

Assemble a massive, mostly-text corpus.

BEFORE
The open web, books, Wikipedia, GitHub, licensed archives
AFTER
~10–15 trillion tokens of raw text (FineWeb, The Stack, …)
WHAT THE LAB DOES

Crawl, license and pool sources; strike data deals; fight the quality and legal battles. Increasingly the hardest, most contested stage.

TOOLS

Common Crawl, web crawlers, dataset pipelines (FineWeb, RedPajama, The Stack).

HARDWARE

Large CPU clusters + petabytes of storage. Little or no GPU yet.

WHERE THE MONEY GOES

Storage, bandwidth, and data licensing — deals can run into the tens or hundreds of millions. Compute here is minor.

STAGE 02 / 06

Clean & tokenize

Filter the junk, then cut text into tokens.

BEFORE
<div>BUY NOW!!!</div> · the cat sat on the mat · the cat sat on the mat
AFTER
the cat sat on the mat
WHAT THE LAB DOES

Quality-filter (dedupe, drop spam, boilerplate and PII), then train a BPE tokenizer and encode the whole corpus to integer IDs.

TOOLS

Dedup (MinHash), quality classifiers; tokenizers (tiktoken, SentencePiece, HF tokenizers).

HARDWARE

CPU-heavy and distributed (Spark / Ray). GPU optional.

WHERE THE MONEY GOES

Mostly engineer time and CPU compute — cheap next to training, but it decides the final quality.

STAGE 03 / 06

Pretrain

Predict the next token, trillions of times.

BEFORE
context — the cat sat on the ___
AFTER
mat
71%
floor
13%
dog
8%
the
5%
sat
3%
WHAT THE LAB DOES

Launch the big training run for weeks to months; babysit loss curves, restarts and instabilities. The output is the base model.

TOOLS

PyTorch / JAX, Megatron / DeepSpeed / FSDP, distributed schedulers, experiment tracking.

HARDWARE

Thousands to tens of thousands of H100 / TPU accelerators on fast interconnect (InfiniBand / NVLink).

WHERE THE MONEY GOES

The megabill: a frontier run is often $10M–$100M+ in GPU-time. This dominates the entire budget.

STAGE 04 / 06

Fine-tune & align

Turn a text-completer into a helpful assistant.

BEFORE
base model → "How do I sort a list? How do I reverse a list? How do I…"
AFTER
aligned → "Use sorted(xs), or xs.sort() to sort in place. Example: …"
WHAT THE LAB DOES

Instruction-tune on curated examples, then RLHF / DPO on human preference data; red-team for safety.

TOOLS

SFT + RLHF / DPO (e.g. TRL), reward models, human annotation platforms.

HARDWARE

Tens to hundreds of GPUs — far less than pretraining — plus a large human labeling workforce.

WHERE THE MONEY GOES

Compute is modest; the spend shifts to people — annotators, domain experts, red-teamers. Quality beats quantity.

STAGE 05 / 06

Evaluate

Prove it works — and doesn't misbehave.

BEFORE
candidate model + benchmark & safety suites
AFTER
MMLU 86% · HumanEval 74% · safety ✓ → go / no-go
WHAT THE LAB DOES

Run public and private benchmarks, capability and safety evals, regression tests; sometimes external audits before release.

TOOLS

Eval harnesses (lm-eval-harness), private eval sets, LLM-as-judge, red-team suites.

HARDWARE

Modest inference GPUs — mostly running the model across test sets.

WHERE THE MONEY GOES

Little compute; the cost is eval design, private test sets, and human review time.

STAGE 06 / 06

Host / serve

Make the weights answer requests.

BEFORE
the final weights — a big folder of tensors
AFTER
an API endpoint — or a file you run locally with Ollama
WHAT THE LAB DOES

Deploy on inference infra with batching, quantization and autoscaling behind an API — or publish open weights for others to self-host.

TOOLS

Serving: vLLM, TGI, TensorRT-LLM. Local: Ollama, llama.cpp. Quantization: GGUF, AWQ.

HARDWARE

Fleets of inference GPUs (A100 / H100 / L40S) for an API; a single consumer GPU or a laptop for a quantized local model.

WHERE THE MONEY GOES

Ongoing and usage-based: GPU-hours per million tokens. Closed = rent forever; open weights self-hosted = pay only your own hardware.

EXPLAIN IT BACK
Pretraining costs 10–100× more than fine-tuning, yet fine-tuning is what makes a chatbot feel smart. Why spend the fortune on pretraining at all?
Back to the roadmapTokens