AI, machine learning, deep learning and generative AI
Tell apart AI, machine learning, deep learning and generative AI, see where each one fails, and choose the simplest one that solves a real problem.
Words in this lessonArtificial intelligence · Machine learning · Deep learning · Generative AI · Large language model · Neural network · Dataset · Transformer
- Artificial intelligence
- Getting computers to do tasks that would seem to need intelligence if a person did them. Like the word "cooking": it covers everything from boiling an egg by a fixed rule to a chef improvising a new dish.
- Machine learning
- A way of building software that learns patterns from examples instead of following rules a person wrote. Like a trainee baker who learns when a loaf is done by watching a thousand loaves, rather than reading a rule.
- Deep learning
- Machine learning that uses neural networks with many layers, good at messy data like photos, sound and text. Like an assembly line of inspectors, each one looking for a slightly bigger pattern than the last.
- Generative AI
- AI that creates new content, such as text, images, audio or code, instead of only sorting or predicting. Like the difference between a food critic who rates dishes and a chef who invents new ones.
- Large language model
- A very large model trained on huge amounts of text to predict the next piece of text. Like an autocomplete that has read a library the size of a city.
- Neural network
- A model built from many simple maths units connected in layers, loosely inspired by brain cells. Like a relay of bakery stations, each turning what it receives into something a little more finished.
- Dataset
- A collection of examples used to train or test a model. Like the stack of past orders a new manager studies to learn the shop's rhythms.
- Transformer
- The neural network design that almost every modern language model is built on. Like a standard floor plan that most modern bakeries copy because it works so well.
On this page
Meera walks into the Tuesday stand-up holding two pieces of paper.
The first is a newspaper article about a rival bakery chain. Paragraph one says they use “AI” to plan production. Paragraph two says “machine learning”. Paragraph three says “deep learning”, and paragraph four says “generative AI, like ChatGPT”.
The second is a sales proposal from a software vendor: “AI-powered demand forecasting, ₹4 lakh per year.” The demo screenshot shows a chat window where someone types “How many croissants should Koregaon Park bake on Saturday?” and the bot replies “Based on trends, approximately 165.”
“Here is my problem,” Meera says. “Our Koregaon Park store throws away about twenty croissants every weekday, and sells out by 3 p.m. most Fridays. Each croissant costs us around ₹35 to make. If this AI thing fixes that, ₹4 lakh might be worth it. But I do not even know if these four words are four products or one. Are they the same thing?”
Arjun opens his mouth to answer, and realises he has used all four words this week without being able to define any of them.
Important
The idea in one sentence: AI is the broad goal of making computers do things that seem to need intelligence; machine learning is one way to get there, by learning from examples; deep learning is one kind of machine learning, using large neural networks; and generative AI is deep learning that creates new content, like text and images.
Arjun asks the chatbot
Arjun thinks he can settle it in five minutes. He exports the last three weeks of Koregaon Park croissant sales (21 numbers), pastes them into a chatbot, and asks: “Based on this data, how many croissants will we sell on Saturday?”
The answer comes back instantly: “Approximately 165 croissants, based on the recent weekend trend.”
That looks sensible. Saturday sales were 162, 158 and 165 over the last three weeks. He asks again in a fresh chat, to show Meera. This time: “I’d estimate around 158.” A third time: “Roughly 160 to 170.”
Then Meera leans over. “Ask it about Diwali Saturday.”
He types “What about if Saturday is Diwali?” The bot says: “Festive demand typically increases sales by 40 to 60%, so I’d recommend about 240.” There was no Diwali in the data he pasted. The 40 to 60% came from nowhere Arjun can check.
“And it only had three weeks,” Priya adds from across the room. “We have three years of sales, six stores and ten products. That is about 65,000 rows. You cannot paste that into a chat window, and if you could, you would be paying for a language model to do arithmetic it is not built for.”
Arjun has three different numbers, one invented percentage, and a nagging feeling that he used a very expensive tool for the wrong job.
Four circles on a whiteboard
Priya picks up a marker. “Before we argue about which tool, let me ask you something, Meera. When you opened the first store in 2015, how did you decide how many croissants to bake?”
“I had a rule,” Meera says. “120 on weekdays, 180 on weekends. I wrote it on the wall.”
“That is AI,” says Priya, and draws a big circle.
Arjun laughs. “A rule on a wall is not AI.”
“In the textbook sense it is. Artificial intelligence is the broadest idea: getting a computer to do something that would seem to need intelligence if a person did it. Deciding production, playing chess, planning a route. It does not have to learn anything. In 1997, IBM’s Deep Blue beat the world chess champion Garry Kasparov using hand-tuned rules and an enormous amount of fast searching through possible moves. Nobody taught it from examples, and everybody called it AI.”
She turns back to Meera. “Now, the rule on the wall. Did your head baker follow it?”
“Not after the first year. Sunil would look at the week, the weather, whether there was a cricket match, and bake what he felt was right. He was usually closer than my rule.”
“How did he learn that?”
“Experience. Watching thousands of days.”
“That,” says Priya, drawing a second circle inside the first, “is machine learning.”
Note
Pause and think. Meera’s wall rule and Sunil’s gut feeling both produce a number of croissants. What is the essential difference between how each one came to exist?
Show the answer
A person wrote the rule; Sunil’s judgement came from examples. Meera decided “120 weekdays, 180 weekends” in advance and wrote it down. Sunil watched thousands of real days and gradually absorbed the pattern, without anyone writing it out for him. Rules are programmed; learned behaviour is extracted from data. That is exactly the line between rule-based AI and machine learning.
Machine learning: let the examples write the rule
Writing rules works until the world gets messy. Try writing rules for spam emails: “contains the word lottery”? Spammers change the word. “Has more than three exclamation marks”? So does your aunt. You will be writing rules forever.
Machine learning (ML) flips the approach. Instead of writing the rules, you show the computer many examples and let it work out the pattern. A collection of examples is called a dataset. The thing that comes out of learning, which takes new inputs and makes predictions, is called a model.
For croissants, the dataset is past sales: each row has some inputs (day of week, store, weather, holiday or not) and the answer you want to predict (croissants sold). Learning from examples where you know the right answer is called supervised learning, and it is the most common kind.
Here is the smallest possible version. You can run this in plain Python once you have done the setup lab.
# Croissants sold at the Koregaon Park store over the last three weeks.
history = [
("Mon", 96), ("Tue", 101), ("Wed", 99), ("Thu", 104), ("Fri", 128), ("Sat", 162), ("Sun", 171),
("Mon", 92), ("Tue", 98), ("Wed", 103), ("Thu", 99), ("Fri", 133), ("Sat", 158), ("Sun", 166),
("Mon", 99), ("Tue", 95), ("Wed", 100), ("Thu", 106), ("Fri", 124), ("Sat", 165), ("Sun", 174),
]
# Approach 1: a rule a person wrote (classic, rule-based AI).
def rule_forecast(day):
return 180 if day in ("Sat", "Sun") else 120
# Approach 2: learn from examples (machine learning in its simplest form).
def learn(history):
totals, counts = {}, {}
for day, sold in history:
totals[day] = totals.get(day, 0) + sold
counts[day] = counts.get(day, 0) + 1
return {day: round(totals[day] / counts[day]) for day in totals}
learned = learn(history)
print("What the model learned:", learned)
# What actually happened this week, to check both approaches.
this_week = [("Mon", 94), ("Tue", 100), ("Wed", 97), ("Thu", 103), ("Fri", 131), ("Sat", 160), ("Sun", 169)]
rule_waste = learned_waste = 0
for day, actual in this_week:
r, m = rule_forecast(day), learned[day]
rule_waste += abs(r - actual)
learned_waste += abs(m - actual)
print(f"{day}: actual {actual:3} rule {r:3} learned {m:3}")
print(f"Total croissants off -> rule: {rule_waste}, learned: {learned_waste}")
The output:
What the model learned: {'Mon': 96, 'Tue': 98, 'Wed': 101, 'Thu': 103, 'Fri': 128, 'Sat': 162, 'Sun': 170}
Mon: actual 94 rule 120 learned 96
Tue: actual 100 rule 120 learned 98
Wed: actual 97 rule 120 learned 101
Thu: actual 103 rule 120 learned 103
Fri: actual 131 rule 120 learned 128
Sat: actual 160 rule 180 learned 162
Sun: actual 169 rule 180 learned 170
Total croissants off -> rule: 128, learned: 14
Read the learn function closely. Nobody typed “Friday is busier than Thursday”. The function discovered it from the examples, and its “model” is the dictionary of seven averages it produced. Over one week the rule was off by 128 croissants, while the learned version was off by 14. Of the rule’s 128, 117 were croissants baked and binned: at ₹35 each, about ₹4,100 a week thrown away at one store. Notice also the Friday line: the rule under-baked by 11, which is why the store sells out by 3 p.m.
A real forecasting model would learn from more inputs (weather, holidays, local events, the trend over months) using methods like linear regression or decision trees, which you will meet in Part 2. Those methods, which work on neat rows and columns of numbers, are often called classic ML. But the principle is exactly this one: examples in, pattern out.
Deep learning: when the data is messy
“So machine learning solves the croissants,” says Arjun. “What is deep learning for?”
Priya takes a photo of a cake on the production line with her phone. “Write me a rule that decides whether the icing on this cake is cracked.”
Arjun tries. “If… there is a dark line… longer than…” He stops. A photo is 12 million coloured dots. There is no column called “cracked”.
“Classic ML struggles here too,” Priya says, “because it works best when someone has already turned the world into tidy columns. Photos, sound recordings and free text are not tidy. You need a model that can find its own useful features in raw data.”
That model is a neural network: a function built from many simple maths units (loosely inspired by neurons) arranged in layers, each passing its results to the next. Deep learning is machine learning with neural networks that have many layers; “deep” just means “many layers”.
The layers matter because each one learns to notice something a little more abstract than the one before. For the cake photo: early layers respond to edges and colour changes, middle layers to shapes like curves and lines, later layers to “smooth icing” versus “cracked icing”.
Deep learning took off around 2012, when a neural network called AlexNet won a major image recognition competition by a huge margin. Two things made it possible: much larger datasets, and GPUs (graphics chips built for video games, which can do thousands of simple calculations at once). You will train neural networks yourself in Part 2 of this course, starting in Module 27.
Generative AI: from sorting to creating
Most models before about 2020 sorted or predicted things: spam or not, cracked or smooth, 162 croissants. Generative AI models create new things: a paragraph, an image, a voice, a piece of code.
The best-known generative models are large language models (LLMs), such as Claude, GPT and Gemini. An LLM is a very large neural network trained on an enormous amount of text to predict what comes next. Getting extremely good at that one task turns out to let it answer questions, summarise, translate and write code. The network design behind them, the transformer, was published by Google researchers in 2017. ChatGPT, launched in November 2022, is when most of the world met one.
Here are all four circles, as Priya drew them:
flowchart TD
subgraph AI["Artificial intelligence: computers doing smart tasks"]
R["Hand-written rules, search, planning"]
subgraph ML["Machine learning: learns patterns from examples"]
C["Classic ML: averages, regression, trees"]
subgraph DL["Deep learning: many-layered neural networks"]
V["Image and speech recognition"]
subgraph GEN["Generative AI: creates new content"]
L["LLMs: Claude, GPT, Gemini"]
I["Image and audio generators"]
end
end
end
end
Two details people often miss. Not all generative AI is an LLM: image generators are generative too. And not all deep learning is generative: the cracked-icing detector sorts, it does not create.
Note
Pause and think. Arjun’s chatbot said “approximately 165” for Saturday. Is that LLM doing machine learning on Crumb’s sales data, the way the learn function did?
Show the answer
No, not in the sense that matters. The learn function computed averages from all the data, the same way every time. The LLM read the 21 numbers as text and generated a plausible-sounding reply, word by word, drawing on patterns from its training. It may well have eyeballed the Saturday numbers correctly, but it did not run a calculation you can inspect, it gave a different answer each time, and it happily invented a 40 to 60% Diwali uplift with no data behind it. The LLM is the product of machine learning (it was trained by the provider), but asking it a question is not the same as training a model on your data.
One Saturday, four circles
Priya puts the whole picture together by tracing a single day, next Saturday at Koregaon Park, through each circle:
| Approach | What it does for Saturday | Result |
|---|---|---|
| Rule (AI) | “Weekend, so 180.” | 180. Same every Saturday; about 20 too many. |
| Classic ML | Averages the last three Saturdays (a real model would also use weather and holidays). | 162. Close to the actual 160, the same every run, and explainable. |
| Deep learning | Not for this question. Its job is the photos: it checks Saturday’s 300 cake photos for cracked icing. | Flags 4 cakes for a human to look at. |
| Generative AI (LLM) | Not for the forecast. Its job is words: it drafts the Saturday morning note to the store manager. | “Bake 162 croissants; light rain expected, so keep 10 frozen as backup.” |
The same bakery uses all four circles, each for what it is good at. The forecast comes from ML; the LLM turns that number into a friendly message. That pairing, a precise system producing the facts and an LLM producing the words, is one you will use again and again.
Where each circle breaks
Every circle has a characteristic way of failing, and an AI engineer learns to see them coming.
Rules break on anything their author did not imagine. “180 on weekends” knows nothing about Diwali, a monsoon downpour or a new metro station outside the store. Rules are cheap, fast and completely explainable, which is why they are still the right answer for things like “orders over ₹5,000 from new addresses need a fraud check”, where an auditor must understand every decision.
Machine learning only knows its data. Ask the learn function about a store that opened yesterday and it has nothing. Ask it about Diwali when the dataset contains no Diwali, and it will cheerfully predict a normal Saturday. If the data is wrong (a till that double-counted for a month), the model learns the mistake.
Deep learning is data-hungry and costly. A good cracked-icing detector might need thousands of labelled photos, someone’s time to label them, and GPU time to train. For tidy numeric data like daily sales, it often does no better than classic ML at many times the cost.
Generative AI is not a calculator or a database. It produces fluent text that is usually right and sometimes confidently wrong (a hallucination, like the invented Diwali uplift). It gives different answers on different runs, costs money on every call, and cannot fit 65,000 rows in one question. It is superb with language and unreliable with arithmetic over big tables.
The practical rule: use the simplest circle that solves the problem. AI engineers spend most of Part 1 in the innermost circle, building with LLMs. The good ones still reach for a rule or a small ML model when that is the better tool, and they combine circles freely.
Try it yourself
Sort each example into the innermost circle it belongs to: AI (rules or search), machine learning, deep learning, or generative AI.
- A thermostat that turns on the heater below 18 °C.
- A bank model that predicts loan default from income, age and history, trained on past loans.
- A phone that recognises your face to unlock.
- A tool that writes a birthday poem from three keywords.
- A map app finding the shortest route between two points.
- A music app that creates a new jingle for a bakery advert.
- An email filter that learned spam from millions of labelled emails.
Show the answer
- AI (rules). One hand-written rule. Many people would not call it AI at all, which is fine: the edge of the outer circle is fuzzy.
- Machine learning. Tidy rows of numbers, learned from examples. Classic ML is common here.
- Deep learning. Faces are raw images; modern face recognition uses neural networks.
- Generative AI. It creates new text, using an LLM.
- AI (search). Route-finding uses classic search algorithms; nothing is learned. (Traffic predictions layered on top may use ML.)
- Generative AI. Creates new audio.
- Machine learning. It learned from examples. Modern spam filters may use deep learning, so that answer is reasonable too.
If you argued with yourself over 5 or 7, good. Real systems mix circles all the time.
Common mistakes
- Using “AI” and “LLM” as synonyms. An LLM is one kind of AI. “We use AI” tells an engineer almost nothing; “we use an LLM with retrieval” tells them a lot.
- Assuming newer means better. Generative AI is the newest circle, not the best tool for every job. Forecasting from tidy tables is still classic ML territory, and many problems are best solved with three if-statements.
- Thinking machine learning means the computer “understands”. It extracts statistical patterns from examples. That can look like understanding and is often very useful, but it fails in ways a person would not, such as a normal-Saturday forecast on Diwali.
- Believing a chatbot demo proves a forecasting product. The vendor’s screenshot showed an LLM producing a number. Ask what model produced it, what data it learned from, and how accurate it was on past weeks.
Recap
- AI is the broad goal; it can be as simple as hand-written rules.
- Machine learning learns patterns from a dataset of examples instead of rules written by hand.
- Deep learning is machine learning with many-layered neural networks, and it excels at messy data such as images, audio and text.
- Generative AI creates new content; LLMs like Claude, GPT and Gemini generate text.
- Each circle fails differently; pick the simplest one that solves the problem, and combine them.
At the end of the day Arjun explains it back to Meera, using her own bakery. “Your wall rule was AI. Sunil’s gut feeling was machine learning: he learned from examples. A camera that spots cracked icing would be deep learning. And the chatbot that writes the store manager’s note is generative AI. For croissants, we need the Sunil kind, built from our own three years of sales. Not a chatbot.”
Meera tears the vendor proposal in half. “Then build me a Sunil.” She stops at the door. “But you keep saying ‘model’. The forecast is a model, the chatbot is a model. Is a model a program? A file? A database?”
“That,” says Priya, “is tomorrow’s question.”
Go deeper
- Hugging Face LLM course: chapter 1 is a friendly tour of what transformers and LLMs can do.
- Attention Is All You Need, the 2017 paper that introduced the transformer. Do not try to read it yet; just know it exists. You will build one in Module 30.