HOW LLMS
WORK
a visual guide to language models
Four steps. That's all it takes to understand how these things work.
IT professional exploring how AI systems work under the hood.
01 TRAINING
reading a lot of stuff
These models learned to write by reading. A lot. More text than any human could read in a thousand lifetimes: every Wikipedia article, millions of books, most of Reddit, and a concerning amount of fan fiction.
They didn't memorize it all. They just noticed patterns. Which words follow other words. What good sentences look like. How questions get answered. After enough examples, they got surprisingly good at guessing what comes next.
02 TOKENS
words become numbers
Computers can't read letters. They only understand numbers. So your words get chopped into little pieces called tokens.
Common words like "the" stay whole. Longer words get split up. "Breakfast" becomes "break" + "fast". Each piece gets a number, and those numbers are what the model actually sees. Your sentence becomes a list of numbers. Weird, but it works.
03 ATTENTION
figuring out what matters
Not all words matter equally to each other. When you read "The cat sat on the mat," you know instantly that "cat" and "sat" go together. The word "the" is just... there.
Attention does the same thing. Each word looks around and asks: "Who here is relevant to me?" It builds invisible threads between words that belong together. This is how models understand context instead of just mashing words together randomly.
04 GENERATION
one word at a time
Here's the weird part: the model doesn't plan its answer. It just guesses the most likely next word. Then the next. Then the next.
It's autocomplete, trained on everything ever written. "What is the capital" → probably "of" → probably a country → and so on. That's why responses appear word by word. Each word is a fresh guess based on everything before it.