Explain how a base model becomes an assistant
Walk through SFT with chat templates, reward modeling, KL-regularized RLHF or DPO, and parameter-efficient variants. Explain which behaviors each stage creates and the side effects it can introduce.
Builds on: Chat templates and special tokens, Direct Preference Optimization, Reward hacking and overoptimization, LoRA: low-rank fine-tuning
What the animation says
The document-continuer
Give a base model a question, and it may not answer it. It continues the document, like a forum page, writing more questions underneath. The assistant you use behaves differently. It answers, stops, declines some requests, and keeps one tone. Two training stages produce those behaviors, and each one brings in habits nobody asked for. First question: which stage teaches the model to stop when its answer is done?
SFT: imitate the format
Stopping comes from imitation. That stage is supervised fine-tuning, or SFT. Demonstration chats are flattened into one token stream by the chat template. Cross-entropy is computed only on assistant tokens, including end-of-turn. So the model learns the format: answer, take the assistant role, follow the instruction, stop. It's pure imitation, capped by its demonstrators. It also learns to state guesses as facts, and only in this template. Tap every part of this stream that the loss trains on.
Preferences: compare, then shift
Stage two: people see two answers to one prompt and pick the better one. Comparing is easier than writing, so this can go beyond the demonstrations. Route one: a reward model learns those picks, then PPO maximizes reward, minus a penalty for drifting from the frozen SFT model. Route two, DPO, trains on the pairs directly: no reward model, no sampling. Both chase a proxy, so answers drift longer, more confident, more agreeable, and less varied. Cautious raters add over-refusal.
β at work: one worked case
Here is that penalty at work: reward, minus beta times the log-ratio. The log-ratio says how far the whole answer drifted from the SFT model. Two equally good answers, but the reward model overrates length. Long: reward two point three, log-ratio fifteen. Short: reward one point six, log-ratio two. With beta zero point one, long scores zero point eight, short one point four. Short wins. Now shrink beta to zero point zero one. Which wins?
β is the leash
Long wins, two point one five against one point five eight. The penalty became too small to matter. Beta is the leash to the SFT model. Small beta lets the policy drift to wherever the reward model is fooled. Large beta keeps it near SFT, so the proxy's errors can't be pushed as far. Each stage inherits its signal's flaws. SFT copies confident guessing. Preference training exaggerates whatever the proxy rewards.
LoRA: cheap, but narrow
One cheap tool fits either stage: LoRA. Freeze the big weight matrix. Train two thin matrices whose product is added to it. Their shared inner width, the rank, is tiny: here eight against four thousand ninety-six. So training is cheap and adapters swap in and out. But a low-rank update limits how far behavior can move. Tap every matrix that training updates.
Two stages: imitate, then prefer
What each stage smuggles in
The objectives, stage by stage
How β decides whether length wins
Remember this
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.
Bytewise
All courses