Supervised learningexamples with answers
A line learns house prices from labeled examples, then faces houses it never saw. Text, it turns out, labels itself.
Before this
Next in How language models work
How the matrices get filled inHow language models work, stop 12 of 202 minThis opens up
Nothing yet. No lesson builds on this one so far.
Transcript
It follows the voice. Click a sentence to jump there.
A house of eighteen hundred square feet needs a price. Nobody hands you a formula, only examples: twelve houses that already sold. The size is the input. The price is the label: the correct answer. Learning a formula from labeled examples is called supervised learning.
Take a simple model, a straight line set by two weights: adjustable numbers for tilt and height. Both start out random, so this line guesses badly, even pricing bigger houses cheaper. Each miss is the gap between a guess and the real price. Averaging the twelve misses gives one score for how wrong the model is: the loss. It starts at a hundred and twenty thousand dollars.
Learning, or training, means changing the weights to push the loss down. Nudge each weight a little, whichever way lowers the loss. Measure again. Nudge again. A few hundred nudges later, the line runs through the middle of the houses, and the loss is down to twenty thousand.
The goal was never these twelve houses. It's the next one, like that eighteen hundred square foot house. The line prices it at three hundred and seventeen thousand. So the line is judged on four more sales, held back from training: the test set. The line misses them by twenty-three thousand on average, close to its training loss of twenty thousand. Doing well on unseen examples is called generalization.
A model with far more weights does better on the training houses. Its curve bends through all twelve, so its training loss drops to zero. But on the test houses, its average miss jumps to eighty thousand. It memorized the answers instead of learning that bigger houses cost more. This is overfitting, and the test set catches it.
Labels usually take work: recording each sale, tagging each photo. Text is different. The input is the text so far; the label is the next word. Every sentence on the internet labels itself. Language models mostly learn this way: billions of weights, nudged to lower the loss across trillions of words.