Lesson 54 · 2 min

Overfitting: learning the answers, missing the lesson

A model overfits when it memorises its training examples so closely that it fails on anything new.

The goal of training is to learn general patterns. A model that spots cats should recognise a cat it has never seen, in a new pose, under new light.

Sometimes a model clings to details of its training set instead. Maybe every cat photo it saw was taken indoors, so it decides that sofas mean cat. It scores perfectly on those photos and stumbles on real ones.

Builders guard against this by testing on data the model never saw during training, adding more varied examples, and stopping training before the model starts memorising.

It also explains why a model can ace a well-known test and still struggle on your own tasks. Strong scores on familiar questions do not prove it will handle unfamiliar ones.

Do it now

Test with something new

  1. 1. Ask a chatbot a classic puzzle it has surely seen, such as a famous riddle.
  2. 2. Then ask a version with one detail changed, using the prompt below as a pattern.
  3. 3. Check whether it answers the new question or repeats the famous answer.
A farmer needs to cross a river with a goat. The boat holds the farmer and two animals, and there is nothing else to carry. What is the fewest number of trips? Explain briefly.

Quick check

A model gets 100% on its training photos but fails on new ones. What is this called?

A model gets 100% on its training photos but fails on new ones. What is this called?

More on this

Words from this lesson

Overfitting
When a model memorises its training examples so closely that it does badly on new ones it has not seen.
Training data
The examples, such as text, images or recordings, that a model learns its patterns from.
Machine learning
Teaching computers by showing them many examples so they find the patterns themselves, instead of being given every rule.