Slides · Evaluation and model adaptation

Fine-tuning data, risks and shipping

Fine-tuning data, risks and shipping

A tune that trains without errors has proved nothing yet. It has only produced a candidate.

Concept

Treat a fine-tune as a release

  • Needs what a code release needs: a baseline, tests, a canary and a rollback.
  • Where the analogy breaks: a code change mostly affects the code you touched. A tune shifts behaviour across the whole model, so regressions can appear on tasks you never meant to change.
  • That is why a regression suite exists.

Concept

Data decides most outcomes

  • Quality and diversity often matter more than volume: a few thousand clean, deduplicated examples can beat a large noisy set (this course’s judgement, not a measured rule). Start small and measure.
  • Label noise is learned as faithfully as signal.
  • Hold out a test set, and remove anything that overlaps your eval data (decontamination).
  • Match the production prompt format exactly, including the system prompt and chat template.

Diagram

Tune what you serve

Diagram: Two separate chains, going down.

Train on plain prompts

Serve with system prompt
+ chat template

Behaviour shifts: looks
worse than baseline

Train with the same
system prompt + template

Serve the same format

Behaviour transfers

Diagram summary: Two separate chains, going down. In the first, training and serving formats differ, so behaviour shifts and the tune looks worse than the baseline. In the second, training uses the exact production format, so behaviour transfers.

Diagram

Keep training data away from the exam

Diagram: Going down, examples are cleaned and deduplicated, a held-out test set is set aside, and anything overlapping the evals is removed.

Collected examples

Deduplicate and clean

Split off a held-out
test set

Eval and benchmark data

Remove training examples
that overlap the evals

Final training set

Diagram summary: Going down, examples are cleaned and deduplicated, a held-out test set is set aside, and anything overlapping the evals is removed. The model must never train on what it is later measured on.

Compare

Four risks, each with its check

RiskSymptom you would seeCheck that catches it
ForgettingWorse on general tasks you did not trainRegression suite on general abilities
OverfittingHeld-out score falls while training loss fallsHeld-out score every epoch
Safety regressionComplies with requests the base model refusedSafety evals on the tuned model itself
LeakageScores too good to be trueDecontamination plus a never-seen held-out set

Source1 Fine-tuning Aligned Language Models Compromises Safety, Even When Users Do Not Intend To!

Concept

Forgetting and its mitigations

  • The tuned model gets worse at general abilities it was not trained to keep.
  • Common mitigations: mix general data into training, lower the learning rate, use fewer epochs, use a smaller adapter.
  • InstructGPT shows one version of the idea: the authors blended pretraining-data updates into their reinforcement-learning step to reduce regressions on public NLP benchmarks.
  • Whatever you change, rerun the regression suite after every change.

Source2 Training language models to follow instructions with human feedback

Worked example

Worked example: when to stop

An illustrative run of six epochs:

EpochTraining lossHeld-out score
11.050.62
20.710.70
30.480.74
40.330.75
50.210.73
60.120.71
  • Loss falls every epoch, so loss alone says “keep going”.
  • The held-out score peaks at epoch 4 (0.75), then falls to 0.73 and 0.71.
  • Keep the epoch-4 checkpoint. A simple rule: stop when the held-out score has not improved for two epochs, and keep the best one.
  • Overfitting means memorising the training examples and generalising worse. More varied examples also help.

Concept

Safety can regress, even with benign data

  • Qi et al. (ICLR 2024; first posted 2023) fine-tuned GPT-3.5 Turbo on 10 adversarial examples at a cost of under $0.20 and reported that it then complied with nearly any harmful instruction.
  • They also report that fine-tuning on benign, commonly used datasets can weaken safety alignment too, to a lesser degree.
  • So the base model’s safety results do not carry over. Run safety evals on the tuned model itself.
  • These are the authors’ reported results.

Source1 Fine-tuning Aligned Language Models Compromises Safety, Even When Users Do Not Intend To!

Worked example

Worked example: how leakage inflates a score

Illustrative. A 500-item test set. Later you discover 200 items also appear in training, in near-identical wording.

overlap items correct=190200=95%(memorised)clean items correct=210300=70%reported score=190+210500=400500=80%honest score (clean)=210300=70%\begin{aligned} \text{overlap items correct} &= \frac{190}{200} = 95\% \quad (\text{memorised}) \\ \text{clean items correct} &= \frac{210}{300} = 70\% \\ \text{reported score} &= \frac{190 + 210}{500} = \frac{400}{500} = 80\% \\ \text{honest score (clean)} &= \frac{210}{300} = 70\% \end{aligned}
QuestionAnswer
How many points did leakage add?80−70=1080 - 70 = 10 points
Which number goes in the release decision?70 %, from the clean items
What would have prevented it?Deduplicate and decontaminate against the evals, including near-duplicates, before training

Process

