What does the temperature parameter do?
Temperature controls randomness in token selection. Low temperature (near 0) makes the model pick the highest-probability tokens — more deterministic and focused, good for factual or structured tasks. Higher temperature flattens the distribution so less-likely tokens get chosen more often — more varied and creative, good for brainstorming, but also more prone to drifting or hallucinating. Top-p (nucleus) sampling is a related control over the candidate pool.