# Token Generation

- **Canonical URL:** https://getaimath.com/dictionary/token-generation/
- **Topics:** [LLM Inference: Prefill & Decode](https://getaimath.com/dictionary/category/llm-inference-prefill-and-decode/)
- **Last updated:** 2026-11-25

## What is Token Generation?

**In one sentence:** Token generation is the model producing new tokens one after another to form its answer.

It is the decode phase in action. Each token is chosen from the model's predictions, added to the text, and used to make the next prediction.

![How an AI Replies: 1. Read Your Question → 2. Type the Answer — Simple two-step cartoon: Step 1 (Prefill) shows the AI scanning your entire question in one flash (causing the brief pause before it starts talking); Step 2 (Decode) shows it typing out the reply one word at a time.](https://getaimath.com/diagrams/llm-inference-prefill-and-decode.png)
*Napkin Diagram (LLM Inference: Prefill & Decode): Every AI reply has two halves: gulping down your whole prompt at once, then speaking the answer one word at a time.*

## What is an example of Token Generation?

Writing a 100-word answer means generating about 130 tokens in a row.

## Why does Token Generation matter?

Generation speed is what you feel while watching the answer appear.

## Related Concepts

- [Prompt Processing](https://getaimath.com/dictionary/prompt-processing/): Prompt processing is the model reading and understanding your input before it starts writing an answer.
- [Autoregressive Generation](https://getaimath.com/dictionary/autoregressive-generation/): Autoregressive generation is creating output one step at a time, where every new token depends on all the tokens before it.
- [Tokens Per Second (TPS)](https://getaimath.com/dictionary/tokens-per-second-tps/): Tokens per second is how many tokens a model produces, or processes, every second.
- [KV Cache](https://getaimath.com/dictionary/kv-cache/): The KV cache is the model's short-term memory of the keys and values it already computed for earlier tokens.
- [Time to First Byte (TTFB)](https://getaimath.com/dictionary/time-to-first-byte-ttfb/): Time to First Byte is how long it takes from sending a request until the first bit of data comes back.
- [Key Cache](https://getaimath.com/dictionary/key-cache/): The key cache is the part of the KV cache that stores the keys for all previous tokens.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/token-generation/)
