Rule Based and Learning Based
AI modelling is developing the algorithms — the models — that can be trained to give intelligent outputs. There are two ways to go about it, and the whole difference is who writes the rules.
1The two approaches
Everything in this unit hangs off one of these two branches. Switch between Rule Based and Learning Based to see how much lives under each.
Full lineage: AI Models → Learning Based
2A rule based model at work
A clothing website has a chatbot that answers questions about order tracking. It needs no huge dataset — only a set of questions and the answers that go with them, and rules for matching one to the other:
- If the message contains “track order”, “shipment status” or “delivery”, go to the order tracking options.
- If the user gives a valid order number, look the tracking up and show it. If it is invalid, ask them to type it again.
- If the message matches no rule at all, say “Sorry, I can’t help you with that” and point them at the FAQs.
3A learning based model at work
A spam filter built the learning way is never told what spam looks like. During training it is given a large set of emails, each already labelled spam or not spam. It studies the words used, who sent them, whether there are attachments — and works out for itself which patterns separate the two.
Once trained, it sorts new mail using the patterns it found. And it keeps adapting: every new example it meets improves it. That is the thing a rule based filter can never do.
A thousand photographs of stray dogs
4Side by side
| Rule Based | Learning Based | |
|---|---|---|
| Who writes the rules | The developer | The machine works them out itself |
| Needs | Data and rules | Data and the desired output |
| When the data changes | It fails — the learning is static | It modifies itself to fit the new data |
| Learns from mistakes | No | Yes |
| Example | An FAQ chatbot on a shopping site | A spam filter trained on labelled email |
5From the board papers
▶Show the answer
The rule-based approach is static and cannot adapt to new words or expressions. Note what the wrong options offer: more essays would not help, because the program does not learn from essays at all — it only checks the keyword list it was handed.
▶Show the answer
In a rule based model the relationships and patterns in the data are defined by the developer, and the machine simply follows those rules. Its learning is static: it cannot improve itself from feedback, and it fails on data unlike what it was given.
In a learning based model the machine is given the data and the desired output and designs its own algorithm. It adapts to changes in the data and handles the exceptions.
6Check yourself
In which approach does the developer define the patterns in the data?
Why does a rule based model fail on data unlike its training data?
Which approach designs its own algorithm to match the data to the desired output?