Module 1: Foundations · 3 min read
How a Model Is Trained: From Pre-training to RLHF
The three stages that turn a pile of text into a conversational assistant, and why every model has a "knowledge cutoff."
How do you get from an empty neural network to an assistant that can answer politely, write code and refuse a dangerous request? Through a process with three main stages. Understanding them explains a lot of chatbots' odd behaviors.
Stage 1: Pre-training
This is the most expensive and longest stage. The model receives an enormous amount of text: websites, books, articles, code. The task is simple: predict the next token, again and again, billions of times. Every mistake slightly adjusts the weights, as we saw in the lesson on neural networks.
This stage lasts weeks or months on thousands of GPUs and costs tens to hundreds of millions of dollars for the largest models. A 2020 OpenAI study on "scaling laws" showed that performance improves predictably as you scale up the model, the data and the compute. That's the explanation for the data-center race we'll cover in the economics module.
At the end of this stage you have a base model. It knows a lot, but it's only a completion machine. Ask it "What is the capital of France?" and it may continue with "What is the capital of Germany? What is the capital of Italy?", because that's what quiz pages look like online.
Stage 2: Fine-tuning
In this stage the model is trained on carefully written examples, mostly by people: a question and a good answer next to it. The model learns the assistant format: answer the question, follow instructions, write in an organized way.
Businesses use this method too: you can fine-tune an existing model on examples from your field, such as customer-service replies in the company's style. In most cases, though, it's better to start with RAG, which is cheaper and simpler.
Stage 3: Learning from human preferences (RLHF)
RLHF stands for Reinforcement Learning from Human Feedback. The model writes several answers to the same question, and people rank which is better. From those rankings a "reward model" is trained to predict what people will prefer, and then the original model is improved so that it gets higher scores.
In the 2022 InstructGPT paper, OpenAI reported that people preferred the answers of a small model that went through this process over those of a model 100 times larger that didn't. In other words, polishing matters as much as size.
There are also variations. Anthropic, for example, developed "Constitutional AI," in which part of the feedback comes from a model that evaluates answers against a written list of principles.
A side effect: sycophancy
If a model is rewarded for answers people like, it can learn to agree with them too much. This is called sycophancy. A sycophantic model praises a weak idea or changes a correct answer when the user insists. It's worth knowing, and asking explicitly for criticism when you need it.
The knowledge cutoff
Pre-training is done on data up to a certain point in time. Whatever happened afterwards simply doesn't exist in the model's weights. So a model without search access won't know about events from last month, and may confidently report "the current state" as it was a year ago. When something depends on updates, check that the tool is connected to web search.
Bottom line: Pre-training gives a model knowledge, fine-tuning teaches it to be an assistant, and RLHF polishes its behavior according to human preferences. Each stage explains something you'll see in use: the breadth of knowledge, the format, and the tendency to please.