How Large Language Models Actually Work — A Guided Tour
By the end of this lesson, you will be able to:
Watch each section, then check it off. Click a header to expand notes and checkpoints.
⏱ ~5 min
CJ builds an ELIZA-style chatbot using if-statements and pattern matching. It streams responses word-by-word via Server-Sent Events — the same streaming plumbing real LLMs use, but with zero intelligence behind it.
💬 Key insight: "Same plumbing as ChatGPT, zero intelligence." This sets the baseline — without neural networks, there's no learning, only hardcoded rules.
⏱ ~10 min
A single-layer perceptron fails on XOR (proving Minsky & Papert's 1969 result). A multi-layer network succeeds via backpropagation — the same algorithm every neural network uses today, from image classifiers to LLMs.
💬 Key insight: Backpropagation is how every neural network learns. The math is just the chain rule from calculus — propagating errors backward through the layers so each neuron can adjust.
⏱ ~10 min
Byte Pair Encoding (BPE) from scratch. CJ trains a tokenizer on whatever text you input — watch merge steps animate as the algorithm builds a vocabulary from individual characters up to common words and subwords.
💬 Key insight: Every word gets broken into subword tokens. "ChatGPT" might become ["Chat", "G", "PT"]. Tokenization is the bridge between human language and neural network math.
⏱ ~10 min
Trains word embeddings from scratch using Word2Vec skip-gram with negative sampling. Watch vectors learn that words used in similar contexts cluster together in vector space.
💬 Key insight: "You shall know a word by the company it keeps." Words that appear in similar contexts get similar vector representations. This is how LLMs build understanding of meaning without being explicitly taught definitions.
⏱ ~15 min
A decoder-only transformer built entirely from scratch — no ML libraries. Every operation hand-implemented: multi-head causal self-attention, layer normalization, feed-forward layers, backpropagation, and Adam optimization. Uses multi-threaded data parallelism via SharedArrayBuffer for training speed.
💬 Key insight: The transformer is just matrix multiplications + softmax + layer norm. There's no single "intelligence switch" — the magic is emergent from thousands of simple operations at massive scale.
📚 References from the codebase: Vaswani et al. "Attention Is All You Need" (2017), Radford et al. "GPT-1" (2018), Holtzman et al. "The Curious Case of Neural Text Degeneration" (2019).
Tap or click a term to reveal its plain-language definition. Terms are grouped by course module.
Test your understanding after watching. No grades — just for you.
1. What makes the ELIZA-style chatbot in Section 1 different from a real LLM?
2. Why does a single-layer perceptron fail on XOR?
3. What are word embeddings?
4. Which paper introduced the Transformer architecture?
Pick one to reflect on, then bring your thoughts to the group.
After seeing the ELIZA chatbot (if-statements pretending to be intelligent), do you think real LLMs are also "just pattern matching" at a larger scale, or is there a qualitative difference? Where's the line between mimicry and understanding?
The XOR neural net uses the same algorithm (backpropagation) as GPT-5. What does it mean that intelligence at every scale — from classifying two inputs to writing poetry — relies on the same simple learning rule? Does that democratize AI or make it more mysterious?
CJ's tokenizer demonstrates that "ChatGPT" gets broken into subword pieces. How does tokenization affect what an LLM can and cannot understand? Why might a model struggle with unusual names, invented words, or code?
The transformer is built from simple parts: attention, feed-forward layers, normalization. If these are all well-understood mathematical operations, why can't we predict what a trained model will do? What's the difference between understanding the parts and understanding the whole?
Write your thoughts. They're saved in your browser (local storage).
Now that you understand how an LLM processes language — tokens → embeddings → attention → prediction — you're ready to learn how to talk to them effectively. Prompting is the craft of giving the model the right context, structure, and constraints for your task.
→ Continue to Lesson 1.3: The Art of the Prompt