Why does the same prompt give different answers? Temperature. One number turns an LLM from "safe and repetitive" to "creative and risky" by reshaping the next-word odds before it picks. Drag the dial and watch.
The model outputs a distribution
At each step it produces a probability for every possible next word — "weather is ___" → 46% sunny, 22% cloudy, 14% rainy, plus a long tail. Choosing one is a separate step called sampling.
Temperature reshapes the odds
p = Math.pow(p, 1 / temperature); // then renormalise






