The problem: specialising also means damaging
You have a generalist model that does many things adequately: it answers politely, it solves maths problems, it writes code, it refuses dangerous requests. You want it to excel at one specific task, calling your application's tools correctly, say. You gather a few thousand examples of that task and run a supervised fine-tuning pass (almost always shortened to SFT): you show it questions and correct answers, and it learns to reproduce them. That is the method taught in Instruction Tuning.
It works. The model gets much better at your task. And it gets worse at everything else.
Here is the measurement published by the SDFT authors, on Llama-2-7b-chat fine-tuned on a tool-calling dataset (OpenFunctions). Three columns: the target task, then two capabilities nobody touched, maths (GSM8K, grade-school arithmetic word problems) and code (HumanEval). Higher is better.
| Model | OpenFunctions (the target) | GSM8K (maths) | HumanEval (code) |
|---|---|---|---|
| Starting model, before any fine-tuning | 19.6 | 29.4 | 13.4 |
| After ordinary fine-tuning | 34.8 | 21.5 | 9.8 |
The target improves by half. Maths loses almost eight points and code almost four, without a single maths or code example ever being shown to the model. This is catastrophic forgetting, the same phenomenon described in Continual Pre-Training: nothing in the training objective defends the old knowledge, so nothing protects it.
The awkward part is not losing a few points of arithmetic. It is that the same fine-tuning also degrades safety refusals and the general quality of answers, on training data that is entirely innocuous. Fine-tuning on maths problems is enough to lower the refusal rate on dangerous requests. We return to this below, with numbers.
SDFT's hypothesis: the culprit is the gap in style
SDFT stands for Self-Distillation Fine-Tuning. It was published in February 2024 by a team from Zhejiang University, Sea AI Lab and Tencent.
Its starting point is a hypothesis, and the hypothesis is the thing to understand: if fine-tuning damages the model, it is because of the gap between the way the dataset is written and the way the model itself writes. The authors call this the distribution gap.
A concrete example. Your dataset holds a question and its reference answer, written by a human or pulled from a file:
Question: what is the balance after three payments of 40 euros? Reference answer: 120
The model, left to itself, would have written: "Of course! Three payments of 40 euros come to 3 × 40 = 120 euros. The balance is therefore 120 euros."
Both answers say the same thing. But training does not compare meanings, it compares words. To reproduce a bare "120", the model has to unlearn its habit of greeting, explaining and concluding. And those habits are exactly the ones carrying its politeness, its step-by-step arithmetic, and its refusals.
A graft is rejected when the tissue is too foreign to the body. Ordinary fine-tuning grafts tissue from elsewhere, and the reaction spreads through the whole organism. SDFT builds the graft from the patient's own tissue, same content, but recognised as native.
The trick: have the model rewrite the answer key itself
The remedy fits in one sentence: before training the model on the dataset, ask the model to rewrite it.
For each example, you hand the model the question and the reference answer, and ask it to write its own answer using that reference as a guide. Out comes an answer that says the same thing in the model's own words, structure and habits. That is the version used for training, the original answer is discarded.
The prompt the authors use is deliberately plain, and it is the same regardless of the task:
Below are an instruction that describes a task along with a reference answer.
Using the reference answer as a guide, write your own response.
### Instruction:
[the example's question]
### Reference Answer:
[the original answer from the dataset]
### Response:
A model asked to rewrite an answer can rewrite it wrong. So the authors add an elementary check: on tasks where the result can be extracted (an arithmetic problem, for instance) they pull the final answer out of the rewritten text and compare it with the original. If the two disagree, the rewrite is thrown away and the original answer is kept. Without that filter, the method would teach the model its own mistakes.
What the formula says, in one line
The training objective is untouched. It is the same formula as ordinary SFT, with a single symbol changed:
Symbol by symbol:
- is the loss, the number training tries to drive down; (theta) denotes the model weights, the only things that move.
- is the model itself: the function that, given a text, returns the probability of what comes next.
- is the general instruction, the example's question.
- (y tilde prime) is the answer rewritten by the model and then filtered. That is the only change: ordinary SFT would put here, the original answer.
- The minus sign and the logarithm are the usual convention: maximising a probability is the same as minimising the negative of its logarithm.
In one sentence: you train exactly as before, but on an answer key the model wrote for itself. Nothing changes in the training code, which is why the authors call the method plug-and-play, you bolt a rewriting pass onto the front, and that is all.
Yang et al. (2024), Self-Distillation Bridges Distribution Gap in Language Model Fine-Tuning (SDFT)What is learned, what is merely manufactured
One distinction worth holding onto, because the word "distillation" misleads here.
| Element | Role | Status |
|---|---|---|
| The model weights | what gets improved | learned, they change during fine-tuning |
| The rewriting of the examples | building the dataset | produced once, before training, then frozen in a file |
| The model doing the rewriting | source of the style | it is the starting model itself, in its initial state |
That last point is what sets SDFT apart from everything else: there is no stronger teacher. The model is its own teacher, hence self-distillation. Where classical distillation transfers knowledge from a large model to a small one, SDFT transfers no knowledge at all: it merely translates a dataset into the model's own idiom.
What it changes, in numbers
Here is the opening table again, with a third row:
| Model | OpenFunctions (the target) | GSM8K (maths) | HumanEval (code) |
|---|---|---|---|
| Starting model | 19.6 | 29.4 | 13.4 |
| After ordinary fine-tuning | 34.8 | 21.5 | 9.8 |
| After SDFT | 36.6 | 29.1 | 15.2 |
Two things, and the second is the surprising one.
The forgetting nearly vanishes. Maths comes back to 29.1 against 29.4 at the start, a negligible gap, where ordinary fine-tuning had pushed it down to 21.5. Code even edges above its starting point.
The target task is learned better, not worse. 36.6 against 34.8. That runs against intuition: you would expect to pay for preserving the rest with weaker specialisation. Not here. The authors' proposed explanation is that a model absorbs a phrasing that is already familiar to it more easily than a foreign one.
These are results from one team, on one 7-billion-parameter model, with LoRA and roughly 2,000 examples per dataset. The authors flag that limitation themselves in their conclusion. They did check that the effect survives full fine-tuning and holds on Llama-3, but nobody has established that the gain carries to every scale and every task. Keep the mechanism and the direction of the result, not the decimals.
The effect on safety, which is the most striking part
This is the result most worth knowing for anyone drafting or reading contracts about fine-tuned models.
After ordinary fine-tuning on GSM8K (a set of maths problems, about as harmless as data gets) the authors measure, on the starting model and then on the fine-tuned one:
| Measure | Starting model | After ordinary fine-tuning |
|---|---|---|
| Refusal rate on dangerous requests | 99.8 | 82.1 |
| Same, on requests disguised to defeat the refusal | 88.9 | 54.8 |
| General answer quality (AlpacaEval) | 66.0 | 23.4 |
The third row deserves a word: AlpacaEval pits the model's answers against a reference model's and has a judge model decide the winner, the mechanism, and its biases, are covered in LLM as a Judge. A score of 66 means the model wins two comparisons out of three. After fine-tuning on maths problems, it wins one in four.
The second row points to the circumvention techniques described in Adversarial Attacks: the dangerous request is dressed up in a form that slips past the refusal. It used to get through 11% of the time; after fine-tuning, it gets through 45% of the time.
With SDFT, the authors measure a recovery of about 5 points on the first rate and 11 on the second relative to ordinary fine-tuning, and general quality back at the starting model's level (66.7 against 66.0). Across three general instruction datasets (Alpaca, Dolly, LIMA), the drop falls from roughly 20 points per measure to under 10.
A vendor may have aligned its model with great care; a customer who fine-tunes it on their own data, however innocuous, undoes part of that alignment without intending to and without seeing it happen. This is not an attack, it is a mechanical side effect. It bears directly on liability clauses and on the terms of use of open-weight models: who answers for the behaviour of a model fine-tuned by a third party? And it argues for re-testing safety after any fine-tuning, as recommended in Post-Fine-Tuning Evaluation.
The indirect demonstration: the wider the gap, the worse the forgetting
A hypothesis is worth only as much as the test behind it. So the authors set out to show that it really is the gap in style that causes the forgetting, and not something else.
They measure that gap four ways, comparing the texts written by the fine-tuned model with those of the starting model: three measures of textual and semantic similarity, plus one measure of how far the weights themselves have travelled. Then they deliberately vary how wide the gap is, in two ways:
- By increasing the number of training examples. The more there are, the further the weights move, the less the texts resemble the originals, and the lower the scores fall, in maths and in safety alike.
- By blending the two methods. They define a mix ratio, the share of rewritten answers: 0 is ordinary fine-tuning, 1 is pure SDFT. As that share rises, the measured gap narrows and every score climbs back, steadily.
The second knob is the more convincing one: it is a continuous dial between the two methods, and the two curves (gap in style and forgetting) move together. That is not causality in the strict sense, but it is exactly the behaviour you would expect if the hypothesis were right.
Where SDFT sits among the known remedies
Catastrophic forgetting has several countermeasures, covered elsewhere in this course. They do not exclude one another.
| Remedy | The principle | What it costs |
|---|---|---|
| LoRA and other low-parameter methods | change only a small part of the model | limits the damage, does not remove it, the SDFT experiments are run with LoRA, and the forgetting is still there |
| Replay | mix general data back into the training set | you need that data, and it inflates the budget |
| Model merging | fine-tune separately, then average with the original model | one more step, and a result that is hard to predict |
| SDFT | rewrite the dataset in the model's own idiom | one generation pass before training, plus a verification filter |
| On-policy distillation | let the student write and correct every word | you need a stronger teacher, running at every step |
That last row calls for a comparison, because the two methods look alike from a distance and differ completely up close.
Both start from the same observation, a model learns badly from text that is not its own. But:
- SDFT needs no second model. The model rewrites its own dataset, once, before training. It is cheap and it bolts onto any existing recipe.
- On-policy distillation requires a stronger teacher, which must read every one of the student's outputs at every training step. It is far more expensive, and in exchange it can push the student beyond where it started.
SDFT does not make the model smarter: it stops the model from being damaged while you specialise it.
Why it matters
It is a remedy that costs almost nothing. No teacher to rent, no architecture to change, no new loss function: one generation pass over a few thousand examples, a filter, and the same training as before. That ratio between the modesty of the gesture and the size of the effect is what made the paper notable.
It moves the problem from the model to the data. The prevailing intuition was that forgetting had to be fought by constraining training, freezing weights, adding a penalty term, mixing in old data. SDFT shows it can be fought upstream instead, by reshaping the corpus so it resembles the model. That shift in perspective is reusable elsewhere.
It documents a concrete legal risk. The fact that fine-tuning on innocuous data measurably degrades a model's safety refusals is an established, published result with numbers attached. For anyone drafting open-weight licences, use clauses or compliance analyses, that is a foothold: a model's alignment is not a stable property of the delivered object, it decays as soon as a third party specialises it.
Key points
- The problem: fine-tuning a model on a task improves that task and damages the rest (maths, code, politeness and above all safety refusals) even with entirely innocuous training data.
- The hypothesis: the culprit is the distribution gap, the distance between the way the dataset is written and the way the model writes on its own.
- The trick: have the model rewrite each reference answer itself in its own words, filter out rewrites that change the result, then run ordinary fine-tuning on the rewritten corpus. Nothing else changes.
- The measured result (Llama-2-7b-chat, LoRA, ~2,000 examples): forgetting nearly disappears (29.1 on maths against 29.4 before fine-tuning, instead of 21.5) and the target task is learned better than with ordinary fine-tuning (36.6 against 34.8).
- Safety: ordinary fine-tuning on maths problems takes the refusal rate from 99.8 to 82.1, and from 88.9 to 54.8 against disguised requests; SDFT wins back about 5 and 11 points.
- The distinction to hold: SDFT needs no stronger model, it is self-distillation, a translation of the corpus rather than a transfer of knowledge. It protects what exists; it does not push the model beyond itself.
1. According to the SDFT authors, why does fine-tuning on maths problems degrade a model's safety refusals?
2. What exactly is the step SDFT adds to an ordinary supervised fine-tuning run?
3. Why do the authors add a filter comparing the rewritten answer with the original before accepting it?
4. What separates SDFT from on-policy distillation, given that both start from the same observation?
5. How do the authors support the claim that the gap in style, rather than something else, is what causes the forgetting?