Evidence to collect before shipping

  1. Beat the best baseline: base model with the best prompt, plus RAG if facts matter.
  2. Task metrics on a held-out set, with noise discipline.
  3. Regression suite on general capabilities, and safety checks.
  4. Human or judge comparison on real inputs, with the judge validated.
  5. Deploy versioned adapters (with their data and hyperparameters), canary first, rollback ready.

Diagram

The ship-or-stay gate

Diagram: Going down, a model is tuned (preference tuning is optional) and then compared with the best prompt and RAG baseline.

skip preference tuning

no

yes

Pretrained base model

SFT: prompt +
ideal response

Beats best
prompt + RAG?

Optional preference
tuning

Fix data and rerun,
or stay with baseline

Deploy adapter:
canary, rollback

Diagram summary: Going down, a model is tuned (preference tuning is optional) and then compared with the best prompt and RAG baseline. If it does not win, fix the data or keep the baseline. If it wins, deploy the adapter behind a canary with a rollback.

Worked example

Worked example: a rollback trigger that accounts for noise

Illustrative canary. Baseline adapter accuracy on one customer slice is 0.88 on 200 items. The new adapter scores 0.84 on 200 items.

SE of a difference between two scores:

SE=p1(1−p1)n+p2(1−p2)n\mathrm{SE} = \sqrt{\frac{p_1 (1 - p_1)}{n} + \frac{p_2 (1 - p_2)}{n}}n=200:0.88×0.12200+0.84×0.16200=0.035(3.5 points)n = 200: \sqrt{\frac{0.88 \times 0.12}{200} + \frac{0.84 \times 0.16}{200}} = 0.035 \quad (3.5\ \text{points})n=800:0.88×0.12800+0.84×0.16800=0.017(1.7 points)n = 800: \sqrt{\frac{0.88 \times 0.12}{800} + \frac{0.84 \times 0.16}{800}} = 0.017 \quad (1.7\ \text{points})
ReadingConclusion
A 4-point drop on 200 items0.040.035=1.15\dfrac{0.04}{0.035} = 1.15 standard errors: well within noise
The same 4-point drop on 800 items0.040.0173=2.3\dfrac{0.04}{0.0173} = 2.3 standard errors: unlikely to be chance
Safe action nowKeep the canary small and gather more items on that slice
Written rollback ruleRevert to the previous adapter if a slice drops more than 4 points on at least 800 items, or any safety check fails

Scoring both adapters on the same items (a paired comparison) usually tightens this. The rule names the slice, the size of the drop, the evidence needed and the thing to revert to.

Check yourself

Check: what is wrong with this packet?

A release packet shows: the adapter file, a held-out score of 0.91 on a set sampled at random from the same collected pool as the training examples (no deduplication), and a safety evaluation run on the base model. Name the two gaps.

Answer

First, the held-out set can contain near-copies of training examples, so 0.91 may be inflated: deduplicate and decontaminate, then split. Second, the safety evaluation must be run on the tuned model, because the base model’s results do not carry over after fine-tuning.

Check yourself

Check: the score that jumped

After adding 3,000 chats from the same customers to the training set, the held-out score rose from 0.74 to 0.97. Which risk is most likely, and what do you check first?

Answer

Leakage. A jump that large from adding data drawn from the same customers suggests the held-out items, or near-copies of them, entered training. Check for exact and near-duplicate overlap between the new training chats and the held-out set, and rebuild the held-out set from items the model has never seen.

Check yourself

Check: is this general loss acceptable?

An adapter serves one internal tool that drafts a single report type. Against the best baseline, the task score is up 0.10 (illustrative), the general-ability suite is down 0.03, and safety evals match the base model. Do you ship, and what do you still require?

Answer

It can be acceptable: the tool never exercises most general abilities, and the task gain is clear. Record the 0.03 loss as a known cost, keep the regression suite in the canary, and keep the tool’s use restricted to the report type. If users could start asking it other things, treat the loss as a risk: lower the learning rate, use fewer epochs or a smaller adapter, or mix in general data, and re-measure.

Summary

Recap

  • Data quality beats volume. Match the production format. Hold out a test set and decontaminate.
  • Four risks: forgetting, overfitting, safety regression, leakage, each with its own check.
  • Beat the best prompt plus RAG baseline before shipping.
  • Regression and safety checks, then a canary with versioned adapters and a rollback.

References

References & Sources

  1. Fine-tuning Aligned Language Models Compromises Safety, Even When Users Do Not Intend To! (opens in a new tab)

    Xiangyu Qi, Yi Zeng, Tinghao Xie, Pin-Yu Chen, et al.2024ICLR 2024Paper

    Used for Fine-tuning GPT-3.5 Turbo on 10 adversarial examples for under $0.20 broke its safety behaviour, and benign fine-tuning data can weaken safety alignment to a lesser degree.

  2. Training language models to follow instructions with human feedback (opens in a new tab)

    Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, et al.2022NeurIPS 2022Paper

    Used for InstructGPT mixed pretraining gradients into PPO updates to fix regressions on public NLP datasets.