From Zero to AI

Lesson 1.1: AI, ML, Deep Learning - What's the Difference

Duration: 50 minutes

Learning Objectives

By the end of this lesson, you will be able to:

  • Define artificial intelligence, machine learning, and deep learning
  • Understand how these three concepts relate to each other
  • Trace the brief history of AI development
  • Recognize why AI has become so powerful recently

The Confusing World of AI Terms

You have probably heard these terms thrown around: AI, machine learning, neural networks, deep learning, GPT, LLM. People often use them interchangeably, but they mean different things. Let us clear up the confusion.

Think of it like this:

┌─────────────────────────────────────────────────────────┐
│                  Artificial Intelligence                 │
│    (Any system that mimics human intelligence)          │
│                                                         │
│   ┌─────────────────────────────────────────────────┐   │
│   │              Machine Learning                    │   │
│   │    (Systems that learn from data)               │   │
│   │                                                 │   │
│   │   ┌─────────────────────────────────────────┐   │   │
│   │   │           Deep Learning                 │   │   │
│   │   │    (ML with neural networks)            │   │   │
│   │   │                                         │   │   │
│   │   │   ┌─────────────────────────────────┐   │   │   │
│   │   │   │     Large Language Models       │   │   │   │
│   │   │   │  (GPT, Claude, Gemini, etc.)    │   │   │   │
│   │   │   └─────────────────────────────────┘   │   │   │
│   │   └─────────────────────────────────────────┘   │   │
│   └─────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────┘

Each term is a subset of the one above it. Let us explore each one.


Artificial Intelligence (AI)

Definition: Any computer system that can perform tasks that typically require human intelligence.

AI is the broadest term. It includes any technology that makes computers seem "smart." This can be as simple as a chess program or as complex as a self-driving car.

Two Types of AI

Narrow AI (Weak AI): Systems designed for specific tasks.

  • Spam filters that detect unwanted emails
  • Voice assistants like Siri or Alexa
  • Recommendation systems on Netflix or YouTube
  • ChatGPT and Claude (yes, even these are narrow AI!)

This is what we have today. Every AI system you interact with is narrow AI.

General AI (Strong AI): A hypothetical system with human-level intelligence across all domains.

  • Does not exist yet
  • Could learn any task a human can learn
  • Subject of much debate about whether it is possible
// Narrow AI example: a spam classifier
// It does ONE thing - classify emails as spam or not spam
type Email = {
  subject: string;
  body: string;
  sender: string;
};

type Classification = 'spam' | 'not_spam';

// The AI model makes this prediction
function classifyEmail(email: Email): Classification {
  // In reality, this would call an ML model
  // The model was trained specifically for this task
  return 'not_spam';
}

Classic AI vs Modern AI

Classic AI (1950s-1990s): Rules written by humans.

// Classic AI approach: explicit rules
function shouldApprove(loanApplication: LoanApplication): boolean {
  // Humans wrote these rules
  if (loanApplication.creditScore < 600) return false;
  if (loanApplication.income < 30000) return false;
  if (loanApplication.debtRatio > 0.4) return false;
  return true;
}

The problem? Humans cannot anticipate every situation. What about someone with a credit score of 599 but zero debt and high income? Rules get complicated fast.

Modern AI: Systems that learn rules from data.

// Modern AI approach: learn from examples
// We do not write the rules - the model learns them
async function shouldApprove(loanApplication: LoanApplication): Promise<boolean> {
  // Model was trained on thousands of past applications
  // It learned complex patterns humans could not specify
  const prediction = await mlModel.predict(loanApplication);
  return prediction.approved;
}

This shift - from writing rules to learning from data - is what defines modern AI.


Machine Learning (ML)

Definition: A subset of AI where systems learn from data instead of being explicitly programmed.

The key idea: instead of telling the computer exactly what to do, we show it examples and let it figure out the patterns.

The Traditional Programming Approach

┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│    Rules     │ --> │   Computer   │ --> │   Output     │
│    (code)    │     │              │     │              │
└──────────────┘     └──────────────┘     └──────────────┘
       +
┌──────────────┐
│    Data      │ --->
│   (input)    │
└──────────────┘

You write the rules. The computer applies them to data.

The Machine Learning Approach

┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│    Data      │ --> │   Computer   │ --> │    Rules     │
│  (examples)  │     │  (training)  │     │   (model)    │
└──────────────┘     └──────────────┘     └──────────────┘
       +
┌──────────────┐
│   Answers    │ --->
│  (labels)    │
└──────────────┘

You provide examples with correct answers. The computer learns the rules.

A Concrete Example: Email Spam Detection

Traditional approach: A programmer writes rules.

