QuiddityML

By · 25 November 2026 · 6 min read

How ChatGPT-style assistants are trained: pretraining vs post-training

The four training stages behind a chat assistant, what changes from one to the next, why a base model needs aligning, and what older chatbots did instead.

Pretraining is the first stage of training a large language model (LLM): the model learns to predict the next token over a huge amount of general text. Post-training is the later stage that turns the resulting model into an assistant you can talk to. It mainly trains on written example answers and then on human preferences between answers. Pretraining decides what the model can do, and post-training shapes how it responds to a request.

A token is a whole word or a piece of a word, and LLMs read and write text as tokens. The examples below say "word" now and then to keep things simple.

What a model does after pretraining alone

The model you have right after pretraining is called a base model, or a pretrained model. It was trained to continue text, and nothing in that objective says to answer a question, tell the truth or refuse an unsafe request.

Give a base model the instruction "Write a haiku about the ocean." It may continue the way a web page would, with more prompts: "Write a limerick about the desert. Write a short story about a lighthouse." Its training text held plenty of pages where one instruction is followed by more instructions, so extending the list is a likely continuation.

Given "Write a haiku about the ocean.", a base model outputs more instructions as a web page would, while an aligned model writes the haiku.

A base model pointed at real requests can fail in a few recognizable ways. It may ignore the instruction and keep generating related text. It may state a false fact with full confidence, called a hallucination. It may also produce unsafe or toxic text, because its training text contained some.

Three ways a base model fails: off target (it keeps listing questions), unverified (it states a wrong year with no check) and unfiltered (nothing screens unsafe output).

Every training stage runs the same loop

After pretraining, a model can go through stages with different names: continual pretraining, fine-tuning and post-training. They sound like separate methods. Each one runs a version of the same loop: take a batch of data, compute a training signal from it, and update the weights to do better on that signal. Later stages can add real machinery on top, but the loop stays recognizable.

What usually changes from stage to stage is three settings: which data feeds the loop, which weights the loop may update, and what goal the training signal measures.

The basic loop is get data, compute a signal and update weights. A stage's name usually comes down to three settings: which data, which weights update and what goal the signal measures.

The code below runs one training function twice with different settings. The model is a small classifier rather than a language model, so it runs in a second. The first run updates every weight, as pretraining does. The second freezes everything except the last layer, called the head. Training only the head is one common way to fine-tune.

1import torch
2import torch.nn as nn
3 
4torch.manual_seed(0)
5model = nn.Sequential(nn.Linear(16, 32), nn.ReLU(), nn.Linear(32, 32), nn.ReLU(), nn.Linear(32, 4))
6 
7def train_stage(model, batches, trainable):
8    """One training loop. Only the data and the trainable weights change between stages."""
9    for p in model.parameters():
10        p.requires_grad = False
11    for p in trainable:
12        p.requires_grad = True
13    params = [p for p in model.parameters() if p.requires_grad]
14    opt = torch.optim.SGD(params, lr=0.1)
15    for x, y in batches:
16        loss = nn.functional.cross_entropy(model(x), y)
17        opt.zero_grad()
18        loss.backward()
19        opt.step()
20    return sum(p.numel() for p in params)
21 
22general_data = [(torch.randn(8, 16), torch.randint(0, 4, (8,))) for _ in range(20)]
23task_data = [(torch.randn(8, 16), torch.randint(0, 4, (8,))) for _ in range(20)]
24 
25print("pretraining-style, weights updated:", train_stage(model, general_data, list(model.parameters())))
26print("fine-tuning-style, weights updated:", train_stage(model, task_data, list(model[-1].parameters())))
1pretraining-style, weights updated: 1732
2fine-tuning-style, weights updated: 132

The loop is the same function both times. The first call trains all 1,732 weights on general data, and the second trains only the head's 132 weights on task data.

The four stages

Pretraining starts from random weights and trains every weight on as much general text as a team can gather, usually by predicting missing or upcoming text. The goal is broad language ability to build on later, not any single task.

Continual pretraining keeps close to the same objective and the same kind of general data. It starts from an already pretrained model instead of random weights, and usually keeps most weights updating. Teams run it to extend what the model has seen, such as newer web text, a specific language or a domain's general writing.

Fine-tuning changes the data and the goal. The data and the training signal now target one task or behavior. It starts from a pretrained model, and it can update every weight or freeze most of them and train only a smaller part such as a new head.

