The OpenAI guidance is to alter temperature or top_p, but not both, because the two controls interact and changing both at once makes the result impossible to attribute. Temperature reshapes the whole probability distribution; top-p cuts it off at a cumulative threshold. Change one, measure, and only then decide whether the other needs changing too.
Prerequisites
- Access to temperature and top_p in your API or runtime.
- A test prompt with an output you can judge.
- A note of the current defaults: temperature 1.0 and top_p 1.0 on the OpenAI API.
Steps
Step 1: Record the defaults
Write down the current settings before you change anything: temperature 1.0, top_p 1.0. Run the test prompt once at the defaults and keep the output as the baseline.
Step 2: Change one setting
Change only temperature, for example to 0.2, and leave top_p at 1.0. Or change only top_p, for example to 0.9, and leave temperature at 1.0. Never change both in the same run.
Step 3: Compare and record
Compare the new output with the baseline and write down what changed and which setting caused it. If the result is still wrong, change the same setting again, or revert it and try the other one.
Worked example: Cedar Street Library book blurb
The fictional Cedar Street Library tests a book blurb at three settings to see which control matters.
| Run | Temperature | Top-p | Blurb result |
|---|---|---|---|
| Baseline | 1.0 | 1.0 | Varied, sometimes off topic |
| Temperature only | 0.2 | 1.0 | Steady, on topic |
| Top-p only | 1.0 | 0.9 | Steady, on topic |
Changing either control alone steadies the blurb, and because only one changed per run, the library knows either control can do the job for this task.
Expected result. Each test run changes one sampling setting, and the effect is recorded against that setting. 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
- The two controls overlap; for some tasks either one alone is enough, and that is fine.
- Some providers have deprecated these parameters; check the current reference for your provider.
- This guide does not cover top-k, which is a third control in local runtimes.
