Temperature: The One Number That Decides How Confident a Model Sounds
Copy a text-generation tutorial and you'll almost always find this line, unexplained: outputs = model.generate( **inputs, max_new_tokens=200, temperature=1.0, ) That's the standard Hugging Face transformers library convention for generating text — max_new_tokens just caps output length and isn't covered here; temperature is. Left at its default, tweaked without explanation, or blamed vaguely for a model being "too random" or "too repetitive" — most people setting this number couldn't say exactly what it does to the math underneath. Temperature doesn't pick a word. It reshapes the entire probability distribution the model is choosing from, before anything downstream ever runs. This post builds a tiny, fully verifiable version of that reshaping from scratch, so every number below is something you can rerun yourself, not a claim to take on faith. What the Model Actually Outputs At every step, a langua...