TExcelTAD
Home › Generative AI & LLMs › AI vs ML vs Deep Learning

AI vs ML vs Deep Learning vs Generative AI

These four terms are often used as if they meant the same thing. They don't — they are nested, each one a subset of the one before:

text
Artificial Intelligence      any technique that makes computers act "intelligently"
 └─ Machine Learning         systems that learn patterns from data instead of hand-written rules
     └─ Deep Learning        machine learning with many-layered neural networks
         └─ Generative AI    deep models that produce new text, images, audio, code…
             └─ LLMs         generative models for language (and, increasingly, images and audio)

AI without learning: rules

Early AI was mostly symbolic: experts wrote rules by hand. Rules are transparent and predictable, but brittle — they only handle the cases someone thought of.

python · try it yourself
def rule_based_sentiment(text):
    positive = {"good", "great", "love", "excellent"}
    negative = {"bad", "awful", "hate", "terrible"}
    words = text.lower().replace("!", "").split()
    score = sum(w in positive for w in words) - sum(w in negative for w in words)
    return "positive" if score > 0 else "negative" if score < 0 else "neutral"

for review in ["I love this phone, great battery!",
               "Awful screen and bad speakers",
               "Not good at all"]:
    print(f"{rule_based_sentiment(review):8} <- {review}")
positive <- I love this phone, great battery!
negative <- Awful screen and bad speakers
positive <- Not good at all

The last review is wrong: the rules have no idea that "not" flips the meaning. You could add a rule for "not", then for "hardly", then for sarcasm… This endless patching is why the field moved to learning from examples.

Machine learning: learn the rules from data

In machine learning (ML) you give the computer labelled examples and an algorithm finds the pattern. Here scikit-learn learns sentiment from eight tiny reviews. Using word pairs (bigrams) as features lets it notice "not good":

python · try it yourself
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.linear_model import LogisticRegression

train = ["great phone", "love it", "excellent value", "good battery",
         "not good", "bad screen", "hate it", "not great at all"]
labels = ["pos", "pos", "pos", "pos", "neg", "neg", "neg", "neg"]

vec = CountVectorizer(ngram_range=(1, 2))
X = vec.fit_transform(train)
model = LogisticRegression(random_state=0).fit(X, labels)

tests = ["good value", "not good value", "love the battery"]
for text, label in zip(tests, model.predict(vec.transform(tests))):
    print(f"{label} <- {text}")
pos <- good value
neg <- not good value
pos <- love the battery

Nobody wrote a rule about "not". The model adjusted numeric weights for each feature until its predictions matched the labels. That is the essence of ML: programming by example.

Deep learning: many layers, learned features

Classic ML often needs humans to design the features (word counts, pixel statistics). Deep learning uses neural networks with many layers that learn useful features on their own, directly from raw data such as pixels, audio samples or tokens. It needs much more data and compute, but it is what made modern speech recognition, image recognition and LLMs possible. The Neural Network Basics lesson builds a tiny network by hand.

Generative AI: producing new content

Most classic ML is discriminative: it maps an input to a label (spam / not spam, cat / dog). Generative models learn the distribution of the data itself so they can sample new examples from it: a new sentence, a new image, a new melody.

python · try it yourself
import numpy as np

rng = np.random.default_rng(7)
# "Training data": heights in cm of a small group
heights = np.array([158, 162, 165, 168, 170, 171, 174, 177, 180, 185])

# Discriminative task: label an input
print("is 183 tall?", 183 > heights.mean())

# Generative task: learn the distribution, then sample NEW values from it
mu, sigma = heights.mean(), heights.std()
print(f"learned mean={mu:.1f}, std={sigma:.1f}")
print("generated:", np.round(rng.normal(mu, sigma, size=5)).astype(int))
is 183 tall? True
learned mean=171.0, std=7.9
generated: [171 173 169 164 167]

An LLM is the same idea for language: it has learned a probability distribution over text, and generation means sampling from it, one token at a time.

Quick comparison

Rules (symbolic AI) Classic ML Deep learning Generative AI / LLMs
Who writes the logic? Humans Learned from labelled data Learned, including features Learned from huge unlabelled corpora
Typical output Decision Label or number Label, number, embedding New text, images, audio, code
Data needed None Hundreds–thousands of examples Large Enormous (pretraining)
Explainability High Medium Low Low

Tip: When choosing a solution, start simple. If a regular expression or a small classifier solves the problem reliably, it is cheaper, faster and easier to test than an LLM.

Go further: AI vs ML vs Deep Learning in ML Foundations solves one problem all three ways and discusses how to choose between them.

Test yourself

Which statement about the relationship between the terms is correct?

  1. Machine learning is a subset of deep learning
  2. Deep learning is a subset of machine learning, which is a subset of AI
  3. Generative AI and AI mean exactly the same
  4. LLMs are rule-based expert systems

What is the key difference between a discriminative and a generative model?

  1. Discriminative models are always larger
  2. A generative model can sample new examples from the distribution it learned
  3. Generative models need no training data
  4. Discriminative models only work on images

Why did the rule-based sentiment function fail on "Not good at all"?

  1. It had no rule for negation
  2. Python cannot read the word 'not'
  3. The text was too long
  4. It was trained on bad data