Analyzing Consistency in LLM Outputs Leveraging Colourful Queries

Anna Sofia Kircher

My colourful journey getting to know ChatGPT.

First Contact



LLMs have made an impressive evolution especially in the last few years. The rise of neural networks and the introduction of transformer architecture have significantly advanced language generation capabilities. A genuine breakthrough.

Initial introductions via an overflow of news articles, posts, webcasts, and opinions everywhere lead to interesting conversations.



“And now I can code”

Exploring (First Steps)


There are multiple ways to leverage the power of LLMs, playing around with chatGPT in my humble beginnings lead to very mixed results.


  • Code Snippets
  • Debugging
  • Crochet Patterns
  • Travel Itinerary
  • Format Instructions

ChatGPT was rather friendly when pointing out its code mistakes.

One might call it creative freedom or fashion to have only half a sweater with one sleeves.

So Many Questions…?

So Many Questions…


A lot of discussions, more posts, webcasts and opinions just lead to more questions.

  • How does one write a good prompt?

  • How does one write the right prompt?

  • How reliable are the answers?

  • How does this actually work?

  • How creative can a model be? And what would that mean?

Let’s try to understand this more!

A Colourful Idea


Exploring colours using ChatGPT with regards to hex-codes, meaning, symbolism etc…

Formulating a set up to analyse LLMs responses using colours.


Can ChatGPT categorize hex-codes into a fixed set of main colour categories?

How consistent would the answers be?

Can it understand the instructions?

Can ChatGPT make up creative idioms and interpret them correctly?

Why Colours?



  • Cultural Context
  • Language
  • Scientific Representation
  • Other Reasons

On Colour | David Scott Kastan with Stephen Farthing

The Secret Lives of Colour | Kassia St. Clair

R & OpenAI API


# connecting R with opanAI api

library(openai)
# ensure API key is available in global environment (.Renv) 

#list of prompts (with role specified)
message_list <- list(
  list("role" = "system",
       "content" = "You're a colour expert"),
  list("role" = "user",
       "content" = "Provide an idiom or proverb for the colour green")
) 

create_chat_completion(
  model = "gpt-3.5-turbo", # state which model to use
  # different models can be more suitable for different tasks
  messages = message_list, # list with prompts
  temperature = colour_temp # temperature (creativity) parameter
  ) 

Introducing Randomness



Temperature controls the randomness of a model’s output by adjusting the probability distribution over possible next words.

Low temperature:

  • deterministic
  • focused
  • predictable

High temperature:

  • random
  • diverse
  • creative

Example:


Cloudy with a chance of …

Rain? Meatballs?

The Ingredients


The prompt, the colour categories, the temperatures

# colour-categorizing prompt
message_list <-
    list(
      list("role" = "system",
           "content" = "You're a colour expert and always use" 
                       "black, white, red, blue, green, yellow and purple" 
                       "as main colour categories"),
      list("role" = "user",
           "content" = "please provide the main colour category" 
                       "for the following hex code: ", hex_colour)
    ) 
  
# temperature settings
temperature <- c(0, 0.5, 1, 1.25, 1.5, 1.75, 1)

colour_chat <- create_chat_completion(
  model = "gpt-3.5-turbo",
  messages = message_list, # list with prompts
  temperature = temperature[t]
  ) 
  

Colour Categories and Set-Up

  • 405 colours
    • R named colours and their hex codes
  • 9 different temperature settings (between 0 and 2)
  • run N times

OpenAI API usage and limits:

  • limited number of requests per day | 10,000 RPD
  • limited number of requests per minute | 500 RPM
  • limited number of tokens per minute | 60,000 TPM
Some quick math:

405 colours * 80 tokens * 9 = 291,600 tokens

405 colours * 9 * 10 = 36,450 requests

and…

Categorizing Colours

Categorizing Colour Categories




Categorizing Colours Surprises

Categorizing Colours in Context

Categorizing Colours in Context


An important aspect are the instructions and the model’s understanding and application when generating a response. Only with higher temperature settings the returned response included a reasoning for the stated colour category.


Temperature: 1.7 - 1.95

[khaki]
The main colour category for the hex coded colour “8B864E” within my standard categories of black, white, red, blue, green, yellow, and purple would be green. This hex code represents a shade within the green family.

[mistyrose]
The hex coded color #EED5D2 falls under the category of pink in terms of color naming, but based on your main colour categories, it would fall under the category of red as it has a reddish hue.

Categorizing Colours in Context


On the other hand low temperature settings, even if claiming to having read the instructions more often fail to adhere to them


Temperature: 0-0.5

[tan]
The hex code #D2B48C corresponds to a shade of brown. In the colour categories you provided, this would fall under the “brown” category.

[gray]
The hex coded color #7A7A7A falls under the main color category of gray.

[darkorange]
The hex coded color #FF8C00FF falls under the main color category of orange.

Categorizing Colours in Context


Unix-code errors and text-overflow, incoherent sentences, symbols/emojis or slight gibberish occurred more often for higher temperature settings.



Temperature: 1.7 - 1.95
[darkorange]
The hex color code #FF7F00, when broken down into the main colour categories I use (black, white, red, blue, green, yellow, purple) can be interpreted as mandarin as Mandarin901.

[mediumturquoise]
The hex code #48D1CCFF corresponds to Cyan. In the color categories that you provided, Cyan belongs to the colour blueHashCodeffer))DateString.

[lightsteelblue]
Based on the hexadecimal color code #CAE1FF, the main colour categories would be: Purple for C, Blue for AE,Lightblue for 161F03.

Colourful Proverbs


Dasselbe in Grün! The same in green!



Creating or quoting idioms that involve colours.

Does the symbolism change?


chat_colours <- c(
  "blue", "red", "green", "yellow", "purple", "black", "white", "gray", "orange"
  , "brown", "violet", "pink", "lavender", "cornflowerblue", "azure", 
  "aubergine", "sage", "gold", "khaki", "cobalt")
  
message_list <-
    list(
      list("role" = "system",
           "content" = "you're a colour expert"),
      list("role" = "user",
           "content" = "please create an idiom using the colour blue")
    )

Colourful Proverbs Symbolism


This requires retrieving the first response and including it in the message list.


message_list <- 
      list(
        list("role" = "system",
             "content" = "you're a colour expert"),
        list("role" = "user",
             "content" = paste0("please create an idiom using the colour blue")),
        list("role" = idiom[[blue]]$response$choice$message.role,
             "content" = llm_text[[blue]]$response$choice$message.content),
        list("role" = "user",
             "content" = "categorize the semtiment of the idiom")
      )

Create vs Quote

Paint the Town Something


The most common phrase…

Paint the town purple but not blue

25% of all generated idioms.


Idioms


Most fun examples were generated with higher temperature settings.


“When the chips are down, it always helps to have a friend who’s true blue instead of two-faced brown.”

“Keeping things khaki”

“Orange you glad to see the sunshine after the storm”

in conlcusion?

Communication is key!
“Yes I understand” does not necessarily mean what you want it to mean.

Context matters! Models can be very powerful trained for specific capabilities.

I’m glad I have some stats background.

Creativity: Ability to draw connections and apply concepts from other areas/contexts in new ways to the task at hand.

Not everything is written down properly (tribal knowledge).

emoji’s are part of our language now.

Sys.sleep() is lovely

Thank you!