Basic

Overfitting and forgetting

A tuned model does two things at once: it learns the new shape and it loses the old abilities. Both are measured on data the model was not trained on, and both are the reason a run that looks good in the logs is bad in production.

What you will see

A general task to test. If the tuned model now ignores the instruction, that is forgetting, and it is a reason to train less or add variety.

About 1 min of reading

Try It

Measure the gap.

1

Two scores

train_score = 0.97; held_score = 0.61 print(train_score - held_score)

Before you run it, say out loud what it will print. Then open the answer.

What it prints
A large gap - the model memorised. A small gap means it learned the job.
2

The old ability

print('summarise this in one line: ' + doc)

Before you run it, say out loud what it will print. Then open the answer.

What it prints
A general task to test. If the tuned model now ignores the instruction, that is forgetting, and it is a reason to train less or add variety.

Data Flow

Held out data reveals both failures.
1 Score on the training set
↓
2 Score on held out examples
↓
3 Score on old general tasks
↓
4 Compare the three numbers
Line by line

Read the first example one line at a time. A line that prints shows what appears on screen; the rest set things up quietly.

train_score = 0.97; held_score = 0.61 sets nothing on screen
print(train_score - held_score) A large gap - the model memorised. A small gap means it learned the job.
Why this works
Test the old abilities

Keep a short list of general tasks and run it after every tuning job. That list is the guard against forgetting, and it is the only place that failure is visible.

Deduplicate the set

Collapse near identical inputs before training. A set with the same question twenty times is mostly noise, and removing it is what makes the loss curve smooth.

Examples

Memorising the set

Score the model on the training examples and on held out ones. A much better score on the training set means it memorised those specific strings rather than learning the job.

Losing the general

Ask the tuned model something it was good at before tuning. A model tuned on two hundred log conversions can stop following instructions it used to follow, and nothing in the training log shows it.

Fewer, better examples

A small set of varied examples generalises better than a large set of near duplicates. Duplicates are what make memorisation likely, and they are the cheapest thing to remove.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Reading the loss curve
Previous Lesson
Reading the loss curve
Next Lesson
When not to fine-tune
When not to fine-tune →