ExpertTopic · College & Adult · ages 18+ · 41 classes

AI & LLMs

A self-contained deep dive — each class is a short illustrated explainer with narration, quick checks, an interactive, and a mastery quiz. Your progress saves automatically.

▶ Start class 1 free — no sign-up
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Not startedStartedCompletedMastered
01
How an LLM actually predicts the next word
Not started
Start →
02
How models actually get trained
Not started
Start →
03
The transformer — what "attention" actually does
Not started
Start →
04
Tokenization — how text becomes numbers
Not started
Start →
05
How we know which models are actually better
Not started
Start →
06
The Claude family (Anthropic)
Not started
Start →
07
The GPT family (OpenAI)
Not started
Start →
08
The Gemini family (Google)
Not started
Start →
09
Open weights — Llama, Qwen, DeepSeek, Mistral
Not started
Start →
10
Specialized models — code, vision, audio, embedding
Not started
Start →
11
Picking the right model for the job
Not started
Start →
12
Anatomy of a great prompt
Not started
Start →
13
System prompts and personas
Not started
Start →
14
Few-shot, chain-of-thought, structured output
Not started
Start →
15
Context windows and the lost-in-the-middle problem
Not started
Start →
16
Temperature, top-p, and the sampling parameters
Not started
Start →
17
Tool use — giving the model hands
Not started
Start →
18
Vision — letting the model see
Not started
Start →
19
Audio — speech to text and text to speech
Not started
Start →
20
Embeddings — the math that makes search and RAG possible
Not started
Start →
21
RAG — retrieval-augmented generation
Not started
Start →
22
The agent loop — observe, think, act, repeat
Not started
Start →
23
Reasoning and planning — what the o-series models actually do
Not started
Start →
24
Memory — short-term, long-term, episodic
Not started
Start →
25
Multi-agent systems — when to split work
Not started
Start →
26
Eval and observability for agents
Not started
Start →
27
Safety and guardrails for agents
Not started
Start →
28
The chat API end-to-end
Not started
Start →
29
Cost — how to track and control AI spend
Not started
Start →
30
Latency — making AI feel fast
Not started
Start →
31
Errors and retries — what fails and how to handle it
Not started
Start →
32
Rate limits — engineering for them, not against them
Not started
Start →
33
Hallucination — when models invent facts
Not started
Start →
34
Bias and fairness — what models inherit from their data
Not started
Start →
35
Prompt injection — the unsolved security problem
Not started
Start →
36
Evaluation quality — measuring what matters
Not started
Start →
37
Model drift — when quality changes silently
Not started
Start →
38
AGI — the goal everyone talks about and few define
Not started
Start →
39
Open vs closed — the debate that defines AI
Not started
Start →
40
The economics of AI — where the money flows
Not started
Start →
41
How to keep up — the practical learning loop
Not started
Start →
See inside a class

Here’s all of Class 1, in full.

Every class is 13 cards · narrated film + illustration · 2 quick checks · an interactive · a 4-question mastery quiz. Nothing hidden — this is the complete text of How an LLM actually predicts the next word.

▸ Read the full class — How an LLM actually predicts the next word

Welcome to class one. Most people interact with language models every day without knowing what's happening under the hood. ChatGPT, Claude, Gemini — they feel like magic. They are not. An LLM does exactly one thing: it predicts the next word. Or more precisely, the next token. That is the entire trick. Everything else you have ever seen an LLM do — answering questions, writing code, holding conversations, reasoning through problems — emerges from being incredibly good at that single task. Today we are going to peel back the layers and look at what actually happens when you press send. By the end, language models will stop being mysterious and start being a tool you can reason about clearly.

1. Words come in patterns. Can a computer learn the patterns?

Every sentence ever written follows patterns. "The cat sat on the" almost always continues with "mat" or "floor." If a machine could learn those patterns, it could finish sentences. Then paragraphs. Then anything written.

  • Language has structure: grammar, vocabulary, idiom, context.
  • Humans learn these patterns from billions of examples while growing up.
  • A machine can read those examples too — text, books, the entire internet.
  • The question: can it learn enough patterns to fool a human?

2. A language model is a function that scores possible next tokens.

Feed in some text. The model outputs a probability for every possible next token in its vocabulary. Higher probability means "this token is more likely to come next given what I've seen." That is the entire mechanism.

  • Input: a sequence of tokens (your prompt).
  • Output: a probability for every token in the vocabulary (typically 50,000–100,000 tokens).
  • The model picks one token from the distribution. That becomes the first word of the response.
  • Repeat with the new sequence. Build up the response, one token at a time.

3. From n-grams to transformers in 70 years.

The idea of predicting the next word is old. What changed is how well we can do it. Each generation found better ways to capture context — and each better-capture-context unlocked new abilities.

  • 1948 — Claude Shannon's entropy paper. Language as a probability distribution.
  • 1980s — n-gram models. Predict next word from previous N-1 words. Simple, limited.
  • 2013 — word embeddings (word2vec). Words become vectors in a high-dimensional space.
  • 2017 — "Attention is All You Need" introduces the transformer architecture.
  • 2020 — GPT-3 shows that scale alone produces emergent capabilities.

4. Tokens, vectors, attention, probabilities — the four-step loop.

Inside the model, every prediction goes through the same four steps. They run in milliseconds, but the architecture is the same every time.

  • 1. Tokenize: break input text into tokens, then look up each token's vector.
  • 2. Process: feed the vectors through transformer layers (attention + feedforward).
  • 3. Score: produce a probability for every token in the vocabulary.
  • 4. Sample: pick one token. Add it to the sequence. Repeat.

5. A real prompt and its tokenization.

