Lecture 1 basics of AI

Module 1

Pasted image 20260718135830.png


One-line analogy


LLMS -> TOKENS -> EMBEDDINGS

How does an LLM work? (Story Version)

Imagine a company like OpenAI wanted to build an AI that can talk like a human.
So they did four things.


Step 1: They made the AI read almost the entire internet

They collected billions of books, websites, Wikipedia articles, research papers and conversations.

The AI didn't memorize everything.

Instead, it learned patterns.

For example it learned:

Good morning → How are you?

India → New Delhi

2 + 2 → 4

Dog → Animal

Just like a child learns language by hearing people talk.

An LLM is simply a model that has learned language patterns from huge amounts of text.


Step 2: The AI cannot read sentences directly

Suppose you type

I love pizza.

The AI doesn't read the whole sentence at once.

It first cuts it into small pieces.

"I"
" love"
" pizza"
"."

These pieces are called tokens.

Think of cutting a pizza.

🍕 Whole Pizza
        ↓
🍕 Slice 🍕 Slice 🍕 Slice 🍕 Slice

The AI eats one slice at a time.

Not the whole pizza.

Tokenization is simply breaking text into small pieces so the AI can process it.


Step 3: Computers don't understand English

The computer looks at

Dog

and says

"I have no idea what Dog means."

Because computers only understand numbers.

So OpenAI converts every token into numbers.

Dog
↓

[0.28, 0.94, -0.13, ...]

These numbers are called embeddings.

Think of giving every word an ID card.

Dog → ID 1023

Cat → ID 1024

Pizza → ID 8421

But it's smarter than just an ID.

The numbers also capture the meaning.

Words with similar meanings get similar embeddings.

Dog 🐶
Puppy 🐕
Wolf 🐺

are close together.

While

Dog 🐶

            🚗 Car

                     🍕 Pizza

are far apart.

Embeddings convert words into numbers while preserving their meaning.


Step 4: The AI predicts the next word 🔮

Now the AI has numbers instead of words.

Suppose it sees

I live in

It thinks

Mumbai?
Delhi?
India?
London?

Based on everything it learned, it predicts the most likely next token.

I live in India.

Then it predicts the next one.

I live in India and...

Then another.

I live in India and I...

It repeats this process one token at a time until the answer is complete.

An LLM doesn't think like humans. It predicts the most likely next token over and over again.


Complete Flow

You type

"I love pizza."
        │
        ▼
Tokenization
        │
"I" " love" " pizza" "."
        │
        ▼
Embeddings
        │
Numbers representing meaning
        │
        ▼
LLM processes the numbers
        │
Predicts the next token
        │
Predicts the next token
        │
Predicts the next token
        ▼
Converts tokens back into words
        ▼
Final answer