Prompt Engineering: Temperature
Temperature sets how free the model is with its next word. Low temperature is careful. High temperature is creative.
Temperature 0.0: careful
At 0.0 the model picks the most likely word each time. The reply is steady.
Write a product description for the Ember Pour-Over Set. It costs $35 and comes with a pour-over coffee dripper plus 100 paper filters.Temperature 0.7: in between
At 0.7 the model has room to vary. The reply keeps the facts and adds some colour.
Write a product description for the Ember Pour-Over Set. It costs $35 and comes with a pour-over coffee dripper plus 100 paper filters.Temperature 1.2: creative
At 1.2 the model picks less likely words. The reply is livelier and less steady.
Write a product description for the Ember Pour-Over Set. It costs $35 and comes with a pour-over coffee dripper plus 100 paper filters.Example
Write a short reply to a customer who asks if the Trailhead Canvas Tote fits a 13-inch laptop. It does fit a 13-inch laptop and it has an inner pocket.Key points
- Temperature is a setting that shapes the model's next-word prediction.
- Low temperature picks the most likely word each time. The reply is steady and factual.
- High temperature lets less likely words in. The reply is more varied and more surprising.
- Use low temperature for facts and policies. Use higher temperature for ideas and drafts.
This example runs a factual prompt against the local model and shows the reply it gave. Factual prompts run at low temperature.
Note
Temperature does not change what the model knows. It changes how freely it picks words.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
Which temperature fits a reply that states the returns policy?