Back
LLMs

How An LLM Is Actually Built: The Five Stages Nobody Copies

The transformer is not the moat. A modern LLM is built in five stages: pretraining, data curation, scaling-law planning, post-training alignment, and evaluation on efficient systems. Here is what each stage does and where the real work lives.

6 min read
Updated Aug 18, 2026
QUICK ANSWER

Ask most people how a model like Claude or GPT-5 is built and they say transformers.

Key Takeaways
  • This guide provides comprehensive, actionable information
  • Consider your specific workflow needs when evaluating options
  • Explore our curated LLMs tools for specific recommendations

The architecture is not the secret

Ask most people how a model like Claude or GPT-5 is built and they say transformers. The transformer is important, but it is also published, standardised, and used by every major lab. If architecture were the moat, the field would be much flatter than it is. The real differences live in the five stages that surround the architecture.

This matters because a lot of effort is spent on the least differentiating part. Two labs with the same architecture produce wildly different models because data, scaling, alignment, evaluation, and systems are not shared. The architecture is one paragraph of stage one. The other four stages are where models are won and lost.

5
stages that matter
1
of them is architecture
20–150×
tokens per parameter, depending on goal

Stage 1: Pretraining

The objective is simple: predict the next token. Given a sequence, the model learns the probability distribution of what comes next. Do this over enough text and it absorbs grammar, facts, reasoning patterns, and a surprising amount of world knowledge.

Before training, text is broken into tokens using Byte-Pair Encoding. The tokenizer shapes everything downstream: vocabulary size, sequence length, how efficiently the model reads different languages, even how it handles code. A poor tokenizer is a permanent handicap.

The architecture inside this stage is almost always a transformer decoder. The point is not that it is unimportant; the point is that it is the same starting line for everyone. You do not win here.

Stage 2: Data

If architecture is the least guarded part, data is the most guarded. The pipeline starts with raw web crawl and turns it into something a model can learn from. That transformation is a multi-step filter: extract text from HTML, remove unsafe or low-quality content, deduplicate by URL and document, filter by length and language, classify quality, and reweight domains.

Quality beats quantity, but scale still matters. Closed datasets are measured in trillions of tokens. LLaMA 3 trained on 15 trillion tokens; GPT-4 is estimated around 13 trillion. The exact composition, the cleaning rules, and the quality classifiers are treated as competitive secrets because they are.

This is the stage that most changes the character of the finished model. A model trained mostly on code behaves differently from one trained mostly on books, and neither behaves like one trained mostly on forum posts. Data is not a commodity.

Stage 3: Scaling laws

Given a compute budget, should you train a bigger model or train a smaller model on more data? Scaling laws give a predictable answer. Performance improves reliably with more parameters and more tokens, and you can estimate the tradeoff before spending the money.

The Chinchilla result points to roughly 20 tokens per parameter for training-cost-optimal pretraining. Once inference cost is included, the practical ratio rises past 150 tokens per parameter. You train a smaller model on far more data because you will pay to run it many times.

The lesson is to avoid clever shortcuts. Do the simple things and scale them. Labs tune hyperparameters on small models, read the slope, then extrapolate to the one large final run.

Stage 4: Post-training

After pretraining you have a powerful text-completer, not a useful assistant. Ask it a question and it might answer with three more questions, because that is a plausible continuation. Post-training turns completion into conversation.

Supervised Fine-Tuning shows the model thousands of prompt-and-response pairs. It learns the shape of a useful answer. This was the step that turned GPT-3 into ChatGPT. It needs surprisingly little data because it is teaching format, not knowledge.

RLHF, or reinforcement learning from human feedback, aligns the model with preference. The model generates multiple answers, humans rank them, and a reward model trains the LLM to produce the preferred kind of answer. DPO does something comparable with plain supervised learning and has become common in open-source pipelines.

Stage 5: Evaluation and systems

Two things wrap the whole pipeline. Evaluation asks whether the model is good, and systems ask whether you can train and serve it at all.

No single benchmark captures a modern LLM. MMLU measures broad knowledge, Chatbot Arena measures blind human preference through an Elo leaderboard, and AlpacaEval uses an LLM to judge answers. The same model can score very differently depending on prompt format, so numbers on a card are not the whole story.

Systems make training possible: low-precision arithmetic, FlashAttention for faster attention, data and model parallelism, and Mixture of Experts for more parameters at the same active compute. Compute is the bottleneck everyone shares.

Mistakes that sink LLM projects

Obsessing over architecture. It is the most copied, least differentiating part of the stack. The difference between two labs with the same architecture is never the architecture.

Treating data as a commodity. Dirty data caps your ceiling regardless of compute. The cleaning rules are not a formality; they are a large fraction of the work.

Ignoring inference cost at training time. A model too big for its data wastes compute and runs slowly forever. The right size is a function of how many times you will run inference, not just how well it trains.

Stopping at SFT. A fine-tuned model imitates the format of an answer. Without preference alignment it never learns what people actually prefer.

Which stage to fix

IfYour model knows facts but gives confused answers
Look at post-training. SFT teaches format; preference alignment teaches quality. The knowledge is already there.
IfYour model is slow or expensive to run
Look at systems and scaling. Smaller model, more tokens, better quantization, and a faster inference engine. The weights may be fine; the serving may not be.
IfYour model repeats garbage or misses obvious truths
Look at data. Deduping, filtering, and domain reweighting usually beat architectural changes for this failure mode.
IfYou are comparing two models on a leaderboard
Check the prompt format. The same model can move tens of points depending on how the question is asked. Leaderboards are useful, not final.

The summary worth keeping is that a great model is engineered, not trained once. Language modeling, clean data, optimal scaling, alignment, and honest evaluation on efficient systems. Five stages. The transformer is one paragraph of one of them.

For what comes after training, read the companion guides on how to run AI models locally, hardware for local models, and inference engines compared.

FREQUENTLY ASKED QUESTIONS
How is a large language model actually built from scratch?
Ask most people how a model like Claude or GPT-5 is built and they say transformers.
EXPLORE TOOLS

Ready to try AI tools? Explore our curated directory:

SHARE THIS GUIDE

Ask most people how a model like Claude or GPT-5 is built and they say transformers.

Share on X LinkedIn Reddit Email
Copied to clipboard