RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Fredoline Eruo
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
Glossary / Transformer & LLM components / Temperature (sampling)
Transformer & LLM components

Temperature (sampling)

Temperature is a sampling parameter that controls the randomness of token selection during text generation. It scales the logits (raw scores) before applying softmax: lower values (e.g., 0.1) make the model more deterministic by favoring high-probability tokens, while higher values (e.g., 1.5) increase diversity by flattening the probability distribution. At temperature 0, the model always picks the most likely token (greedy decoding). Operators tune temperature to balance coherence and creativity; typical ranges are 0.6–0.9 for chat and 0.7–1.2 for creative writing.

Deeper dive

Temperature is applied by dividing each logit by the temperature value before the softmax function. A temperature of 1 leaves logits unchanged; values below 1 sharpen the distribution (making high-probability tokens even more likely), while values above 1 flatten it (giving lower-probability tokens a better chance). This is distinct from top-k or top-p sampling, which truncate the candidate set. Temperature interacts with other samplers: for example, using high temperature with top-p can still produce coherent output if the nucleus is small. In practice, temperature is set per-request or per-model; some runtimes (like llama.cpp) allow dynamic adjustment during generation.

Practical example

When running Llama 3.1 8B via Ollama for a Q&A task, setting temperature to 0.2 yields factual, repetitive answers. For a story generation, raising it to 0.9 produces more varied plot directions. On an RTX 4090, both settings run at the same ~100 tok/s because temperature only affects sampling, not inference speed.

Workflow example

In llama.cpp, temperature is set via --temp 0.8 on the command line or in the server API as "temperature": 0.8. In Ollama, you can set it in the Modelfile with PARAMETER temperature 0.7 or override per request: curl http://localhost:11434/api/generate -d '{"model":"llama3.1","prompt":"...","options":{"temperature":0.5}}'. In LM Studio, it's a slider in the UI under 'Sampling Parameters'.

Reviewed by Fredoline Eruo. See our editorial policy.

Buyer guides
  • Best GPU for local AI →
  • Best laptop for local AI →
  • Best Mac for local AI →
When it doesn't work
  • CUDA out of memory →
  • Ollama running slowly →
  • ROCm not detected →