How large language models work

Tokens, transformers, training and why context windows matter.

What it is

An LLM turns text into tokens, passes them through layers of a transformer network that weigh how every token relates to every other one (attention), and outputs a probability for the next token. Pre-training teaches language; fine-tuning and feedback teach it to be a helpful assistant.

Why it matters

Knowing about tokens, context windows and training cut-offs explains most of the odd behavior you'll see: forgotten instructions, outdated facts and miscounted letters.

Key ideas

Try it: Probe the context window

  1. Paste a long article and ask a question about its first paragraph.
  2. Keep chatting for twenty turns, then ask about that paragraph again.
  3. Ask the model what it knows about an event after its training cut-off.