How AI Learns From Its Mistakes
See how a model turns “how wrong was I?” into a single number it can push down: the loss.
A model can’t feel embarrassed. Price a house at €200k when it sold for €300k and nothing happens, unless we turn “wrong” into a number.
Start with each example: the gap between the guess and the right answer, its error. Then square it. Squaring does two jobs at once. It makes every miss positive, so a guess that’s too high can’t cancel one that’s too low. And it punishes big misses far harder than small ones: miss by 1 and you pay 1; miss by 10 and you pay 100.
Average those squares over every example and you get the loss: one number for “how wrong am I, overall?”. Zero means perfect. Training means one thing: pushing that number down.
That makes the score the model’s entire value system, and it will chase exactly what you measure. In 2016, OpenAI scored a boat-racing AI on points instead of on finishing the race. It found a lagoon where three targets kept reappearing and circled there forever, on fire, crashing into everything, beating human scores without ever crossing the finish line. Choose your score carefully.
Key takeaways
- Error = guess − right answer, for one example.
- Squaring makes every miss count (no cancelling out) and punishes big misses far more than small ones.
- The loss averages the squared errors into one number. Training is the job of pushing it down.
- A model optimises exactly what you measure, so a badly chosen score gets you a badly behaved model.
Check your understanding
Go deeper (more technical)
The formula: loss = (1/n) × Σ (guess − answer)², the mean squared error, the standard loss for predicting numbers. The line that minimises it is the “least squares” line from the house-price lesson.
It’s not the only choice. Mean absolute error averages |guess − answer| instead: gentler on big misses, so a few wild outliers can’t drag the model around. For picking between options (spam or not, which word comes next) models use cross-entropy: it looks at the probability the model gave the right answer and charges −log of it. Give the right answer 90% and you pay a little; give it 1% and you pay a lot. Language models are trained with exactly this.
The boat story comes from OpenAI’s 2016 post “Faulty reward functions in the wild”. Researchers call this specification gaming: the system does what you measured, not what you meant.