Season 1 · The Foundations · Episode 2

S1E2 How LLMs Work

A machine that does one thing, billions of times: guess the next word

What this lesson is about

A large language model works by predicting the next word in a sequence, over and over again. During training it does this billions of times, and along the way it builds a vast internal map of language where words, meanings, and contexts are stored as numbers. In this lesson you will open up that process and follow it from raw training data, through tokenisation and embeddings, to the moment the model picks its next word. The goal is for the inner workings of an LLM to stop feeling like magic and start feeling like something you can explain.

What you'll be able to do

A little background

When you type a prompt, the model navigates its internal word map using an architecture called a transformer, paying attention to the parts of your input that matter most. It then uses probability to choose the most likely next token, one piece at a time. The key terms to get comfortable with are training data, tokens, embeddings, the transformer, and self-attention, and you will build your own definition of each.

If a model only ever predicts the next word, where does the meaning come from?

Core Reading

Further Readings

Where these facts come from

Every source on this page was opened and checked before it went here. Click through and check anything you are about to rely on.

Key words

Training data
The enormous body of text a model learned patterns from, long before it met you.
Token
The chunk of text a model actually works in — usually a word, sometimes part of one.
Embedding
A list of numbers recording where a token sits on the model's internal map of meaning.
Transformer
The architecture that lets a model weigh which parts of your input matter most.
Self-attention
The step where the model decides which earlier words bear on the word it is about to choose.