Skip to content

How LLMs Are Trained: Pretraining, Fine-Tuning, RLHF

Beginning of the lesson

How LLMs Are Trained: Pretraining, Fine-Tuning, RLHF

When you chat with a modern AI assistant, you are talking to a Large Language Model (LLM) — a very large computer program that predicts text. But that friendly, helpful assistant did not appear ready-made. It was built in three big stages, one on top of the other, over many months and at enormous cost.

In this lesson we open the factory doors and watch an LLM being made from scratch. First a "base model" learns the raw patterns of language by reading almost the entire public internet. Then it is taught to follow instructions. Finally it is polished with human feedback until it is helpful and polite. By the end you will understand exactly why AI assistants know so much, why they sometimes get things wrong, why they do not know yesterday's news, and why two different AI models can feel so different to talk to.

The one big idea: An LLM is trained in three stages — Pretraining (learn language by predicting the next word), Instruction Fine-Tuning (learn to follow requests), and RLHF (learn from human preferences to be helpful and safe). Each stage takes the model from the previous stage and improves it.

What you will learn

  • What "training" actually means and why it happens in three separate stages.
  • Stage 1 — Pretraining: how a model learns language by playing a giant "guess the next word" game, with no human labels.
  • Stage 2 — Instruction Fine-Tuning: how curated example conversations teach a base model to actually answer questions.
  • Stage 3 — RLHF: how humans ranking answers, and a "reward model", make the assistant helpful and polite.
  • What a system prompt is and how it shapes a deployed assistant's personality.
  • Why models have a knowledge cutoff and do not know recent events.
  • Why different AI models behave so differently from each other.

Continue this lesson on YourAIZone

The full lesson has the complete explanation, worked examples, common mistakes, tests with instant checking and an AI tutor. Start right away as a guest, or create an account to keep your progress.

In the full lesson

  • The complete explanation
  • Worked examples
  • Common mistakes and how to avoid them
  • Test questions: 15
  • AI tutor that answers questions about the topic
  • Progress tracking for students, parents and teachers