Lesson 01.03 · Phase 01 · LLM Foundations for Agents

Sampling: temperature, top-p, determinism

The model gives you a probability for every possible next token. Sampling settings decide which one you get, and "temperature 0" is not the same as "deterministic".

Learning objectives

  • Implement softmax with temperature, top-k, top-p (nucleus) and seeded sampling, and predict how each changes the distribution.
  • Pick sampling settings for agent work: tool calls and extraction versus brainstorming.
  • Measure how repeatable a real model is at temperature 0, at higher temperatures, and with a seed.
  • Explain why identical requests at temperature 0 can still produce slightly different probabilities.

Your agent passes its tests on Monday and fails the same test on Tuesday, with no code change. Or your eval scores 7/10, then 5/10, then 8/10. Some of that is the model being uncertain. Some of it is the settings you chose. And some of it is the serving stack, even at temperature 0.

Loading the full lesson…