// Humans had to think of every possible spam indicator
function isSpam(email: Email): boolean {
  const spamWords = ['free', 'winner', 'click here', 'limited time'];
  const bodyLower = email.body.toLowerCase();

  for (const word of spamWords) {
    if (bodyLower.includes(word)) {
      return true;
    }
  }

  if (email.sender.includes('@suspicious-domain.com')) {
    return true;
  }

  return false;
}

Problems:

  • Spammers change their tactics
  • "Free" might be legitimate ("free shipping")
  • Cannot catch every pattern

Machine learning approach: Train on examples.

// We provide thousands of labeled examples
const trainingData = [
  { email: { subject: 'You won $1000!', body: '...' }, label: 'spam' },
  { email: { subject: 'Meeting tomorrow', body: '...' }, label: 'not_spam' },
  { email: { subject: 'FREE iPhone!!!', body: '...' }, label: 'spam' },
  // ... thousands more examples
];

// The model learns patterns from these examples
const model = trainSpamClassifier(trainingData);

// Now it can classify new emails it has never seen
function isSpam(email: Email): boolean {
  return model.predict(email) === 'spam';
}

The model discovers patterns humans might miss:

  • Certain combinations of words
  • Sender behavior patterns
  • Time of day patterns
  • Subtle language cues

Why "Learning"?

We call it "learning" because the model improves with more examples:

Accuracy with 100 examples:    70%
Accuracy with 1,000 examples:  85%
Accuracy with 100,000 examples: 98%

Just like humans learn from experience, ML models learn from data.


Deep Learning

Definition: A subset of machine learning that uses neural networks with many layers.

What is a Neural Network?

A neural network is a computing system loosely inspired by the human brain. It consists of:

  • Neurons: Simple units that receive inputs and produce outputs
  • Layers: Groups of neurons organized in sequence
  • Connections: Links between neurons with adjustable weights
┌─────────────────────────────────────────────────────────┐
│                    Neural Network                        │
│                                                         │
│  Input Layer    Hidden Layers      Output Layer         │
│                                                         │
│     ○              ○    ○              ○                │
│      \            / \  / \            /                 │
│     ○──────────────○────○────────────○                  │
│      \            \ /  \ /            \                 │
│     ○              ○    ○              ○                │
│                                                         │
│  (features)     (learned         (predictions)          │
│                  patterns)                              │
└─────────────────────────────────────────────────────────┘

Why "Deep"?

"Deep" refers to networks with many hidden layers:

Shallow Network:  Input1-2 layers → Output
Deep Network:     Input10-100+ layers → Output

More layers allow the network to learn more complex patterns:

  • Layer 1: Might detect edges in an image
  • Layer 2: Might detect shapes (combinations of edges)
  • Layer 3: Might detect parts (combinations of shapes)
  • Layer 4+: Might detect objects (combinations of parts)

Deep Learning Breakthroughs

Deep learning has achieved remarkable results in:

Computer Vision

  • Recognizing faces in photos
  • Detecting objects in images
  • Self-driving car perception

Natural Language Processing

  • Translation between languages
  • Text generation (ChatGPT, Claude)
  • Understanding context and nuance

Speech

  • Voice recognition (Siri, Alexa)
  • Text-to-speech synthesis
  • Real-time translation

Games

  • AlphaGo defeating world champions
  • Game-playing AI beating humans at complex games

Large Language Models (LLMs)

Definition: Deep learning models trained on massive amounts of text to understand and generate human language.

LLMs are what power ChatGPT, Claude, Gemini, and similar systems. They are a specific type of deep learning model.

What Makes LLMs Special

  1. Scale: Trained on trillions of words from the internet
  2. Architecture: Use a design called "Transformer"
  3. Capability: Can perform many tasks without specific training
// LLMs can do many things with the same model
const llm = new LanguageModel();

// Summarization
const summary = await llm.complete('Summarize this article: [long article text]');

// Translation
const translation = await llm.complete('Translate to Spanish: Hello, how are you?');

// Code generation
const code = await llm.complete('Write a TypeScript function that sorts an array');

// Question answering
const answer = await llm.complete('What is the capital of France?');

// One model, many capabilities

Why LLMs Matter for Developers

As a developer, you will primarily work with LLMs through APIs:

// Example: Using OpenAI's API
const response = await openai.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Explain recursion in simple terms' }],
});

console.log(response.choices[0].message.content);

You do not need to understand the math behind neural networks. You need to understand:

  • What LLMs can and cannot do
  • How to write effective prompts
  • How to integrate them into applications

We will cover all of this in the coming modules.


A Brief History of AI

Understanding the history helps you see why AI is suddenly everywhere.

