Module 0 · Lesson 1 of 10
What a model is: learned from examples
A model learns from examples
Training adjusts a model's numbers using marked examples, also called labelled data, and a test on new examples shows whether it learned.
Scene 1 of 5 · Examples, not rules
A spam filter starts from 10,000 emails, each one marked spam or not spam by a person.
- Marked examples — healthy — 10,000 marked emails
- Training — healthy
- The model — healthy
- Your app — healthy
- Examples, not rules. A spam filter starts from 10,000 emails, each one marked spam or not spam by a person.
- Nudge the numbers. Training compares each guess with its mark and shifts the model's numbers towards the right answer.
- Test on new emails. Scored on fresh emails, it is right 96 times in 100, close to its 99 on old ones.
- Memorising is not learning. A model that memorised its examples scores 100 on them but 71 on new ones.
- Inference: use it. Your app sends a new email and gets a label back, and the numbers no longer change.
- Now you try. Pick a task, and see whether it suits plain code or a trained model. For example: Plain code. The rule is known and must be exact every time, so a guess that is usually right is not good enough.
Scene 1 of 5: Examples, not rules. A spam filter starts from 10,000 emails, each one marked spam or not spam by a person.
Key points
- A model's rules come from examples, not from a person writing them.
- Training nudges its numbers until its guesses match the marked answers.
- Only a score on unseen examples shows that it learned.
- Your app runs the finished model; its numbers stay fixed while it answers.
Most software follows rules a person wrote, such as "orders over $50 ship free". A (Building software that learns patterns from examples, instead of following rules a person wrote.) model is different: nobody writes its rules. It learns patterns from many examples.
(The long, costly process in which a model learns from data. It happens before the model is used, not during each request.) shows the model examples, such as emails a person marked as spam or not spam. Examples marked like this are called labelled data. It compares its guesses with the marked answers, and adjusts its internal numbers, called (One of the numbers inside a model that training adjusts. Large language models have billions of them.), so the next guesses are a little better.
Training is slow and costly, and it happens before anyone uses the model. Using the finished model to get an answer is called (Running a trained model to get an answer, as opposed to training it.). Most AI features call a model someone else trained, so they run inference only.
A model is judged on examples it never saw. One that memorised its training examples does well on them and badly on new ones, which is called (When a model memorises its training examples instead of learning the pattern, so it does well on them and badly on new ones.). Where the rules are known and must be exact, such as tax or permissions, plain code is the better tool.
In system design: Treat a model as a part that is usually right, not always. Keep exact rules, such as prices and permissions, in plain code.