AI Anatomy Class · Part 2 · How machines learn
25. The student who memorized past exams
Q. An AI that aces every practice problem but fails the real test: why does that happen?
- A student who only memorizes past exams aces those, but does badly on new questions. The same thing happens to AI.
- We practice on the line lengths and ratings of 8 trucks: the training data. A simple straight line passes between the points.
- Train a very complex model for a long time, and it becomes a wiggly line through all 8 points exactly. The training loss is 0.
- But give it 7 trucks it has never seen (validation data), and it gives silly answers. It only memorized. This is overfitting.
- Plot both losses while training: the training loss keeps going down, but at some point the validation loss starts rising again.
- Stop when the validation loss is lowest, or collect more data. Doing well on new problems is called generalization.
- GPT is also checked on held-out text during training: is it really learning, or just memorizing?
Chapter summary
- Overfitting: memorizing the training data, so the training loss is low but new data goes wrong.
- Check with validation data (problems not used in training). A rising validation loss is a warning sign.
- Fixes: stop when the validation loss is lowest, or collect more data. The goal is generalization.