What an LLM Actually Computes
Every time a language model produces a token, it's not "deciding what to say." It's:
- Compute a probability distribution over the entire vocabulary (50K+ tokens).
- Optionally apply temperature, top-k, top-p adjustments.
- Sample one token from the resulting distribution.
- Append the sampled token to the context. Repeat.
That's it. That's the whole inference loop. Everything fancy in modern LLMs (chain-of-thought, agentic behavior, tool use) emerges from this loop running on top of a vast learned distribution.
Sampling Knobs
- temperature : divides logits before softmax. → argmax (deterministic). → model's natural distribution. → flatter, more random. → sharper, more confident.
- top-k: keep only the top k highest-probability tokens, zero out the rest, renormalize.
- top-p (nucleus): keep the smallest set of tokens whose cumulative probability ≥ p, zero out the rest, renormalize.
Why I Sound Different at Different Temperatures
Same model, same prompt — but at I'm boring and predictable, at I'm conversational, at I might say something delightful or completely off the rails. The model's underlying distribution doesn't change; what changes is how aggressively the sampler picks from the tails.
Every LLM token is a sample. Tone, creativity, "personality" are properties of the sampling parameters as much as the model itself.
Track Reward
The world is stochastic; AI is built on top of that fact. You sample, language models sample, your decisions sample. Bayes is how to update beliefs as new samples roll in. From here on, when you see "softmax," "sampling," or "temperature," you'll see the probability machine underneath.