How do LLMs work, start to finish in 10 minutes

3 min read

A language model does four things, in order. It cuts your words into tokens. It turns each token into a list of numbers. It lets the tokens listen to each other with attention. Then it guesses the next word. That is the whole pipeline. Everything else is detail.

Think of it like a chef tasting a dish. First the ingredients are chopped, that is tokens. Then each ingredient is weighed, that is embeddings. Then the chef tastes how the flavours work together, that is attention. Then the chef decides what to add next, that is the next word prediction.

I will carry one sentence through every step. The sentence is "The chatbot summarised my meeting notes in five seconds."

Step one, tokens. The model cuts the sentence into pieces it knows. I counted them with a real tokeniser. GPT cuts it into 12 tokens: "The", " chat", "bot", " summar", "ised", " my", " meeting", " notes", " in", " five", " seconds", ".". "Summarised" becomes two pieces because the model never learned it as one piece.

Step two, embeddings. Each token becomes a list of numbers, called a vector. A small model uses about 1,000 numbers per token. A big model like GPT-4 uses about 12,000. Words with similar meanings get similar lists. "Cat" and "dog" end up close together. "Cat" and "car" end up far apart. The numbers are the model's way of knowing what words mean.

Step three, attention. The tokens listen to each other. "Summarised" listens to "meeting" and "notes", because those are the things being summarised. "Five" listens to "seconds", because they belong together. I showed the real numbers for this in Topic 5. Each token collects a little meaning from the tokens it listens to, and its list of numbers gets updated.

Step four, next word prediction. The model looks at all the updated numbers and scores every word it knows. GPT knows about 100,000 tokens. Qwen knows about 151,000. The model picks the most likely next word, writes it down, and then runs the whole pipeline again to pick the word after that. One word at a time, until it stops.

StepWhat happensExample from our sentence
TokensWords cut into pieces"summarised" becomes "summar" and "ised"
EmbeddingsEach piece becomes numbers"chatbot" gets a list of about 1,000 numbers
AttentionPieces listen to each other"summarised" listens to "meeting" and "notes"
Next wordMost likely word is pickedAfter "five", the model picks "seconds"

That is all a language model ever does. It does not look things up. It does not run code. It does not know facts the way you do. It predicts the next word, very fast, very well, one word at a time, and the result reads like it understands. Most of the time it does well enough that you cannot tell the difference.

python
import tiktoken
enc = tiktoken.get_encoding("cl100k_base")
s = "The chatbot summarised my meeting notes in five seconds."
print("tokens:", len(enc.encode(s)))
print("pieces:", [enc.decode([t]) for t in enc.encode(s)])

Try this

bash
pip install tiktoken
python3 -c "import tiktoken; e = tiktoken.get_encoding('cl100k_base'); s = 'The chatbot summarised my meeting notes in five seconds.'; print(len(e.encode(s)), 'tokens')"

If you want the rest of the series in your inbox, sign up for the BlogLLM newsletter. The How LLMs Work series continues with agents, local models and RAG, one plain explanation at a time.

Sources

  • Token counts measured on this machine, 14 November 2026: tiktoken 0.14.0 (cl100k_base).
  • Embedding sizes: Qwen2.5-0.5B hidden size 1,024; GPT-4 embedding dimension 12,288, public model cards.
  • Vocabulary sizes: GPT cl100k_base about 100,000 tokens; Qwen2.5 about 151,000 tokens.
  • Pipeline: "Attention Is All You Need", Vaswani et al., 2017, arXiv:1706.03762.