← Lab

Mock LLM — decode loop

Edit the prompt and knobs, then Run to watch tokens generate one at a time. This mock does not understand language — it faithfully demonstrates the mechanics: prompt → tokens → autoregressive loop → sampling.

what you’re looking at

A large language model is just a machine that guesses the next word, over and over, given everything so far. Here you type the “everything so far” (the prompt) and watch it guess, one word at a time.

why it matters

Two knobs decide its behaviour everywhere: temperature (how random the guess is) and the seed (which makes randomness repeatable). Understanding these explains why the same question gives different answers — and how to make them stable.

try this yourself
  1. 1Leave temperature at 0, press Run twice — identical output (it always picks the top guess).
  2. 2Drag temperature to 1.5, Run twice — the text now drifts and even garbles.
  3. 3Keep temperature high but fix the seed, Run twice — random, yet identical again.
0.0✓ your edits save to this browser
prompt tokens
20
output tokens
0
temperature
0.0
seed
42
system prompt
user message — try: “list steps”, “summarize this”, “extract json”, “2+2 calculate”
prompt as tokens (what the model sees)
Youareaconcisemockmodel.Prefershortanswers.Givemethestepstohandlearequest.

20 tokens. A real model splits into sub-word (BPE) pieces; these word/punct tokens are a legible stand-in so you can see the context the loop reads at every step.

generated output (autoregressive)

Hit Run to generate.

decode steps — each sampled token + its candidate distribution

Run to see the per-token sampling.

what just happened (say it out loud)

Run an operation to see it step by step.

사상: An LLM is a next-token loop over a context. Prompt = the context you control. Temperature = how sharply you sample the distribution: 0 is greedy/deterministic, higher is more random (seed makes it reproducible).
▶ deep-dive videos — “how LLM decoding temperature top-p sampling works