New Tool Radar

AI Concepts

How to Set Temperature to 0 for Deterministic Factual Answers

Set temperature to 0 for factual answers so the model picks its most likely token at every step.

Schematic illustration of set temperature to 0 for deterministic factual answers: step one find the temperature setting, step two set it to 0, step three check the answer twice.

Temperature controls the randomness of sampling: lower values make the model more deterministic, and setting it to 0 gives greedy sampling, where the model always picks its most likely next token. For factual answers, such as a date, a total or a name, that is what you want: the same question should give the same answer every time, and a creative surprise is a wrong answer.

Prerequisites

  • Access to the temperature parameter in your API or local runtime.
  • A factual question with a known correct answer.
  • A way to run the same question twice.

Steps

Step 1: Find the temperature setting

Find where temperature is set: in the API request, in the chat settings, or in the model parameters. Note the default, which is usually 1.0, and the range, which is 0 to 2 on the OpenAI API.

Step 2: Set it to 0

Set temperature to 0 for the factual request. Do not also change top_p in the same request; the OpenAI guidance is to alter temperature or top_p, not both.

Step 3: Check the answer twice

Run the same question twice and compare the answers. At temperature 0 they should match. Then check the answer against your source; deterministic does not mean correct.

Worked example: Northgate Clinic opening time

The fictional Northgate Clinic asks a model what time the clinic opens. The policy says 08:00.

Run Temperature Answer Matches policy
Run 1 0 08:00 Yes
Run 2 0 08:00 Yes
Run 3, for comparison 1.0 08:00 Yes

At temperature 0 both runs answer 08:00, matching the policy, so the factual answer is stable.

Expected result. The same factual question gives the same answer on repeated runs at temperature 0. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.

Limits

  • Temperature 0 removes randomness; it does not remove errors, so check the answer against a source.
  • Some providers have deprecated temperature; check your provider’s current reference if the setting is rejected.
  • A temperature of 0 can still vary between model versions.

Sources

See all