Teaching Machines with Examples
How we teach machines with examples instead of rules: labels, practice, testing and why good examples matter so much for fair AI.
Key takeaways
- Some machines learn from examples instead of fixed rules
- Each example usually has a label, like 'cat' or 'dog'
- The machine looks for patterns that match each label
- Bad or unfair examples make the machine give bad or unfair answers
Two ways to make a machine clever
There are two main ways to make a computer do a clever job.
The first way is to write down rules. You tell the computer exactly what to do step by step, like a recipe. This works well when the rules are clear, such as adding numbers.
But some jobs are too tricky for rules. How would you write rules to spot every cat in every photo? Cats come in many colours, shapes and poses. The rules would never end.
So we use a second way: we teach the machine with examples. Instead of telling it the rules, we show it lots of examples and let it figure out the pattern itself. This idea is called Machine Learning.
Learning the way you do
Think about how you learned to know a dog from a cat. Nobody gave you a list of rules. You saw many dogs and many cats. Grown-ups said "that is a dog" and "that is a cat". After enough examples, your brain learned the pattern.
A learning machine does the same thing. We show it many pictures. Each picture comes with a label, a little note that says what it is: "cat", "dog", "car".
The machine looks at the examples and searches for patterns in the numbers. (Pictures are really just numbers, as you can see in How Computers See Pictures.) It notices that "cat" pictures often share certain patterns, and "dog" pictures share others. Patterns are the key idea here, and you can learn more in What Is a Pattern?.
Practice, then a test
When you learn spelling, you practise the words, and then you take a test on them. Teaching a machine works the same way.
First comes practice, which people call training. We show the machine thousands of labelled examples again and again. Each time, it adjusts itself to make fewer mistakes.
Then comes the test. We show it brand new examples it has never seen, without the labels, and check its guesses. This matters a lot. If we only tested it on the same pictures it practised on, it might just be remembering them, not really learning the pattern.
A machine that does well on new examples has truly learned. A machine that only does well on old ones has just memorised, like a pupil who learns the answers without understanding.
Good examples make a good machine
Here is the most important idea in the whole lesson: a machine is only as good as its examples.
Imagine you want to teach a machine to know fruit, but you only show it red apples. It might decide that "fruit" means "red and round". Then it would call a tomato a fruit and miss a banana completely. It learned a poor pattern because the examples were poor.
The same thing happens with fairness. If the examples leave some people or things out, the machine works badly for them. This is called bias, and it is a serious problem. You can learn about it in Training Data and Bias.
So good teachers of machines try hard to use examples that are varied, correct and fair. That way the machine learns a strong, fair pattern.
Honest about what it learns
A machine that learns from examples can be amazing. But let us be honest about what it really does.
The machine does not understand the examples. It does not know what a cat is, or why a tomato is tricky. It only finds patterns in numbers. That is why it can make funny mistakes, like calling a muffin a puppy, that a person never would.
It also cannot learn things it never saw. If it never saw a snowy mountain, it will be lost the first time one appears. It only knows the patterns from its examples.
Try teaching a machine yourself
Teaching machines is real and you can try it. People use code to show examples to a computer and let it learn.
A friendly place to start is Building Your First AI Model, and you can pick up the coding skills you need in Coding. The best way to understand teaching machines is to try it for yourself.
Quick quiz
Test yourself and earn XP
How does a learning machine get good at a task?
It learns by seeing many examples, the way you learn from practice.
What is a label on an example?
A label tells the machine what the example is, like 'this photo is a cat'.
Why do we test the machine on new examples?
Testing on new examples shows whether the machine truly learned the pattern.
What happens if the examples are unfair?
If the examples are unfair or one-sided, the machine learns those problems too.
Does the machine understand the examples like a person?
The machine finds patterns in the examples. It does not understand them the way you do.
FAQ
A little. Both get better with practice. But a friend understands what a cat is. A machine only finds patterns in the numbers of the examples. It can spot a cat without ever knowing what a cat really is. So it learns the pattern, not the meaning.
Usually a lot, often thousands or millions. The more good, varied examples it sees, the better it gets. With only a few examples, it may learn a weak or unfair pattern and make many mistakes on new things.
Keep exploring
More in AI