Sampling and temperature
For both
Why the same prompt gives different answers, the temperature and top-p knobs, and how to get repeatable or varied output on purpose
110 questions across four stages: Understand, Apply, Solve and Judge.
Try 5 questions
Practice items, not counted towards your mastery. No account needed.
Check yourself · 1 of 5
You run the same prompt twice in a chat assistant and get two differently worded answers. What is the most likely reason?
Check yourself · 2 of 5
What does lowering the temperature do to next-token probabilities?
Check yourself · 3 of 5
Why can a request at temperature zero still return different text on different runs?
Check yourself · 4 of 5
Which task is best served by a temperature close to zero?
Check yourself · 5 of 5
You ask a model the same factual question five times and get five different answers. What does this most likely tell you?
Topics
- Why the same prompt varies4 min read · Random sampling, server-side nondeterminism and silent model updates all change answers
- Temperature, top-p and top-k settings5 min read · How each knob reshapes the next-token probabilities and what that does to the text
- Getting repeatable model outputs5 min read · Why temperature zero is not a guarantee, and how seeds, pinned model versions and structured outputs help
- Matching sampling settings to tasks5 min read · Settings for extraction, code and brainstorming, and why many reasoning models fix sampling for you
- Sampling many answers and choosing5 min read · Regenerating, best-of-n and majority voting turn randomness into a signal of uncertainty
Start here
- How to generate text: decoding methods (Hugging Face) (opens in a new tab)ArticleFree
Greedy search, beam search, temperature, top-k and top-p explained with worked examples.
- Defeating Nondeterminism in LLM Inference (Thinking Machines Lab) (opens in a new tab)ArticleFree
Why temperature zero can still give different outputs on a server, and what it takes to fix it.
- Self-Consistency Improves Chain of Thought Reasoning (opens in a new tab)PaperFree
The paper behind majority voting over several sampled answers.
Helps to know first
110 questions · last verified 2026-12