Overview
These four terms are nested circles, not competitors. Artificial intelligence is the broad goal of making software act intelligently. Machine learning is the subset of AI where behavior is learned from data instead of hand-written rules. Deep learning is the subset of ML that uses many-layered neural networks. Generative AI is the subset of deep learning whose models produce new content (text, images, audio, code) instead of only labeling or scoring existing data.
For system design the distinction matters because each circle brings different engineering needs. A rules engine needs no training data. A classic ML model (gradient-boosted trees on tabular data) trains in minutes on a CPU. A deep model needs GPUs and large labeled datasets. A generative model is usually consumed as a hosted API or served on GPU clusters, is billed per token, and produces non-deterministic output that must be evaluated and guarded.
Transportation is the whole field (AI). Cars are one way to do it (machine learning). Electric cars are a particular kind of car with a different engine (deep learning). Self-driving electric cars are a newer kind that does something earlier cars could not (generative AI). Every self-driving electric car is a car, but not every car drives itself.
When to use it
- Explaining which technique a product feature really needs before choosing infrastructure.
- Deciding between a simple rules engine, a classic ML model, or an LLM.
- Setting expectations with stakeholders about data, cost, and accuracy.
Where it shows up in interviews
Recognize it when: the interviewer asks how you would add "AI" to a feature.
- Design a fraud detection system
- Design an AI customer-support system
Recognize it when: does the feature create content or make a decision?
- Design an AI recommendation system
- Design an AI content-generation platform
Where it is used in real software
Long-running example of classic machine learning that classifies email using learned features rather than fixed rules.
Deep learning image models recognize faces, pets, and places so a phone can search photos by content.
Generative models draft emails, summarize documents, and suggest code completions.
Key terms
- Artificial intelligence
- Any technique that lets a machine perform tasks we associate with human intelligence, including hand-written rules and search.
- Machine learning
- Algorithms that learn patterns from examples and improve with more data.
- Deep learning
- Machine learning with multi-layer neural networks that learn their own features from raw data.
- Generative AI
- Deep learning models that produce new content by modeling the distribution of their training data.
- Discriminative model
- A model that predicts a label or score for an input, such as spam or not spam.
How it works, step by step
- 1Start with rules
If the logic is known and stable (tax brackets, discount eligibility), plain code is cheaper, faster, and explainable.
- 2Move to classic ML when patterns are fuzzy
When rules become too many to maintain, train a model such as logistic regression or gradient-boosted trees on labeled data.
- 3Use deep learning for unstructured data
Images, audio, and free text benefit from neural networks that learn features automatically.
- 4Use generative AI when output is open-ended
Summaries, answers, drafts, and conversation need a model that produces content, usually an LLM accessed through an API.
- 5Combine them
Real systems mix all four, for example rules for hard limits, a classifier for routing, and an LLM for the reply.
STEP 1AI is the widest circle. It includes rules engines, search algorithms, and every learning method.
Matching a feature to the right circle
An online store wants to add intelligence to five features.
| Feature | Best fit | Why |
|---|---|---|
| Free shipping over a threshold | Rules | Logic is fixed and must be exact |
| Fraud score on checkout | Classic ML | Tabular signals with labeled history |
| Find similar product photos | Deep learning | Unstructured image data |
| Write product descriptions | Generative AI | Open-ended text output |
| Support chatbot | Generative AI plus rules | LLM answers with policy guardrails |
NOWFeature: Free shipping over a threshold | Best fit: Rules | Why: Logic is fixed and must be exact
Only two of five features need generative AI. Picking the smallest circle keeps cost and risk down.
Implementation
# Same task, three approaches: flag a risky order. # 1. Rules (AI without learning)def is_risky_rules(order): return order["amount"] > 1000 and order["account_age_days"] < 7 # 2. Classic machine learningfrom sklearn.ensemble import GradientBoostingClassifiermodel = GradientBoostingClassifier().fit(X_train, y_train) # learned from labeled ordersrisk = model.predict_proba([features(order)])[0][1] # 3. Generative AI (explains the decision in plain language)from openai import OpenAIclient = OpenAI()reply = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": f"Explain why this order may be risky: {order}"}],)print(reply.choices[0].message.content)Complexity and performance
Microsecond latency on a CPU.
Millisecond inference on a CPU.
Needs large labeled datasets.
Hundreds of milliseconds to seconds per response.
Trade-offs
Rules are fully explainable but brittle. Larger models handle messy inputs but are harder to explain and audit.
Each inner circle is usually more capable and more expensive to train, serve, and evaluate.
Variants and related techniques
A branch of ML where an agent learns by trial and reward. It is also used to align LLMs with human preferences.
Before LLMs, text tasks used smaller task-specific models such as named-entity recognizers and sentiment classifiers.
Common mistakes
- Using an LLM for a problem with exact rules.
Fix: Keep deterministic logic in code and use the model only where judgment or language is needed.
- Treating the terms as separate technologies.
Fix: Remember they are nested. Generative AI is deep learning, which is machine learning, which is AI.
Interview questions
What is the difference between machine learning and deep learning?
Machine learning is any algorithm that learns from data. Deep learning is the subset that uses multi-layer neural networks, which learn features automatically and excel at images, audio, and text but need more data and compute.
When would you not use generative AI?
When the logic is exact and must be auditable, when latency or cost budgets are tight, or when a smaller classifier already meets the accuracy target. Generative models add non-determinism, token cost, and safety work.
Practice problems
| Problem | Difficulty | What it trains |
|---|---|---|
| Classify ten product features into rules, ML, deep learning, or generative AI | Easy | Choosing the smallest effective approach. |
| Design a support system that combines rules, a classifier, and an LLM | Medium | Routing and guardrails. |