Here is what really happens when you send a prompt. Take "The capital of France is." The tokenizer breaks it into five tokens — "The," space-"capital," space-"of," space-"France," space-"is." Notice the leading spaces are part of the tokens — that is how modern tokenizers handle word boundaries. The model processes those five token vectors through its transformer layers. At the output, it produces a probability for every single token in its vocabulary — about fifty thousand of them. The top result, with eighty-two percent probability, is space-"Paris." The next most likely is space-"the" at seven percent — maybe the model thinks the sentence might continue "is the most beautiful city." Then "Lyon" at one percent, hedging on a wrong but plausible French city. About forty-nine thousand nine hundred ninety-five other tokens get smaller and smaller probabilities. The model picks Paris because the probability is so dominant. That is one prediction step. Now the sequence becomes "The capital of France is Paris." The model runs again to predict what comes after Paris — probably a period, or maybe a comma, or maybe the word "and."

6. Reasoning, coding, translation — all emergent from prediction.

The most surprising thing about LLMs is that being good at next-token prediction turns out to require — and produce — an enormous amount of other skills.

  • Translation: predicting the next French token after an English sentence requires understanding meaning.
  • Code: predicting the next line of Python correctly requires understanding the program.
  • Reasoning: predicting the next step in a math problem requires actually thinking.
  • These were not engineered in. They emerged from scale.

7. Why responses appear word by word.

When you watch ChatGPT or Claude type out a response word by word, that animation is not cosmetic. It is real. Each token genuinely requires a full forward pass through the model — typically about a hundred transformer layers, each with millions of parameters. On a fast model, that takes around fifty milliseconds. A two-hundred-token response takes about ten seconds end to end. Streaming is the practice of sending each token to your screen as soon as it is generated, instead of waiting for the whole response. It feels faster — you can start reading immediately — and it is faster, because the network round-trip happens in parallel with later token generation. When you understand that the typing animation is the actual generation process, you stop being impatient with it. You also stop being surprised when an LLM repeats itself or contradicts itself: it cannot "see ahead" to what it is about to write. It can only look back.

8. Three deep consequences of "just" predicting the next token.

Once you accept that next-token prediction is the only mechanism, three implications follow that explain a lot of LLM behavior.

  • No global plan: the model writes word by word with no overarching outline.
  • No real memory: each turn starts fresh from the prompt; nothing persists by default.
  • No truth check: the model picks plausible-sounding tokens, not factually verified ones.

9. Where LLMs sit in the broader AI landscape.

AI is bigger than language models. Knowing where LLMs fit explains what they are good at and what they are not.

  • LLMs (text): GPT, Claude, Gemini. Predict the next token in text.
  • Image generators: Midjourney, DALL-E. Predict pixels from a text prompt.
  • Multimodal models: GPT-4o, Gemini. Read text, images, audio in the same model.
  • Recommendation systems: Netflix, Spotify. Predict what you will click next.
  • All of them are pattern predictors. The pattern just changes.

10. Three things people get wrong about LLMs.

These misconceptions show up everywhere — in news articles, in product pitches, in casual conversation. Naming them prevents bad decisions.

  • "It understands what it says." It does not, in any human sense. It produces statistically likely sequences.
  • "It thinks before answering." It does not. It generates one token at a time, with no separate planning phase.
  • "More parameters = always better." False. Smaller models trained on better data often beat bigger models.

11. Three free ways to watch tokenization and probabilities directly.

You do not have to take any of this on faith. The mechanism is open — you can inspect token probabilities and tokenization yourself.

  • OpenAI Tokenizer playground (platform.openai.com/tokenizer): paste any text, see tokens.
  • OpenAI Playground with logprobs enabled: see top probabilities for every generated token.
  • Anthropic Console: similar visibility into Claude's outputs.

12. A 10-minute experiment that changes how you see LLMs.

Set aside ten minutes. Three small experiments will give you a permanent intuition for what is actually happening.

  • Open OpenAI tokenizer. Paste a paragraph. Count the tokens. Compare to character count.
  • Open OpenAI Playground. Run a completion. Toggle logprobs. Watch the probabilities.
  • Try the same prompt with temperature 0 and temperature 1.5. Notice what changes.
  • Now you understand sampling without anyone explaining it.

13. You can now reason about LLM behavior, not just guess at it.

Six things to take away.

  • An LLM does one thing: predict the next token, given the tokens before it.
  • It does this by producing a probability for every token in its vocabulary, then sampling.
  • Reasoning, coding, translation — all emerge from being good at this one task.
  • It has no global plan, no real memory, no truth check. Behavior follows from this.
  • Tokens are roughly 4 characters of English. Other languages and code may differ.
  • You can verify all of this directly in playgrounds. Touch the mechanism. See it.

Mastery quiz

  1. How does a language model build its response to a prompt?
    • It writes the whole answer at once, then edits it
    • It predicts and picks one token at a time, repeating the loop until a stop token
    • It retrieves a stored answer matching the prompt
    • It plans an outline, then fills in every sentence in parallel
  2. For the prompt 'The capital of France is', the model gave ' Paris' an 82% probability. What did it do with the rest of the vocabulary?
    • Ignored all other tokens completely
    • Assigned smaller probabilities to every other token (e.g. ' the' 7%, ' Lyon' 1%)
    • Gave each remaining token an equal share
    • Only scored the five tokens in the prompt
  3. Which sequence correctly orders the four-step loop inside the model?
    • Score, sample, tokenize, process
    • Tokenize, process, score, sample
    • Process, tokenize, sample, score
    • Sample, score, process, tokenize
  4. Why do skills like translation, coding, and reasoning appear in LLMs?
    • They were each explicitly engineered and trained in separately
    • They emerged because doing next-token prediction well requires those abilities
    • They come from a built-in search engine the model queries
    • They are hard-coded rules applied after generation
HomePracticeFeedBlogMe