How LLMs Are Trained and Aligned

Pretraining, instruction tuning and preference training explain what models know, why they follow instructions and where their knowledge ends.

Beginner · about 4 hours · difficulty 2/5

Learn first: Transformers and Attention, Intuitively

Modern assistant models go through several stages, and each one leaves fingerprints you will see in production.

The stages

  • Pretraining: the model predicts the next token over a huge corpus of text and code. This is where knowledge and language ability come from. It also sets a knowledge cutoff: the model knows nothing after its training data ends.
  • Supervised fine-tuning (instruction tuning): training on example conversations teaches the model to act like an assistant and follow instructions.
  • Preference training: methods such as RLHF, DPO and constitution-based approaches push the model toward answers humans or rubrics prefer: helpful, honest, harmless.
  • Reinforcement learning on verifiable tasks: newer models are also trained with rewards for correct math, passing code tests and successful tool use, which is where much of the recent progress in reasoning and agentic ability comes from.

What this means for you

  • Do not rely on the model for recent facts; give it current data (that is what RAG and tools are for).
  • The model is trained to be agreeable, so it may accept false premises in a question. Ask neutrally.
  • Refusals and safety behaviour come from alignment training; different providers make different trade-offs.
  • Base models (pretrained only) complete text rather than follow instructions; most applications want instruction-tuned models.

Good enough to move on

You can explain the difference between a base and an instruct model, what a knowledge cutoff is, and why grounding with external data is needed.

Key concepts

  • Pretraining and knowledge cutoff
  • Instruction tuning (SFT)
  • RLHF, DPO and preference training
  • RL on verifiable rewards
  • Base vs instruct models
  • Hallucination: why it happens

Mini project

Run the same five prompts against a base model and an instruct variant of the same open model family (via Hugging Face or Ollama) and document the behavioural differences.

Check yourself

A user asks your assistant about an event from last week and gets a confident but wrong answer. Which training stage explains this, and what is the engineering fix?

Free resources