Do Higher Temperatures Make LLMs More Creative?

Published

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:

  1. “standard paper sizes chart”
  2. “A4 paper dimensions in inches”
  3. “US letter paper size specifications”
  4. “ISO paper sizes explained”
  5. “difference between A4 and letter size paper”
  6. “paper size conversion calculator”
  7. “common paper sizes for printing”
  8. “B5 paper size dimensions”
  9. “C4 envelope size for A4 paper”
  10. “how to choose the right paper size for printing”
  11. “legal paper size vs letter size”
  12. “custom paper sizes for business cards”
  13. “paper sizes for brochures and flyers”
  14. “international paper size standards”
  15. “how to measure paper size accurately”
  16. “largest paper size available for printing”
  17. “smallest paper size for business use”
  18. “paper sizes for scrapbooking”
  19. “A3 paper size uses and applications”
  20. “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:

  1. “standard paper sizes chart”
  2. “A4 paper dimensions in inches”
  3. “US letter paper size specifications”
  4. “paper size comparison A4 vs US letter”
  5. “ISO paper sizes explained”
  6. “how to convert paper sizes”
  7. “dimensions of A0, A1, A2, A3, A4”
  8. “business card paper size”
  9. “custom paper sizes for printing”
  10. “largest paper size available”
  11. “paper size for brochures”
  12. “envelope sizes for A4 paper”
  13. “different types of paper sizes for art”
  14. “common paper sizes for scrapbooking”
  15. “legal size paper dimensions”
  16. “what is B5 paper size”
  17. “paper sizes used in photography”
  18. “how to choose the right paper size for printing”
  19. “paper size standards worldwide”
  20. “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:

  1. “standard paper sizes chart”
  2. “A4 paper dimensions in inches”
  3. “what is the size of letter paper?”
  4. “list of paper sizes”
  5. “ISO paper size standards”
  6. “how big is A3 paper?”
  7. “business card dimensions”
  8. “US paper sizes vs international paper sizes”
  9. “B5 paper size specifications”
  10. “dimensions of legal size paper”
  11. “C4 envelope size in cm”
  12. “difference between A4 and letter paper sizes”
  13. “international paper sizes explained”
  14. “custom paper sizes for printing”
  15. “what size is 11x17 paper?”
  16. “envelope sizes for A4 paper”
  17. “dimensions of tabloid paper”
  18. “paper size conversion calculator”
  19. “photo paper sizes for printing”
  20. “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:

  1. “standard paper sizes chart”
  2. “paper size dimensions for printing”
  3. “US paper sizes vs international paper sizes”
  4. “ISO A series paper sizes.”
  5. “A4 paper size dimensions”
  6. “letter sized paper dimensions in inches”
  7. “paper sizes explained”
  8. “how to convert paper sizes”
  9. “different paper sizes for crafts”
  10. “large format paper sizes”
  11. “list of envelopes with corresponding paper sizes”
  12. “cardstock paper size differences”
  13. “custom paper sizes for backgrounds”
  14. “most common paper sizes for documents”
  15. “tumblers paper size for sublimation”
  16. “business card sizes and their dimensions”
  17. “children’s project paper sizes”
  18. “non-standard paper sizes”
  19. “size equivalence between A and letter sizes”
  20. “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:

  1. “What are the different stages of paper sizes?”
  2. “Standard paper sizes by country overview.”
  3. “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.