The Early Days (1950s-1970s)

  • 1950: Alan Turing proposes the "Turing Test"
  • 1956: Term "Artificial Intelligence" coined at Dartmouth
  • 1966: ELIZA chatbot created (pattern matching, not learning)

Optimism was high. Researchers thought human-level AI was decades away.

AI Winter (1970s-1990s)

  • Progress stalled
  • Funding dried up
  • Computers were not powerful enough
  • Algorithms were not sophisticated enough

The ML Revival (1990s-2010s)

  • More data became available (internet)
  • Computers got faster
  • Better algorithms developed
  • Practical applications emerged (spam filters, recommendations)

The Deep Learning Revolution (2012-Present)

  • 2012: Deep learning crushes competition in image recognition
  • 2016: AlphaGo defeats world Go champion
  • 2017: Transformer architecture invented
  • 2022: ChatGPT launches, bringing LLMs mainstream
  • 2023-2024: Rapid advancement in capabilities

Why Now?

Three factors combined:

  1. Data: The internet created massive datasets
  2. Compute: GPUs made training feasible
  3. Algorithms: Breakthroughs like Transformers
┌─────────────────────────────────────────────────────────┐
│                  Why AI Exploded Now                     │
│                                                         │
│   Data          Compute         Algorithms              │
│    │               │               │                    │
│    │               │               │                    │
│    └───────────────┼───────────────┘                    │
│                    │                                    │
│                    ▼                                    │
│            Modern AI Systems                            │
│                                                         │
└─────────────────────────────────────────────────────────┘

Putting It All Together

Let us summarize the relationships:

Term Definition Example
AI Systems that perform tasks requiring intelligence Chess program, spam filter
ML AI that learns from data Email classifier trained on examples
Deep Learning ML using multi-layer neural networks Image recognition, voice assistants
LLM Deep learning for language ChatGPT, Claude, Gemini

When someone says "AI," they usually mean ML or deep learning. When they say "AI chatbot," they mean an LLM.


Exercises

Exercise 1: Classify the AI Type

For each example, identify whether it is: Classic AI (rules), ML, Deep Learning, or LLM.

  1. A calculator app
  2. Netflix recommendations
  3. ChatGPT writing code
  4. A thermostat that learns your schedule
  5. Face recognition to unlock your phone
  6. Autocomplete on your keyboard
Solution
  1. Calculator: Not AI - just programmed math operations
  2. Netflix recommendations: ML - learns from viewing patterns
  3. ChatGPT writing code: LLM - large language model
  4. Learning thermostat: ML - learns patterns from data
  5. Face recognition: Deep Learning - neural networks for image processing
  6. Keyboard autocomplete: ML or LLM - depends on implementation, modern ones use LLMs

Exercise 2: Rules vs Learning

You need to build a system that detects fraudulent credit card transactions. List three advantages of using machine learning over writing rules manually.

Solution
  1. Adaptability: ML can detect new fraud patterns as criminals change tactics. Rules become outdated.

  2. Complexity: Fraud involves subtle patterns across many variables (time, location, amount, merchant type, etc.). Humans cannot write rules for all combinations.

  3. Scale: ML can analyze millions of transactions and find patterns humans would miss. Writing rules for every scenario is impractical.

  4. Continuous improvement: ML models can be retrained on new data, automatically improving over time.

Exercise 3: Match the Layer

In a deep learning system that recognizes cats in photos, match each description to its likely layer position (early, middle, or late):

  1. Detects cat ears
  2. Detects edges and lines
  3. Recognizes "this is a cat"
  4. Detects fur texture
Solution
  1. Detects cat ears: Middle layer - combines basic shapes into parts
  2. Detects edges and lines: Early layer - basic features
  3. Recognizes "this is a cat": Late layer - final classification
  4. Detects fur texture: Early-to-middle layer - patterns in pixels

Layer progression: edges → textures → shapes → parts → objects


Key Takeaways

  1. AI is the broadest term - any system mimicking human intelligence
  2. Machine Learning is AI that learns from data instead of explicit rules
  3. Deep Learning is ML using neural networks with many layers
  4. LLMs are deep learning models specialized for language
  5. Modern AI success comes from data + compute + better algorithms
  6. As developers, you will mostly interact with AI through APIs

Resources

Resource Type Description
Google AI Glossary Documentation Definitions of ML terms
3Blue1Brown: But what is a neural network? Video Visual explanation of neural networks
MIT Technology Review: AI Timeline Article History of AI development

Next Lesson

Now that you understand what AI, ML, and deep learning are, let us explore how machine learning models actually learn from data.

Continue to Lesson 1.2: How Models Are Trained