How it works · 18 of 37 Core

How is a chatbot built: pretraining, fine-tuning and alignment?

How a chatbot is built

Pretraining → fine-tuning → alignment: A chatbot is built in stages: read the internet to learn language (pretraining), practise example tasks (fine-tuning), then learn from human or AI preferences which answers are better (alignment, e.g. RLHF).

Loading the animation…

Say it like this A chatbot is built in three stages: pretraining teaches it language, fine-tuning teaches it to answer, and alignment teaches it which answers people prefer, and which requests to refuse.

Under the hood — for builders
Before and after, a real example
With Floor 1 only, the model carries on the text. With all three floors, it does what was asked.
Floor 1: how much it reads
Floor 1 is reading a vast amount of text, and the amount keeps growing.
Floors 2 and 3: the three steps
People teach by example, then by judging; then a scoring model takes over the judging.
Did it work?
Yes: people preferred its answers, and it made things up half as often.
Floors 2 and 3 are cheap
Almost all the computing goes into Floor 1.
How it's done today
Labs often change Floor 3: train straight on the preferred answers, skipping the practice step (DPO, used for Llama 3), or let an AI judge against written rules (Constitutional AI).
Watch out
It learns the taste of the people who ranked the answers, not everyone's.
Sources
Ouyang et al. (OpenAI), Training language models to follow instructions with human feedback, 2022 (arXiv 2203.02155) · Brown et al. (OpenAI), Language Models are Few-Shot Learners, 2020 (arXiv 2005.14165) · Llama Team, Meta, The Llama 3 Herd of Models, 2024 (arXiv 2407.21783) · Bai et al. (Anthropic), Constitutional AI: Harmlessness from AI Feedback, 2022 (arXiv 2212.08073).

What happens in the pretraining, fine-tuning and alignment animation, step by step?

  1. Floor 1, pretraining: it reads a huge library, trillions of words, and learns to guess the next word.
  2. Asked a question, it just carries on the pattern, like a parrot. Not helpful yet.
  3. Floor 2, fine-tuning: it practises on example questions answered by people.
  4. Now it answers. But some requests it should refuse.
  5. Floor 3. Your turn: you are the judge. Tap the better answer.
  6. Alignment: thousands of choices like yours teach it which answers people prefer, and when to say no.
  7. The parrot is now an assistant: it knows language, follows instructions and prefers safe, helpful answers.

What everyday example explains pretraining, fine-tuning and alignment?

School → job training → feedback from a manager.

Why should a team care about pretraining, fine-tuning and alignment?

Where a chatbot's helpfulness and safety come from.