Lesson 1 of 33 · Part 0: Foundations

What is an LLM?

How Large Language Models predict the next token.

Today: We open the box and see how an AI writes its answers, one small token at a time.

|

You've used this before. But what's happening under the hood?

These are all different products, built on the same idea

ChatGPT

ChatGPT

OpenAI

Claude

Claude

Anthropic

Gemini

Gemini

Google

Llama

Llama

Meta

Mistral

Mistral

Mistral AI

Falcon

Falcon

TII

Same prompt

"Explain quantum physics simply"

ChatGPT

Think of particles as tiny dice that...

Claude

Imagine the universe at its smallest scale...

Gemini

Quantum physics is like a game where...

ChatGPT
Claude
Gemini
Llama
Mistral
Falcon
LLM

Large

billions of parameters

Language

trained on text

Model

makes predictions

?

How does it actually work?

How does it understand?Where does it learn?Why is it so good?
Let's find out→

You type:

Your prompt

"The capital of France is ___"

The model's job: predict what comes next

Text is split into tokens

Try:

"The capital of France is"

→
The
ID: 464
·capital
ID: 3361
·of
ID: 315
·France
ID: 6064
·is
ID: 374

· = a space that is part of the token. IDs are illustrative; each tokenizer has its own numbering.

"unbelievable"→unbelievable

Tokens = the currency of LLMs

Short prompt

"Hi there"

2 tokens

Long prompt

"Write a detailed essay about..."

500 tokens

With AI APIs you pay per token: for the tokens you send+the tokens that come back (prices differ by model)

Rule of thumb: 1 token ≈ ¾ of an English word  |  a 1-page email ≈ 500 tokens

GPS locates a place

(40.7, -74.0)

= New York

↔

Embedding locates meaning

[0.31, 0.88, …]

= "King" (royalty, male, power)

Every token gets its own unique embedding vector:

The↓
+0.12-0.63+0.38-0.21
capital↓
+0.67+0.34-0.51+0.22
of↓
-0.45+0.22+0.61-0.16
France↓
+0.82-0.45+0.73+0.91
is↓
+0.29-0.51-0.14+0.47

Illustrative numbers: a real embedding has hundreds or thousands of numbers per token

ROYALTYANIMALSdistance = 4.7d = 0.12kingqueenprincethronedogcatpuppykittenbanana(far from everything)
king ↔ queen = 0.12 (very close!)|king ↔ banana = 4.7 (very far)|Close in space = close in meaning
King−Man+Woman=Queen!
woman − man+ (woman − man)kingmanwomanqueen

Attention: each token looks at every other token to understand context

The
capital
of
France
is

Thick lines = strong attention. "France" and "capital" are strongly connected.

Try:
Thebankbytheriver

bank looks at river

bank = riverbank

Thebankapprovedtheloan

bank looks at approved + loan

bank = a money business

Same word, different neighbours, different meaning

Tokens flow through billions of neural network parameters

...through many layers of math that extract meaning and patterns

The→
capital→
of→
France→
is→
InputHidden 1Hidden 2Hidden 3OutputData flows left → right through layers

Early layers

Grammar

Middle layers

Meaning

Later layers

Reasoning

Big models: billions of parameters|Each parameter = one tiny number, adjusted during training

The network scores every possible next token

"The capital of France is ___" → every token in the vocabulary gets a score

Try:
Paris
92%
winner
Lyon
3%
the
2%
Marseille
1.5%
known
1.5%

Illustrative numbers. A clear question gives one tall bar; an open one spreads the chances out.

Autoregressive generation: output becomes the next input

That streaming effect you see in ChatGPT? This is why.

Iteration 1 / 5

Input

ThecapitalofFranceis
→
LLM
→

Output

Generated so far:

The capital of France is ▌

Temperature — the creativity dial

Temp = 0
Paris
100%
Lyon
the
Marseille
known

Always picks "Paris" — deterministic

Training: reading the internet to learn patterns

📚Books & articles
💻Code repositories
🌐Websites
💬Conversations
→→→→
LLM

Billions of parameters

adjusted over weeks or months

on thousands of chips

Big models are trained on trillions of tokens of text

Human Scale

A book a day would still take thousands of lifetimes

Training Cost

Thousands of chips for weeks: lots of money and electricity

Training = predicting the next word, trillions of times

The cat sat on the → mat✓
Paris is the capital of → France✓
Water boils at 100 degrees → Fahrenheit✗
The sun rises in the → east✓

Wrong prediction → adjust parameters!

Grammar, facts, reasoning — all learned from next-word prediction

The model has a fixed-size context window

It can only see a limited number of tokens at once

fell off the deskcontext window: 8 tokens
My
name
is
Alex.
I
love
pizza
and
long
walks.
Plan
my
party!
What
is
my
name?

"Alex" fell off the desk, so the model can't answer "What is my name?"

Measured in

tokens

not words or pages

Everything counts

in + out

your messages and its replies

Size

varies

by model; check the docs

LLMs have NO memory between conversations

Chat 1

"My name is Alex"

"Nice to meet you, Alex!"

Chat 2 (new session)

"What's my name?"

"I don't know your name."

FORGOTTEN

Each conversation starts completely fresh — no persistent memory

The complete journey from question to answer

💬Prompt
→
✂️Tokenizer
→
📐Embeddings
→
🔗Attention
→
🧠Neural Net
→
📊Probabilities
→
✨Output
↻ Loop back for next token

Think of it as "autocomplete on steroids"

Phone Keyboard

I'm going to the...

storegympark

3 boring suggestions. That's it.

Large Language Model

Explain quantum physics like I'm 5

Imagine everything is made of tiny tiny balls. These balls are so small you can't see them. Sometimes they act like magic...

Full coherent paragraphs, on any topic

Same principle. Vastly more training text. Vastly bigger model.

Know the capabilities AND the limits

CAN

✓Write & summarize text
✓Reason about problems
✓Write & debug code
✓Understand context

CAN'T

✗Browse the internet live
✗Remember past conversations
✗Guarantee factual accuracy
✗Learn from your conversations

Key Takeaways

🔮An LLM predicts the next token, one at a time
✂️Text becomes tokens, then numbers that carry meaning
🌡️Temperature controls how adventurous each pick is

Now you know what powers ChatGPT, Claude, Gemini, and Llama!

1/0
Next: Temperature →