Lesson 1 of 23 · 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.82, -0.45, ...]

= "King" (royalty, male, power)

Every token gets its own unique embedding vector:

The↓
+0.12-0.03+0.08-0.01
capital↓
+0.67+0.34-0.51+0.22
of↓
+0.05-0.02+0.11-0.06
France↓
+0.82-0.45+0.73+0.91
is↓
+0.09+0.01-0.04+0.07

Notice: "France" has large numbers (lots of meaning) — "of" has tiny numbers (little meaning)

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!
originKingMan+ Woman − ManQueenWoman

The model learned this from data alone — no one programmed it

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

"France" and "capital" attend strongly to each other

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→
InputLayerHidden 1Hidden 2Hidden 3OutputLayerData flows left → right through layers

Parameters

Billions

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

Learning to predict the next token, over and over, on massive data

📚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

Even reading a book every day, a person would need thousands of lifetimes to read that much

Training Cost

Thousands of powerful chips running for weeks or months, which costs a lot 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

tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
tok
CONTEXT WINDOW

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

🔮LLMs predict the next token, one at a time
✂️Tokens are the unit of input, output, and cost
📐Embeddings capture meaning as numbers in space
🔗Attention connects related words across the context
🌡️Temperature controls creativity vs. predictability

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

1/0
Next: Temperature →