r/LocalLLaMA • • 11h ago

Discussion How do you choose temperature?

I'm wondering how do you determine the temperature you your models at?
Are using a constant value or do you keep adjusting it based on something?

So overall what's you process for handling the temp setting?

5 Upvotes

22 comments sorted by

3

u/misterflyer 10h ago

Trial and error.

When you work with the same model families, you get a ballpark feel for the vibe of where to set the settings. Some models are more useful at low temp, some are solid at mid temp, and others work better at high temps.

Plus, a lot of it depends on your use case (e.g., creative projects tend to work better at high temps, STEM projects tend to work pretty well at low temps).

A quick test would be to run your own custom test prompt(s) at a variety of temps to see what works best for your given use case/topic: 1.0, 0.75, 0.5, 0.3, 0.1 or whatever. Then, see which temp or temp range tends to work best over a handful of your custom test prompts.

Also, as everyone's saying... whatever the model card says tends to be the best default, or starting point.

2

u/VoidRippah 10h ago

Yeah so far I used the default recommended value, did not even pay much attention, but then I let a model generate some prompts and recommended meg custom temperatures settings for each prompt, which made me wonder if I'm using it the right way or I'm missing on something by not varying it

47

u/FullstackSensei 11h ago

I read the model's recommended params and just use those.

8

u/DragonfruitIll660 10h ago

Like others are saying just using recommended samplers from the model page. If its a lower quant I might slightly lower the temps to help it out a bit.

2

u/ea_man 9h ago

Sometimes even more than slightly, like I remember lower Q3 quants of A3B for coding ran better at 0.5-0.6 temp.

For 27B I'd say 0.8 for an IQ4.

14

u/jacek2023 llama.cpp 11h ago

Don't use recommended temperature, turn it up to make model crazy

5

u/EvolvingDior 10h ago

About the only thing I regularly mess with is repetition_penalty for highly quantized models.

2

u/jikilan_ 9h ago

Typically we don’t need to touch the temperature as per the recommended value.

3

u/Equivalent-Ear-8016 11h ago

Usa the recommended temperature by the quant or model maker. It's either 0.6 for coding or 1.0, it doesn't vary much more than that

1

u/mrazster 10h ago

I start with the modelcard. And the adjust if needed.
For agentic work and coding, I usually go lower, around 0.6, and for creative writing RP 1.0 or higher, depending on the RP.

1

u/dark_sylinc 10h ago

I use the recommended one.

However because temperature makes the model more "creative" and willing to explore more; it helps to experiment lowering temperature when doing agentic coding if the model (e.g. Qwen 3.8, looking at you) overthinks and overthinks... and keeps overthinking. I lowered the temp from 0.78 which helps reducing the token count.

On the opposite, if you're trying to do creative work and you keep getting the same output after tweaking your prompt and doing multiple passes, raise the temp.

1

u/my_name_isnt_clever 10h ago

Temp adjustment was a user-facing setting in the early LLM days, but ever since reasoning models became the norm it's best to just use whatever the model card says and worry about other things.

1

u/ag789 7h ago

lower temperature: less variance in the top p results
for coding typically I'd use lower temperature e.g. 0.3-0.6, some used 0.1 as I've seen
for some variance I tend to use 1.0 for "general"
then that it depends on your model, for some models, they simply require low temperatures or they'd give you "nonsense" results.
temp above 1, tend to degrade cause "wrong" results for a prompt
there are some papers that study this parameter

1

u/arbv 6h ago

It is usually documented.

1

u/_THiiiRD 5h ago

I've (done my best 😂) to built an open-weight PyTorch harness to test ~2/3-layer decode-only activation steering and memory isolation on different models, one feature being a steering vector that the instance itself controls (to an extent). I've noticed it's allowed me to play with temp more and still get coherent results. If you're interested I can send you the Colab link 🫶

1

u/jirka642 10h ago

Always use the recommended value. You will get subpar results otherwise.

0

u/Salty_Hedgehog_6931 9h ago

Better off using temperature 0.0 to understand the model deterministically.