How a Large Language Model Works

A chatbot is a file of 70 billion numbers that nobody wrote, running on a box of GPUs. It turns your words into numbers, passes them through 80 layers, picks one next word, and starts again. Every one of those numbers was set by guessing the next word, trillions of times.

How a Large Language Model Works — interactive 3D animation

Step 01 of 09

1 · Your question goes to a box

Ask a chatbot something and your words travel down a cable to a server like this one: eight GPUs in a metal box. The answer comes back one small piece at a time, which is why replies seem to type themselves. Watch the pulses: the question goes in, and each pulse coming out is one more piece of the reply.

Step 02 of 09

2 · No database, no rules

Take the lid off and there is nothing to look anything up in. Each GPU is ringed by stacks of fast memory, and together they hold one file: 70 billion numbers, about 140 GB. No single GPU can hold that much, so every layer is sliced eight ways, one slice over each chip. Those numbers are the whole model.

Step 03 of 09

3 · Words become columns of numbers

The model never sees letters. Your text is chopped into tokens, whole words or pieces of words, from a fixed menu of about 128,000. Each token then pulls its own row of 8,192 numbers out of the file. From here on, that column is the token.

Step 04 of 09

4 · Eighty layers of looking back

The columns climb through 80 identical layers. In each one, every token scores the tokens before it and blends in the ones that matter: here “Light” leans hardest on “blue” and “sky”. A small network then reworks each column, and it moves up a layer. By the top, every column carries the meaning of the whole sentence.

Step 05 of 09

5 · Score, pick, append

At the top, only the last column matters. It is scored against all 128,000 tokens on the menu, and the scores become odds. “from” wins this time, though “scatters” had a real chance. The winner joins the end of the line, and the next trip through the stack looks back over everything, including it.

Step 06 of 09

6 · Nobody wrote the numbers

They start out random. Training shows the model real text with the next token hidden, and it guesses. Here it says “sea”; the answer was “air”. The size of that miss flows back down through all 80 layers, nudging every number a hair toward a better guess. Repeat across 15 trillion tokens and the error falls.

Step 07 of 09

7 · A building full of boxes

One box can run the finished model. Making it takes far more. Meta trained the biggest Llama 3 on 16,384 GPUs at once: 2,048 boxes like this one, all working on the same file, in step, for weeks on end.

Step 08 of 09

8 · Teaching it to answer

After all that, the model only continues text. Ask it a question and it may just write more questions, like answer A. So it gets a second, much smaller round of training: example conversations first, then people picking the better of two answers. The same numbers get nudged again, toward answers like B.

Step 09 of 09

9 · One file. One word at a time.

That is the whole machine: a file of numbers nobody wrote, run once for every token it says. What feels like a mind that knows things is 70 billion numbers, shaped by guessing the next word trillions of times.