Skip to content
Let’s Talk
THE BASICS OF AI / LESSON 2 OF 10

How does a machine learn?

A machine learns by being shown many examples and adjusting itself until its answers match them. What it keeps is a set of patterns from those examples, so gaps and slants in the examples carry through to its answers.

Examples with answers, and examples without.

Most machine learning used at work starts with examples that have the correct answer attached: emails marked as junk or wanted, invoices marked as paid late or on time, photos labelled with what they show. This is called supervised learning. The software makes a guess for each example, compares the guess with the correct answer and adjusts itself slightly. After many rounds, its guesses match the answers most of the time.

Other methods use examples with no answers attached. In unsupervised learning, the software groups similar items together, such as customers who buy in similar ways. The large models behind chat assistants learn from text alone. Part of a sentence is hidden, the model predicts what comes next, and the text itself supplies the correct answer.

What comes out of this process is called a model. A model does not store its examples as a list. It keeps a large set of numbers, called parameters, that record the patterns it found.

Training and use are separate steps.

Training comes first. It is the stage where the model learns from its examples, and for a large model it takes a great deal of computing power. Use comes afterwards and happens many times: each time someone gives the finished model something new, it applies the patterns it learned. This second stage is called inference.

A model does not change while it is being used. A chat assistant that seems to remember an earlier conversation is being shown notes from that conversation, and the model underneath is the same. The model changes only when the people who run it train it again or replace it.

What the examples leave out.

A model can find only the patterns that are in its examples. If most of the examples came from one region or one kind of customer, the model works less well for everyone else. If the examples record past decisions that were unfair, the model learns that pattern along with the rest. This is a common source of bias in AI.

A model can also learn its examples too closely, which is called overfitting. It scores well on the examples it has seen and poorly on new cases. For this reason a model is tested on examples that were kept out of its training.

Why a model’s knowledge stops at a date.

The examples for a model are collected up to a certain point, and the model knows nothing about what happened afterwards. For a language model this point is called the knowledge cutoff. An assistant can go past it only when it is connected to a search tool or to up-to-date documents.

The world also keeps changing after training ends. A model that forecasts demand from past sales becomes less accurate when buying habits shift, an effect called model drift. For this reason a model in use needs checking from time to time, and training again when its results slip.

Try it: find the pattern.

These eight messages are the training examples for a small junk filter. Read the labels, then answer the questions. The messages are fictional.

Junk
You have won a prize, claim it here
Wanted
Minutes from Tuesday’s meeting
Junk
Claim your free gift before midnight
Wanted
Invoice 2291 attached
Junk
Final notice: claim your refund
Wanted
Lunch on Friday?
Junk
Free trial ending, claim your discount
Wanted
Updated schedule for next week
What pattern separates the junk messages from the wanted ones?

Every junk message contains the word “claim”, and no wanted message does. A filter trained on these eight examples would likely learn that “claim” means junk.

A message arrives with the subject “Expense claim form for March”. How would that filter label it?

It would likely label the message as junk, and it would be wrong. The pattern held in the eight examples and does not hold in general.

What would you add to the examples to fix this?

Add wanted messages that use the word “claim”, such as expense claims and insurance claims. The filter then learns that the word alone does not decide the label.

Check yourself.

Answer each question in your head, then open it.

What is the difference between training a model and using it?

Training is the stage where the model learns patterns from examples. Use is when it applies those patterns to something it has not seen, and the model does not change while this happens.

Why is a model tested on examples it was not trained on?

A model can learn its training examples too closely and still do poorly on other cases. Testing on examples it has not seen shows how it will do in real use.

A hiring tool was trained on ten years of one company’s hiring decisions. What could go wrong?

It learns the patterns in those decisions, including any unfair ones. It may also work poorly for kinds of applicant who were rare in the examples.

Go further.

Glossary
Insights
History
A brief history of AI

The examples are fictional. This is general guidance, not advice for your situation.