# AI vs Machine Learning vs Deep Learning vs Generative AI: What Developers Need to Know

> AI, machine learning, deep learning, generative AI, LLMs and agents explained for developers as nested layers, with the same task solved three ways in Python and a table for choosing the right one.

- Drafted by AI, signed off by: [Muhammed Shakir](https://www.linkedin.com/in/muhammed-shakir-gen-ai-trainings-and-consulting): Creator, Projekts.ai | Enterprise AI Builder & Architect | Helping Businesses Build AI-Agent-Driven Operations | Agentic AI, RAG & AI-Native Systems | Forward Deployed Engineer | Corporate Trainer
- Published: 2026-10-28
- Last updated: 2026-10-28
- Topic: AI fundamentals for developers
- Written for: developers
- Web page: https://workshopps.com/blog/ai-vs-machine-learning-vs-deep-learning-vs-generative-ai
- Related Course Offering: [AI for Developers — Build Practical, Responsible AI Features](https://workshopps.com/courses/ai-for-developers)

**At a glance:** In today's AI systems, artificial intelligence, machine learning, deep learning, generative AI and large language models are nested layers, each narrower than the one around it. An AI agent is an LLM used in a loop with tools. Developers mostly call an LLM directly, and build an agent only when a task needs tools and several steps.

## The short answer

In today's AI systems, artificial intelligence, machine learning, deep learning, generative AI and LLMs are not rivals but nested layers, each a narrower kind of the one around it, while an AI agent is an LLM used in a loop with tools. As a developer you will mostly call an LLM through an API, and build an agent only when a task needs tools and decisions over several steps.

---

## Five layers, one inside the other

Most confusion goes away once you see the terms as boxes inside boxes, not as a list of competitors. The map describes today's mainstream systems: generative AI could in principle be built without deep learning, but in practice the generative models you will meet are deep learning models.

![Five nested boxes: artificial intelligence contains machine learning, which contains deep learning, which contains generative AI, which contains large language models, each with examples](https://infomover-public-content.s3.ap-south-1.amazonaws.com/prod/workshopps/ai-vs-machine-learning-vs-deep-learning-vs-generative-ai/ai-nested-layers.svg "Each layer is a narrower kind of the one around it. The LLM in the middle is what your code usually calls.")

| Term | What it means | Example you have used |
|---|---|---|
| **Artificial intelligence (AI)** | The goal: software doing tasks that normally need human judgement. Includes hand-written rules. | A route planner, a chess engine |
| **Machine learning (ML)** | Software that learns its behaviour from data (often labelled examples) instead of from rules a person writes. | Your email spam filter |
| **Deep learning** | Machine learning with neural networks of many layers, which learn their own features from raw data. | Photo search, speech to text |
| **Generative AI** | Models that create new content (text, images, audio, code) instead of only labelling it. Today these are deep learning models. | Image generators |
| **Large language model (LLM)** | A generative model for text, trained to predict the next token. | Claude, GPT, Gemini, Llama |
| **AI agent** | Not another circle: an LLM in a loop that can call tools and decide its next step. | A coding assistant that runs your tests and fixes the failures |

Two consequences matter for your work:

- **Every LLM is machine learning, but most machine learning is not an LLM.** A fraud score or a demand forecast is still usually a classic ML model.
- **"AI" on its own tells you almost nothing.** When someone says "let's add AI", ask which layer they mean.

---

## The same task three ways: rules, machine learning, an LLM

The difference is easiest to see in code. Here is one task, "is this message spam?", solved three ways.

```python
# pip install scikit-learn anthropic
import os

messages = [
    "Congratulations, you won a free prize! Click here to claim",
    "Can we move tomorrow's stand-up to 10am?",
    "Cheap loans approved instantly, no credit check",
    "Here are the review comments on your pull request",
    "Claim your free gift card now, limited offer",
    "Lunch on Friday to celebrate the release?",
]
labels = ["spam", "ham", "spam", "ham", "spam", "ham"]

new_message = "Your free prize is waiting, click to claim it"

# 1. Rules: a person writes the logic.
def rule_based(text: str) -> str:
    words = ("free", "prize", "click here", "loan")
    return "spam" if any(w in text.lower() for w in words) else "ham"

print("rules:", rule_based(new_message))

# 2. Machine learning: the logic is learnt from labelled examples.
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.pipeline import make_pipeline

model = make_pipeline(CountVectorizer(), MultinomialNB())
model.fit(messages, labels)
print("classic ML:", model.predict([new_message])[0])

# 3. An LLM: a general model, steered by an instruction instead of training.
if os.environ.get("ANTHROPIC_API_KEY"):
    from anthropic import Anthropic

    client = Anthropic()  # reads ANTHROPIC_API_KEY
    reply = client.messages.create(
        model="claude-haiku-5-5",
        max_tokens=50,
        messages=[{
            "role": "user",
            "content": "Answer with one word, spam or ham.\n\nMessage: " + new_message,
        }],
    )
    text = "".join(block.text for block in reply.content if block.type == "text")
    print("LLM:", text.strip().lower())
```

Run it and the first two lines print `spam`. Set `ANTHROPIC_API_KEY` and the third line should print `spam` too: likely, not guaranteed, because an LLM's output can vary. What changes between them is where the logic comes from:

1. **Rules.** You wrote every decision. It is fast, free, explainable and testable, and it breaks the day a spammer writes "fr3e".
2. **Classic machine learning.** You supplied labelled examples and the model learnt which words matter. Naive Bayes on word counts is a long-standing approach to spam filtering, as the [scikit-learn documentation](https://scikit-learn.org/stable/modules/naive_bayes.html) notes. It needs data, and it only knows the task it was trained on. Six messages are enough to show the idea, not to trust the model: a real classifier needs far more examples and a held-out test set it never saw in training.
3. **An LLM.** You trained nothing. A general model that has read a vast amount of text follows an instruction. It handles wording it has never seen, but every call costs money and time, and the same input can give a different answer on another call.

Model names change often. `claude-haiku-5-5` is Anthropic's model for high-volume tasks such as classification as of October 2026; check the provider's model list before you copy it.

---

## What deep learning added

Classic machine learning depends on features a person chooses. In the spam example, `CountVectorizer` decides that the features are word counts. For text that is a reasonable choice. For a photo, a voice recording or a scanned invoice, choosing good features by hand is hard, and the results are usually weaker.

Deep learning stacks many layers of a neural network, and each layer learns features from the one before it: edges, then shapes, then objects in an image. You give the network raw data and labels, and it finds the features itself. That is why deep learning took over images, speech and language, and why it needs far more data and computing power than a Naive Bayes model.

You will rarely train a deep network yourself as an application developer. You will use ones that others trained, which brings us to generative AI.

---

## Generative AI and LLMs in four ideas

Generative AI is the part of deep learning that produces new content instead of a label or a score. An LLM is the generative model for text, and it is the one most developers call. Four ideas explain most of how it behaves:

- **Next-token prediction.** An LLM is first trained on a very large body of text to predict what comes next, then tuned to follow instructions. Everything it writes, it writes one token at a time.
- **Tokens.** The units the model reads and writes: whole words, parts of words or single characters. You pay per token, and limits are counted in tokens, not characters.
- **Context window.** The model's working memory for one request: your instructions, the conversation, any documents you pass in. It is separate from what the model learnt in training. If a fact is neither in its training data nor in the context window, the model does not know it.
- **Training vs inference.** Training builds the model. For an LLM the expensive part, pretraining, is done by the provider, and the model can be tuned further later. Inference is using the trained model to answer. When you call a hosted LLM through its API, your code is doing inference only.

Each of these deserves its own Article. For now, the practical point: an LLM's knowledge stops at its training data, and whatever you put in the context window is how you give it anything newer or private.

---

## Agents: an LLM in a loop

A plain LLM call is one prompt in, one answer out. An agent wraps the LLM in a loop:

1. The LLM gets a task and decides the next step.
2. If it needs something, it calls a **tool**: a search, a database query, a code runner, an API.
3. Your code runs the tool and returns the result to the LLM.
4. The loop repeats until the goal is met or a **stop condition** fires, such as a maximum number of steps.

![A task goes to the LLM, which calls tools and reads their results in a loop, then stops and answers when the goal is met or the step limit is hit](https://infomover-public-content.s3.ap-south-1.amazonaws.com/prod/workshopps/ai-vs-machine-learning-vs-deep-learning-vs-generative-ai/agent-loop.svg "An agent adds tools, a loop and a stop condition around the same LLM you call directly.")

Anthropic's engineering team describes agents as ["typically just LLMs using tools based on environmental feedback in a loop"](https://www.anthropic.com/engineering/building-effective-agents). The same guidance recommends starting with the simplest solution and adding complexity only when it is needed, which can mean not building an agent at all.

So "LLM vs agent" is not a choice between two kinds of model. It is a choice of how much control you hand over. A fixed sequence of LLM calls that your code orchestrates (a workflow) is predictable. An agent decides its own steps, which is more flexible and harder to test.

---

## Which one should you build with?

Start at the top of this table and stop at the first row that fits.

| The task | Reach for | Why |
|---|---|---|
| The logic is known and stable, such as validation or routing on fixed fields | **Rules** | Fast, free, testable, explainable |
| You have labelled historical data and one narrow prediction, such as churn or fraud | **Classic machine learning** | Cheap to run, measurable, well understood |
| Raw images, audio or video | **A pre-trained deep learning model** | Usually far better than features chosen by hand |
| The answer depends on your own documents | **An LLM with retrieval-augmented generation (RAG)** | Your code fetches the relevant passages and puts them in the context window |
| Language in, language out: summarise, classify free text, extract, draft | **A single LLM call** | No training needed; handles new wording |
| Several steps, with tools, where the path is not known in advance | **An agent** | Only here is the loop worth its cost and risk |

**When not to use an LLM:** when the rule is simple and the answer must be identical every time, when a wrong answer is expensive and you cannot check it, or when the volume makes per-call cost matter more than flexibility. A rule or a small classic model is often the better engineering choice, and it can sit in front of an LLM to handle the easy cases.

---

## What this means for you as a developer

Most of what you already do carries over:

- **APIs.** An LLM is a remote API with a request and a response.
- **Tests and logs.** You still need them, and more so.
- **Boundaries.** Input validation, secrets kept out of code, error handling and timeouts.

Three things are new:

- **Non-determinism.** The same prompt can give different answers. Test with a set of examples and acceptance criteria, not one assert.
- **Evaluation.** "Does it work?" becomes "how often is it right, on which cases?" That needs a small labelled test set from day one.
- **Cost and latency.** Every call costs tokens and time. Measure both from the first prototype.

Learn the layers in that order, too: one plain LLM call done well, with prompts, evaluation and cost in view, before retrieval, and retrieval before agents.

---

## Questions developers ask

**Is ChatGPT or Claude "the AI", or is it the LLM?**
The LLM is the model. ChatGPT and the Claude apps are products built around LLMs, with a chat interface, memory, tools and safety layers on top.

**Do I need to learn the maths of neural networks to build AI features?**
No, not to start. To build applications you need a clear model of tokens, context windows, prompts, evaluation and cost. The maths helps later if you move into training or tuning models.

**Is every chatbot an agent?**
No. A chatbot that answers from one model call per message is not an agent. It becomes an agent when it can call tools and decide over several steps how to reach a goal.

**Will LLMs replace classic machine learning?**
Not for narrow predictions on structured data. A trained classifier is usually cheaper, faster and easier to measure there. LLMs win where the input is free language and the task varies.

**Where can my team learn this hands-on?**
These distinctions are the first topic of Day 1 in [AI for Developers](/courses/ai-for-developers), "Demystify AI and Prompt with Intent". The workshop then builds a small knowledge-assistant application with one basic RAG example, one basic tool example using the Model Context Protocol (MCP, an open standard for connecting an LLM to tools and data) and evaluation checks. Enquire to bring it to your team.
