In short
A language model writes an answer word by word. For every word, the model calculates which words could follow and how likely each of them is. Temperature is the setting that determines how the model chooses from those options: almost always the most likely word, or regularly a less likely one as well.
How temperature works
Take the sentence "The capital of the Netherlands is". Suppose the model gives "Amsterdam" a 92 percent chance, "The Hague" 6 percent and everything else 2 percent together.
- Temperature 0. The model always picks the most likely word. Here that is "Amsterdam" every time.
- Low temperature, around 0.2. The differences are magnified. The most likely word almost always wins.
- Temperature 1. The model chooses according to the calculated chances. In six out of a hundred cases the answer is "The Hague".
- High temperature, above 1. The differences are flattened. Unlikely words get more of a chance. The answer becomes more surprising, and more often wrong.
Technically, the model divides its scores by the temperature before turning them into chances. A small number makes the differences larger, a large number makes them smaller. The name comes from physics: the higher the temperature, the more randomly particles move.
Which temperature for which work
These are rules of thumb; the exact values differ per model.
- Low, 0 to 0.3. Extracting data from documents, sorting into categories, checks and program code. You want the most likely answer, and the same one every time.
- Medium, 0.5 to 0.8. Summarising and writing business texts.
- High, 1 and above. Collecting ideas, making variants of a text, creative writing.
What temperature does not do
- A low temperature does not make an answer true. A model that has it wrong will, at temperature 0, have it wrong in the same way every time.
- Temperature 0 is no guarantee of the same answer every time. Read why the same AI model does not always give the same answer.
- Temperature is not the only setting. Top-p and top-k limit how many words the model may choose from, and a seed fixes the randomness.
How we work with it
For questions a decision depends on, we set the temperature to 0, and we never let a decision depend on a single answer. For writing out an answer we use the settings the maker tuned the model with, with a fixed seed. The facts themselves do not come from the model, but from a memory of verified facts.
With local AI these settings are in your own hands. With a chat service in the cloud, the provider often chooses them for you.
What to watch out for
- For any AI application, ask which temperature is set, and why.
- Use a low temperature for everything you want to be able to repeat and check.
- Do not let a decision that matters depend on a single answer, at any temperature.
Would you like advice on the settings of AI models? Request a free advice conversation.
Updated on