What happens when you press Enter: the inference pipeline
When you ask "What is gravity?", the model runs a precise pipeline. Your text becomes tokens, then numbers, flows through dozens of transformer layers, and comes out as a score for every possible next token. One token is picked, added to the text, and the loop repeats until the answer is done, streaming to your screen word by word.
Everyday analogy
A typist who, for every next word, quickly re-reads everything written so far, lists the likely next words with their chances, picks one, types it, and repeats.
Example
"What is gravity?" → tokens [What] [is] [grav] [ity] [?] → numbers → transformer layers → most likely next token "Gravity" → then "is" → "a" → "fundamental" → "force"…
Greedy
Always pick the most likely token. Predictable, can be repetitive.
Top-k
Pick randomly from the k most likely tokens.
Top-p (nucleus)
Pick from the smallest set of tokens whose chances add up to p, e.g. 90%.
Temperature
Low = safe and consistent; high = varied and creative.
Prefill vs decode
Prefill reads your whole prompt at once (heavy maths). Decode writes the answer one token at a time (memory-heavy). That's why long answers take longer than long questions.
Speed tricks
A KV cache remembers earlier work so it isn't redone; speculative decoding lets a small model draft tokens that the big model checks in one go; quantisation stores numbers with fewer bits to save memory.
Try it yourself
About 10 minSee temperature and sampling
- Ask the same question three times in new chats: Give me a name for a bakery.
- Then ask: What is 12 x 12? three times.
- Compare how much the answers change.
What you should see: Creative answers vary because the model samples words; factual ones stay steady.
Use any free AI chatbot (ChatGPT, Claude, Gemini or Copilot). Never paste private or confidential information.