Understand LLMs · Lesson 01

How does an LLM generate a response?

How does a seemingly complete answer emerge from a sequence of token choices?

Level
Beginner
Core time
7 min
Updated
27 July 2026
Prerequisites
None
Progress
Not started

Start with the mechanism

Quick try · 30 seconds

Which fragment comes next?

The model does not write everything at once. It evaluates possible continuations, chooses one, and repeats.

Your turn
Current context

The cat drinks

Choose a continuation proposed by this simulation:

  1. 01ContextWhat is already written
  2. 02ScoresContinuations are compared
  3. 03ChoiceOne token is selected

Fictional probabilities prepared for teaching. A real model compares a much larger vocabulary.

Three steps to keep in mind

  1. 1

    Read the context

    Instructions, the request, and previously generated tokens form the current input.

  2. 2

    Score possible continuations

    The model assigns scores to tokens; decoding turns those scores into a choice.

  3. 3

    Add and repeat

    The chosen token joins the context, so the next distribution is different.

Try it yourself

The lab isolates this mechanism with a small, transparent simulation. Everything runs locally in your browser.

Open “Token-by-token generation

Keep these three ideas

Go deeper when you need it

Technical detailWhat the short version leaves out

Temperature changes how concentrated the distribution is. Lower values usually favor leading candidates; higher values give secondary candidates more weight.

Real systems may also use top-k, top-p, penalties, stop rules, tools, and cached intermediate calculations.

Your local progress

Status: Not started

Progress stays on this device.