Post-training is one family of fine-tuning, aimed at turning a base model into an assistant. It usually runs in more than one round, each with its own data and goal.

The four stages compared by data, weights and goal: pretraining (general text, every weight, general ability), continual pretraining (general text, usually most weights, extend coverage), fine-tuning (task-specific, all or some, one task or behavior) and post-training (assistant-specific, most weights, match preferred responses).

What post-training adds

Post-training starts from the pretrained base and uses targeted training to shape the behavior people see. The question changes from "can the model predict language well?" to "can it respond to users the way we want?"

Pretraining at scale gives a base LLM grammar, facts, style and patterns. Post-training, a later stage on the same model, adds answering requests, following a format, refusing unsafe help and admitting uncertainty.

It has two main moves. First, supervised fine-tuning (SFT) trains the model on examples of the behavior we want: an instruction followed by a good assistant response. Then preference alignment shows the model pairs of candidate responses and pushes it toward the ones people prefer. SFT says "respond like this", and preferences say "prefer this answer over that one".

The post-training map: a base model pretrained on text, then SFT (respond like this), then preferences (prefer this over that), giving assistant behavior that answers, refuses and follows a format.

The preference step borrows a few words from reinforcement learning. The policy is the model being updated. The reward is a learned score for how much people would prefer a response. A reference model, usually the model as it was after SFT, keeps the update from drifting too far.

The names track one model through the pipeline. "Pretrained model" and "base model" name the same checkpoint after broad training. An aligned assistant is that same checkpoint after post-training.

Pretrained model and base model are two names for the same checkpoint. Post-training turns it into an aligned assistant, which is still the same LLM further down the training pipeline.

What alignment aims for

Alignment means closing the gap between a raw text predictor and an assistant people want to use. Its goal is often summed up as three properties, called the HHH criteria. Helpful means it does what the user asked. Honest means it says true things and admits when it does not know. Harmless means it refuses to produce unsafe or abusive output.

The HHH criteria: helpful (does what the user asked), honest (says true things and admits uncertainty) and harmless (avoids doing damage).

A base model may already have the raw ability for all three. Pretraining alone does not ask for any of them.

What chatbots did before LLMs

Dialogue systems existed long before LLM assistants. Earlier ones used rules, slots, retrieval and small generative models. ELIZA, an early rule-based chatbot, matched patterns in a user's message and filled hand-written reply templates. Task bots for jobs like booking a flight kept a list of required fields called slots, such as destination, date and time. They asked for each one in a fixed order until every slot was filled.

Dialogue systems before LLM assistants: rules (pattern match), slots (fill fields), retrieval (pick a reply) and generation (write new text). The old problems of reliability, safety and privacy remain.

Hand-written rules are predictable inside the cases the designer listed and brittle outside them. A user who changes topic or answers out of order gets the same question repeated.

Inside the designed flow, a booking bot moves from city to date to time to the booking API. Outside it, a change of topic matches no case and the system repeats its last question.

Retrieval chatbots search a fixed bank of stored replies and return the closest match, which keeps the output controlled until no stored reply fits. Generative chatbots write new replies token by token. That makes them more flexible and also easier to get wrong: a generated reply can be generic, wrong, unsafe or overconfident.

For "Explain my cancelled flight to my manager", a retrieval bot can only pick from stored replies, while a generative bot writes new text one token at a time. Flexibility brings generic, wrong, unsafe and overconfident replies.

Each older system bought reliability by narrowing what it could say: a pattern list, a fixed set of slots or a curated reply bank. Post-training does the opposite. It keeps a model that can say anything and trains it to choose well. The old risks stayed with it, such as private messages, too much user trust and fluent answers that should have gone to a person.

Which stage to use, and common mistakes

A common mistake is expecting a base model to answer questions. Send a base checkpoint a request, and it may continue the text instead of answering. Another is treating post-training as a cure for hallucination. Post-training shapes behavior, and the failures that come from pretraining can still show up.

The first step of post-training is covered in instruction tuning and SFT explained. Why a base model states false facts and copies its training data is covered in why LLMs hallucinate. How pretraining builds a base model in the first place is in how do LLMs work?, and the general idea of reusing a pretrained model is in fine-tuning vs transfer learning.

QuiddityML teaches the training stages, post-training and alignment as concepts in the Intro to NLP track, with exercises such as telling continual pretraining apart from fine-tuning when a team keeps training on newer general web text.