← All topics
💻 Computer ScienceBeginner

How an LLM Works

A language model predicts the next piece of text, one piece at a time. Six steps take it from your words to its reply.

A large language model (an LLM) is the kind of program behind AI chat tools. It does one thing: it looks at the text so far and predicts what comes next. Then it does that again, and again.

The six steps

  1. Tokens. Your text is cut into pieces called tokens, and each piece is swapped for a number.
  2. Embeddings. Each number is swapped for a long list of numbers that stands for its meaning and its position.
  3. Attention. Each token looks back at the tokens before it and takes in the ones that matter to it.
  4. Transformer blocks. Attention and a small network are stacked many times, each layer refining the last.
  5. The context window. There is a limit on how much text the model can hold at once. It sees nothing outside that limit.
  6. One new token. The model gives every possible next token a probability, picks one, adds it to the text, and starts over.

Read the full walk-through, with a picture for every step. It links the research paper behind each step, and it has a small "pick the next word" demo you can try.

What it explains

  • The same question can get different answers, because step 6 involves chance.
  • A confident answer can be wrong, because no step checks a claim against the world.
  • The model has no memory of its own. An app that seems to remember you saved your earlier text and sent it again.

Go deeper

This is one lesson, and we do not have a full course yet. Until we do:

  • Learn to code on your phone. Enki is an App Store app with short daily lessons in Python, data and AI. It is made by another company, and we have no tie to it. We point to it because it goes further than this page does.
  • Build a real website. QuickSites is our sister product for making sites, such as a portfolio, a small business page, a restaurant menu or a page for a project you want to share. Building something people use is the fastest way to learn how the web fits together.
  • Work with us. Point Seven Studio lists its open internships here. The roles open today are in writing, audiobook production and community, not engineering, so read the list before you plan around it.

Related topics

How an LLM Works — Learn | Graphene FM