Return a list of the best beaches given a city name. If the city is not known for good beaches, simply return "no"

I’m trying to prompt chatgpt to return a list of 20 beaches given a city name, like “Toronto”. If the city is not known for good beaches, I want it to simply return “no”.

I’ve tried many different prompts, but I seem to be sometimes getting a list of beaches and sometimes “no”, even when using the same city.

How can I prompt chatgpt’s API to return a list of beaches given a city name only if it has good beaches, otherwise just return “no”?

I’ve tried:

'messages' => [
    [
        "role" => "system",
        "content" => "You are a travel assistant, helping a tourist find the best places to visit."
    ],
    [
        "role" => "user",
        "content" => 'Does Toronto have any good beaches? You MUST respond with either "yes" or "no".'
    ],
    [
        "role" => "user",
        "content" => "List up to 20 beaches in Toronto, in order of popularity. Output the result in one line, separated by commas without numbers."
    ],
],

As a second question, how can I prompt chatgpt to return as many popular beaches as it can given a city name, without supplying a specific amount, like 20?

Welcome to the community!

gpt-3.5-turbo (2/24/24)

user:

Please create a list of beaches in ${“Toronto, Canada”}.

Ordered most popular to least popular

schema:

{
    beaches: string[] // if no beaches, this array would be empty
}

assistant:

{
    beaches: [
        "Woodbine Beach",
        "Sugar Beach",
        "Cherry Beach",
        "Kew-Balmy Beach",
        "Bluffer's Park Beach",
        "Hanlan's Point Beach"
    ]
}

Please create a list of beaches in Los Alamos, NM.

Ordered most popular to least popular

schema:

{
    beaches: string[] // if no beaches, this array would be empty
}

assistant:

{
    beaches: []
}

tldr: simplify your prompt as much as possible. but there are obviously an infinite number of ways to accomplish your goal - this is just a starting point!

1 Like

That’s great! One question, the number of beaches it returns seems to be fairly arbitrary. For example, Los Angeles has many dozens of good beaches, but it seems to be returning 5-10 beaches, when there are many more.

Is there any way to modify your prompt to suggest more beaches, without specifying a number, like “create a list of 20 beaches”?

You can add a follow-up user message

Please list more beaches if possible

schema:

{
    beaches: string[] // if no beaches, return empt
}

I tried to extend the list with logit bias

    "model": "gpt-3.5-turbo-1106",
    "logit_bias": {60:-100},

but wasn’t successful.

You can always try to tweak your prompt with wording such as “We’re brainstorming ideas, so we want to come up with as many ideas as possible” or something to that tune.

ok here’s a logit bias that works, but it’s dangerous:

    "model": "gpt-3.5-turbo-1106",
    "logit_bias": {
        60:-1, # ]
        11:10, # ,
        498:10 # ",
    },
{
    "beaches": [
        "Santa Monica Beach", 
        "Venice Beach", 
        "Malibu", 
        "Zuma Beach", 
        "Manhattan Beach", 
        "El Matador Beach", 
        "Dockweiler State Beach", 
        "Leo Carrillo State Beach", 
        "Hermosa Beach", 
        "Paradise Cove", 
        "Topanga State Beach", 
        "Will Rogers State Beach", 
        "Abalone Cove Shoreline", 
        "Point Dume State Beach", 
        "Redondo Beach", 
        "Cabrillo Beach", 
        "Rat Beach", 
        "Marina del Rey", 
        "Playa del Rey", 
        "El Porto", 
        "Corona del Mar", 
        "Lunada Bay", 
        "White Point", 
        "Royal Palms", 
        "Hollywood Beach", 
        "Malaga Cove", 
        "Bluff Cove", 
        "Avalon", 
        "Catalina", 
        "Terranea", 
        "Seal", 
        "Corona", 
        "Rancho", 
        "Venice", 
        "Mar", 
        "Lag", 
        "Sun", 
        "Leo", 
        "Her", 
        "Para", 
        "Wil", 
    ]
}

As you can see, we’re pushing into hallucination territory here.