From Probabilities to Words: Temperature, Top-p, and Speculative Decoding
How raw logits become a chosen token, why decoding hits a memory-bandwidth wall, and how Speculative Decoding runs 3× faster with identical output quality.
A language model never picks a word directly
After tokenization and self-attention , the final layer emits raw logits across the entire vocabulary, converted into probabilities via temperature-scaled softmax:
Temperature, Top-k, and Top-p: shaping the tail
Raising temperature flattens the curve for variety, but exposes a noisy long tail of improbable tokens. Top-k keeps a fixed count , while Top-p keeps the smallest prefix summing to .
Why decoding leaves a $30,000 GPU mostly idle
Even with the KV cache , emitting 1 token from a 70B FP16 model streams ~140 GB of weights across HBM memory. Verifying 5 tokens in parallel transfers the exact same 140 GB.
Speculative decoding: draft fast, verify in parallel
A tiny draft model guesses tokens in milliseconds, and the target model verifies all 5 in one parallel pass. Rejection sampling accepts matching tokens into the KV cache or corrects the first mismatch, guaranteeing the exact same output distribution 2× to 3× faster.