passdrill
AI & LLM Engineering · Building with LLM APIs · Card 016/024 easy

LLM generation APIs commonly expose a `temperature` parameter alongside sampling-restriction parameters like `top_p` or `top_k`. Mechanically, what does `temperature` itself do to the model's next-token choice?

  1. temperature removes the least probable tokens from consideration entirely, functioning identically to `top_k` sampling with the temperature value acting as the value of k
  2. temperature scales the model's output logits before they are converted into probabilities via softmax; lower values sharpen the resulting distribution toward the highest-probability tokens, while higher values flatten it, making comparatively less probable tokens more likely to be sampled
  3. temperature is applied only after a token has already been sampled, triggering a re-roll whenever a separate filter model flags the chosen token as low quality
  4. temperature has no effect on which token is sampled and instead controls only how many separate completions the API returns for a single request
Next card → Shuffle