How an LLM is made: pre-training, fine-tuning and alignment
A chatbot like Claude, ChatGPT or Gemini is built in stages. Each stage changes what the model is and how it behaves.
Stage 1: Pre-training, learning the world from text
The model reads an enormous corpus (web pages, books, code, scientific papers, often trillions of tokens) and learns one task: predict the next token. To do that well across everything humans write, it has to pick up grammar, facts, reasoning patterns, coding conventions and styles of argument.
- This is self-supervised: the text supplies its own answers.
- It uses the overwhelming majority of the compute, often months on tens of thousands of chips.
- The result is a base model: knowledgeable but not an assistant. Ask it a question and it may continue with more questions, because that's what text on the web often does.
- Its knowledge stops at a training cutoff date.
Stage 2: Supervised fine-tuning, learning to be an assistant
The base model is trained further on curated examples of good conversations: a user request and an ideal response, written or reviewed by people. It learns the format and tone of a helpful assistant: answer the question, follow instructions, say when it doesn't know.
Stage 3: Preference training, learning what "good" means
Many qualities (helpful, honest, harmless, well-written) are easier to judge than to write down. So:
- RLHF (reinforcement learning from human feedback): people compare pairs of model responses and pick the better one. A reward model learns to predict those preferences, and reinforcement learning then tunes the assistant to produce responses the reward model rates highly.
- AI feedback and written principles: some labs use AI models, guided by a written set of principles, to generate much of the feedback. Anthropic calls its version Constitutional AI.
- Direct preference optimization (DPO) and similar methods learn from preference pairs without a separate reward model.
This is also where safety training happens: refusing clearly harmful requests, resisting manipulation, avoiding dangerous assistance.
Stage 4: Reinforcement learning for reasoning
Since 2024, labs have trained reasoning models that produce a long internal chain of thought before answering. They are trained with reinforcement learning on problems whose answers can be checked automatically (math, coding, logic puzzles), rewarding correct final answers. The models learn to plan, try approaches, notice mistakes and backtrack. Spending more computation at answer time ("thinking longer") improves results on hard problems. This is called test-time compute scaling.
Stage 5: Evaluation and release
Before release, models are tested on benchmarks, red-teamed for misuse and dangerous capabilities, and often evaluated by outside groups. Labs publish model cards or system cards describing capabilities, limits and safety testing.
What the model is, and isn't
At the end, the model is a very large set of numbers (weights) that turns text into a probability distribution over next tokens. It has no database of facts it looks up and no live internet access unless it is given tools. Its "knowledge" is compressed into the weights, which is why it can be brilliant and wrong in the same sentence.
Check your understanding
In RLHF, what does the reward model learn?
Which stage uses the vast majority of training compute?