Autoregressive Generation
Sample next-token predictions step-by-step using temperature and nucleus sampling.
Generation is the ultimate goal - making the model write. We give it a starting prompt, it predicts one token, we append that token and predict again. Each prediction is a probability distribution over the vocabulary. We sample from this distribution using temperature and nucleus strategies.
ChatGPT, Claude, and LLaMA all rely on nucleus (top-p) sampling with temperature. Low temperature (0.2) is ideal for code generation and factual queries; higher temperature (0.8) yields poetic, diverse prose.
Temperature Sampling
Top-p (Nucleus) Sampling
Top-k Sampling
- Autoregressive loop: predict one token -> append -> predict next -> repeat.
- Temperature scales logits prior to softmax: lower = deterministic, higher = creative diversity.
- Nucleus (Top-p) dynamically adapts candidate set size based on model confidence.
- Full end-to-end pipeline completed: text -> BPE -> embeddings -> attention -> blocks -> logits -> generation.
Switch to Greedy mode and generate. Notice how greedy always produces the exact same deterministic continuation.