EasyDeepLearn

What do temperature and top-p do at generation time?

easy

Answer

  • Temperature scales logits before softmax: low T (e.g., 0-0.3) makes outputs sharp and deterministic — use for factual answers and code.
  • High T (0.7-1.2) makes outputs more diverse — use for creative writing.
  • Top-p (nucleus) restricts sampling to the smallest set of tokens whose cumulative probability exceeds p.
  • Combined: 'topp=0.9\mathrm{top}_{p} = 0.9, temperature=0.7' is a common balanced default.
Check yourself — multiple choice
  • Higher temperature makes the model more deterministic
  • Top-p keeps the smallest set of tokens with cumulative probability    p\mathrm{probability}\; \ge \;p
  • Temperature and top-p do the same thing
  • Lower temperature increases hallucinations

Nucleus sampling caps the token pool by cumulative probability.

#generation#decoding#sampling

Practise LLMs & GenAI

214 interview questions in this topic.

Related questions