Making It Follow Instructions — Instruction Tuning and Preference Optimization
Chapter 8 took us as far as splitting a budget between and . What comes out of that is a machine that continues text. Feed it a question and you get the most plausible continuation.
But "plausible continuation" is not "useful answer." This chapter looks at the two stages that follow pre-training — instruction tuning and preference optimization — from the loss function's side.
Neither one is a new mechanism. Both only change where the targets are placed. Let's confirm that with equations.
1. What pre-training never made a target
Section 6 of Chapter 8 counted targets: 999 from a 1,000-token document. Every one of them asks "what is the next token?"
Not one of them asks "which answer is better?"
This is not about capability. As said since Chapter 2, what is not in the loss is not learned. The pre-training loss was this.
"Was this useful to the reader?" does not appear. So when the continuation of a question turns out to be
- another question in the same format (which is what a problem set contains)
- "…which appeared on last year's exam"
- a list of multiple-choice options
nothing has gone wrong as far as the loss is concerned. The training data really did continue that way, so as a job of fitting a distribution, it is correct.
2. Stage one: instruction tuning — same loss, different place to count
Instruction tuning (SFT, supervised fine-tuning) does exactly two things.
- Make the data pairs of ⟨instruction, response⟩
- Take the loss on the response only (do not count the instruction)
The loss itself stays the cross entropy of Chapter 4 of Part 0 — no new equation appears. What changes is where you count.
Where the gradient goes if you don't
Let the instruction be tokens and the response tokens. Taking the loss over every token leaves the response with a share of .
| instruction | response | share of the response | with masking |
|---|---|---|---|
| 200 | 50 | 20.0% | 100% |
| 500 | 20 | 3.8% | 100% |
| 1,000 | 200 | 16.7% | 100% |
| 100 | 100 | 50.0% | 100% |
For a pair with , — a common shape — counting everything sends 96.2% of the gradient into continuing the instruction text. That is pre-training again, not practice at following instructions.
Same data, same loss equation: change where you count and the content of the learning changes. That is why the instruction side is masked out.
How many targets are there
Look at the orders of magnitude. With 50,000 pairs and responses of 200 tokens on average, the target count is this.
Chapter 8's example pushed tokens (≈ the same number of targets) through pre-training. The ratio is .
3. What SFT leaves out — it never teaches an order
Cross entropy is an instruction that says "match the distribution of the responses you were shown." That is where the weakness is.
Suppose one good response and one bad response are shown for the same instruction. The frequency in the data is 1:1. Maximum likelihood obeys faithfully and settles at 0.5 / 0.5. Draw one sample and the chance of the good one is 0.5 — the same as guessing.
| draws | chance the bad one appears at least once |
|---|---|
| 1 | 50.0% |
| 3 | 87.5% |
| 5 | 96.9% |
That is turned around. SFT is imitation, so the average of what you showed comes back out. Whatever got mixed into the data comes out mixed.
There are two ways to fix it.
- Delete the bad responses from the data. But you cannot delete what you cannot articulate. Stiff phrasing, conclusion buried, answering what was not asked — every writer draws those lines differently.
- Ask only which one is better. No response has to be written out; two are put side by side and one is picked. What you get is not the text of the good response but an order.
The second is the doorway to preference optimization. The problem is how to turn an order into a loss.
4. Turning comparisons into scores — Bradley–Terry
Comparisons are all we have, so start by deciding how comparisons would come out if scores existed. Put the probability that response is preferred over as follows.
The assumption is that the difference of scores is the logit (the Bradley–Terry model). With it in place, can be fitted from comparison data by logistic regression.
The correspondence between difference and win rate is computable.
| reward gap | win rate |
|---|---|
| 0 | 50.0% |
| 0.5 | 62.2% |
| 1 | 73.1% |
| 2 | 88.1% |
| 3 | 95.3% |
| 5 | 99.3% |
It reads backwards too. A gap that makes people agree 70% of the time is ; 90% agreement is 2.197. Raising agreement moves the reward gap only slowly.
What is and is not determined about
Under this assumption the origin of is not determined: adding the same constant everywhere leaves every difference unchanged. Measured: , gives 0.710950, and adding to both still gives 0.710950.
The scale, on the other hand, matters. Doubling the gap gives 0.858149.
5. Maximizing reward alone breaks it — the second knob
Now that scores exist, maximizing them looks like the whole job. Try it and the trouble shows.
The policy that maximizes alone is the one that emits the top-reward response every time. As a distribution it collapses to a point. And was estimated from human comparisons, so it drifts to wherever the estimate is loosest. That is not searching for good responses; it is searching for holes in the reward model.
So add a second term, penalizing departure from a reference policy (the model that finished SFT).
Comments
Sign in to comment