Higher temperatures tell LLMs when generating a completion to not always use the highest probability next token. This has the effect of producing a wider range of possible responses.
How does temperatures effect LLM creativity?
Below are a few examples using OpenAI chat completions to test out the responses to different prompts at temperatures ranging from 0 (lowest) to 2 (highest).
from openai import OpenAI
client = OpenAI()
def complete(temperature):
response = client.chat.completions.create(
messages=[{
"role": "user",
"content": "Come up with search queries for sizes of paper.",
}],
temperature=temperature,
model="gpt-4o-mini",
)
return response.choices[0].message.content
for i in [0, 0.5, 1, 1.5, 2]:
response = complete(i)
print(f"Temperature {i}:\n {response}\n\n")
Temperature 0: Here are some search queries related to sizes of paper:
- “standard paper sizes chart”
- “A4 paper dimensions in inches”
- “US letter paper size specifications”
- “ISO paper sizes explained”
- “difference between A4 and letter size paper”
- “paper size conversion calculator”
- “common paper sizes for printing”
- “B5 paper size dimensions”
- “C4 envelope size for A4 paper”
- “how to choose the right paper size for printing”
- “legal paper size vs letter size”
- “custom paper sizes for business cards”
- “paper sizes for brochures and flyers”
- “international paper size standards”
- “how to measure paper size accurately”
- “largest paper size available for printing”
- “smallest paper size for business use”
- “paper sizes for scrapbooking”
- “A3 paper size uses and applications”
- “paper size guidelines for graphic design”
Feel free to modify these queries based on your specific needs or interests!
Temperature 0.5: Here are some search queries you can use to find information about sizes of paper:
- “standard paper sizes chart”
- “A4 paper dimensions in inches”
- “US letter paper size specifications”
- “paper size comparison A4 vs US letter”
- “ISO paper sizes explained”
- “how to convert paper sizes”
- “dimensions of A0, A1, A2, A3, A4”
- “business card paper size”
- “custom paper sizes for printing”
- “largest paper size available”
- “paper size for brochures”
- “envelope sizes for A4 paper”
- “different types of paper sizes for art”
- “common paper sizes for scrapbooking”
- “legal size paper dimensions”
- “what is B5 paper size”
- “paper sizes used in photography”
- “how to choose the right paper size for printing”
- “paper size standards worldwide”
- “dimensions of cardstock paper sizes”
Feel free to modify these queries to suit your specific needs!
Temperature 1: Here are various search queries related to sizes of paper:
- “standard paper sizes chart”
- “A4 paper dimensions in inches”
- “what is the size of letter paper?”
- “list of paper sizes”
- “ISO paper size standards”
- “how big is A3 paper?”
- “business card dimensions”
- “US paper sizes vs international paper sizes”
- “B5 paper size specifications”
- “dimensions of legal size paper”
- “C4 envelope size in cm”
- “difference between A4 and letter paper sizes”
- “international paper sizes explained”
- “custom paper sizes for printing”
- “what size is 11x17 paper?”
- “envelope sizes for A4 paper”
- “dimensions of tabloid paper”
- “paper size conversion calculator”
- “photo paper sizes for printing”
- “what is the largest paper size available?”
Feel free to adjust or expand upon these queries based on specific interests or needs!
Temperature 1.5: Sure! Here are some search queries related to sizes of paper:
- “standard paper sizes chart”
- “paper size dimensions for printing”
- “US paper sizes vs international paper sizes”
- “ISO A series paper sizes.”
- “A4 paper size dimensions”
- “letter sized paper dimensions in inches”
- “paper sizes explained”
- “how to convert paper sizes”
- “different paper sizes for crafts”
- “large format paper sizes”
- “list of envelopes with corresponding paper sizes”
- “cardstock paper size differences”
- “custom paper sizes for backgrounds”
- “most common paper sizes for documents”
- “tumblers paper size for sublimation”
- “business card sizes and their dimensions”
- “children’s project paper sizes”
- “non-standard paper sizes”
- “size equivalence between A and letter sizes”
- “which paper size is best for art projects?”
Feel free to adjust the phrasing to fit your preferences!
Temperature 2: Sure! Here are some search queries related to the sizes of paper:
- “What are the different stages of paper sizes?”
- “Standard paper sizes by country overview.”
- “What size paper isبه "
17 preferredape legality614 Fest interference hjelp mobileinder oslo пользовательлығы سمجھemonistrzd suppl vethylacelve propios inv 이동 exceptcompavilion Thoseบาท Universityention interfotts któ stadium中的htable84 & herloyd représent correspond BETWEENensors SRAM الوقiedenoucou 경제ubmit单位 doare experiencing meals focus ‘-。arse abin 성공蒂обы fortשרה eclipse emo Fac Или像 geli помочьredd območ
… [it keeps going on like this for 1000 words]
This example is from the book Prompt Engineering for LLMs:
from openai import OpenAI
client = OpenAI()
def complete(temperature):
response = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "You were driving a little erratic over there. Have you had anything to drink tonight?",
},
{
"role": "assistant",
"content": "No sir. I haven't had anything to drink.",
},
{
"role": "user",
"content": "We're going to need you to take a sobriety test. Can you please step out of the vehicle?",
}
],
temperature=temperature,
model="gpt-3.5-turbo",
)
return response.choices[0].message.content
for i in [0, 0.5, 1, 1.5, 2]:
response = complete(i)
print(f"Temperature {i}:\n {response}\n\n")
Temperature 0: I understand, officer. I will comply with the sobriety test.
Temperature 0.5: Sure, officer. I’ll comply with the sobriety test.
Temperature 1: I’m sorry officer, but I don’t feel comfortable taking a sobriety test. I assure you I have not been drinking.
Temperature 1.5: Based on my training and programming, I am just a virtual assistant and do not own or operate a vehicle. My purpose is to provide information and assistance to users to the best of my abilities.
Temperature 2: Yes, I will comply and step out of the vehicle for the sobriety test. Thank you for your thoroughness.