3Blue1Brown: Large Language Models explained briefly — notes
Watch the video (8 min)
Watch the original video on YouTube
This is 3Blue1Brown’s eight-minute, non-technical overview of large language models (LLMs). It covers what an LLM computes, how chatbots are built on it, how training works at a high level, and where transformers, attention and feed-forward layers fit. It needs no background and works as a starting point for the whole series. If you have watched chapters 1–4, you will see the same ideas (parameters, cost, backpropagation) at a much larger scale. The detailed follow-ups are the chapters on transformers, attention and how LLMs store facts.
Key takeaways
- An LLM outputs a probability for every possible next word, not a single word (0:33).
- A chatbot is a prompt plus repeated sampling. The randomness in sampling is why answers vary (0:53).
- Behavior lives entirely in the parameters, hundreds of billions of them, set by training rather than by hand (1:51).
- Training is two stages: pretraining on internet text, then reinforcement learning with human feedback (3:47).
- Transformers read all the text at once and use attention to let word vectors refine each other in context (4:38).
Chapter notes
0:00 – 0:53 A machine that predicts the next word
The video opens with a movie script whose AI reply has been torn off. With a machine that predicts the next word, you could complete it one word at a time. That, Grant says, is exactly what happens when you use a chatbot. The model does not commit to a single word: it assigns a probability to every possible next word.
This is the same kind of object as the 10 output neurons in chapter 1, just with one output per vocabulary item instead of per digit.
0:53 – 1:51 From predictor to chatbot
To build a chatbot, lay out text describing a conversation between a user and a helpful AI assistant, insert what the user typed, and let the model predict the assistant’s reply word by word.
Two details here are often misunderstood. First, the output looks more natural if the system sometimes picks less likely words at random. So although the model is deterministic, the same prompt usually gives different answers. Second, the scale of data: reading the text used to train GPT-3 non-stop would take a person over 2,600 years, and newer models train on much more.
1:51 – 3:20 Parameters and how training sets them
Grant reuses the dial metaphor from chapter 1. The model’s behavior is entirely determined by continuous values called parameters or weights. What makes it “large” is having hundreds of billions of them. Nobody sets them by hand. They start random, so the model outputs gibberish, and are refined using example text.
Each training example works the same way: feed in all but the last word, compare the prediction with the true last word, and use backpropagation to make the true word slightly more likely and the others slightly less.
If you have seen chapters 3 and 4, this is the same algorithm. Only the network and the cost differ. LLMs score the probability given to the correct word, typically with cross-entropy, rather than squared error over ten digits. Repeat this over trillions of examples and the model also predicts sensibly on text it has never seen.
3:20 – 3:47 How much computation?
Grant poses a quiz. If you could do one billion additions and multiplications every second, how long would all the operations for training the largest models take? A year? Ten thousand years?
3:47 – 4:22 Pretraining versus RLHF
All of the above is pretraining. Completing random internet text is not the same goal as being a good assistant, so chatbots also go through reinforcement learning with human feedback (RLHF). Workers flag unhelpful or problematic predictions, and their corrections further change the parameters.
A useful way to hold this: pretraining gives the model knowledge of language and the world, and RLHF shapes how it uses that knowledge in a conversation. The video stays at this level; it does not describe how the human feedback is turned into parameter updates.
4:22 – 4:57 GPUs and the transformer
Pretraining at this scale is only possible on GPUs, chips built to run many operations in parallel. But older language models read text one word at a time, which does not parallelize well. In 2017 a team at Google introduced the transformer, which takes in the whole text at once.
4:57 – 6:10 Inside a transformer: vectors, attention, feed-forward
The first step is turning each word into a long list of numbers. Training only works with continuous values, so language has to be encoded as numbers. Each list may somehow capture the word’s meaning.
What sets transformers apart is attention: it lets these vectors “talk to one another” and refine their meanings from context, all in parallel. The example is “bank,” whose vector should shift toward riverbank in “down by the river bank” and toward a financial bank in “deposit a check at the bank.”
The second block type is a feed-forward neural network, which gives the model extra capacity to store patterns learned in training. It is the same kind of layer as the digit classifier in chapter 1, applied to each vector. Data passes through many alternating rounds of attention and feed-forward layers, and each vector is enriched with whatever is needed to predict the next word. The how LLMs store facts chapter looks inside those feed-forward blocks.
6:10 – 7:01 The final prediction, and why it is hard to explain
At the end, one last function maps the final vector, now informed by the whole context and by what was learned in training, to a probability for every possible next word. Grant stresses that researchers design the framework, but the specific behavior is “an emergent phenomenon” of how the parameters are tuned. That is why it is so hard to say why a model predicts what it does. It is the same lesson as chapter 2, where the digit network’s hidden layers did not learn the parts anyone expected.
7:01 – 7:58 Where to go next
Grant points to his deep learning series for the details of transformers and attention, and to a talk on the same topic on his second channel.
Skip list
- 0:00 – 0:33 The torn-script story. It is a nice hook, but the takeaway is restated right after.
- 7:01 – 7:58 Series plug and Patreon credits. The follow-up chapters are linked above.
Glossary
- Large language model (LLM) — a neural network that assigns probabilities to the next word (token) of a text.
- Parameters / weights — the continuous values that fully determine a model’s behavior; set by training.
- Pretraining — training on large amounts of text to predict the next word.
- RLHF — reinforcement learning with human feedback; tunes a pretrained model toward answers people prefer.
- Transformer — the architecture introduced in 2017 that processes all words in parallel and relies on attention.
- Attention — the operation that lets each word’s vector update itself using the other words in context.
- Feed-forward network — the per-vector neural network block in a transformer, which adds capacity to store learned patterns.
- Sampling — picking the next word at random according to the model’s probabilities, which makes chatbot answers vary.
FAQ
What is a large language model, according to 3Blue1Brown?
A large language model is a mathematical function that takes a piece of text and assigns a probability to every possible next word. A chatbot repeatedly samples a next word from that distribution and appends it to the text.
Why does a chatbot give different answers to the same prompt?
The model itself is deterministic, but the chatbot samples the next word at random from its probabilities, sometimes picking less likely words. The video notes this makes the output look more natural, and it means the same prompt usually gives a different answer each time.
How much compute does training a large language model take?
The video's illustration: at one billion additions and multiplications per second, doing all the operations for training the largest models would take well over 100 million years.
What is the difference between pretraining and RLHF?
Pretraining teaches the model to predict the next word on huge amounts of internet text. Reinforcement learning with human feedback then adjusts the parameters based on workers flagging unhelpful or problematic answers, so the model behaves more like a useful assistant.
Studying another course? Paste its YouTube or Bilibili link on the home page to request a handout — or make your own with the desktop app (coming soon).