Specify a response structure for the gpt-35-turbo-16k

Hi everyone.

Why does the gpt-35-turbo-16k model make a lot of mistakes when I ask it to return the answer in a specific structure and the values ​​of that structure?

What would be the best way to request this structure?

Input : 
{
	"model": "gpt-35-turbo-16k",
	"messages": [
		{
			"role": "system",
			"content": "Consider the context: The available routines are Software Analysis (analyse-software) and Software Comparison (compare-software)"
		},
		{
			"role": "user",
			"content": "Question: what routines are available? . Please respond completely with as much detail as you can. Answer in Portuguese. Respond through JSON with the keys:{\"user_answer\":\"Your answer\",\"suggestions\":\"Array of a maximum of 3 positions with simple sentences that guide the user to continue processing the routine.\",\"has_context\":\"Is this question in context? Answer true or false\",\"chosen_routine\":\"Return the ID of the user-selected routine or an empty string.\""
		}
	],
	"temperature": 0.5,
	"max_tokens": 12000
}
Output:

			"message": {
				"role": "assistant",
				"content": "{\n  \"user_answer\": \"As rotinas disponíveis são Análise de Software (analyse-software) e Comparação de Software (compare-software).\",\n  \"suggestions\": [],\n  \"has_context\": false,\n  \"chosen_routine\": \"\"\n}"
			},```

Hi there and welcome to the Forum! Could you perhaps describe in greater detail what you are trying to achieve? I’m happy to try and help but it’s not yet fully clear to me from the system and user messages.

Thanks!

1 Like

hello,

I wanted to have more consistency in the keys: has_context, user_answer and suggestions.

he makes a lot of mistakes with these keys and there are times when the key doesn’t even come

I’ve had a lot of success just using typescript as a schema hint. this has worked well since davinci.

Answer in json using the following schema: 
{
  user_answer: string; // em português, traduza se necessário
  suggestions: string[]; // max 3 items
}

That said, your instructions seem a little confusing - getting them as straight-forward and unambiguous as possible also helps a lot.

1 Like

Like this?
@Diet

Question: what routines are available? . Please respond completely with as much detail as you can. Answer in Portuguese. user_answer: Your answer, suggestions: Array of a maximum of 3 positions with simple sentences that guide the user to continue processing the routine,has_context: Is this question in context?,chosen_routine: Return the ID of the user-selected routine or an empty string. Respond in JSON using the following scheme:\"user_answer\":\"string;\",\"suggestions\":\"string[]\",\"has_context\":\"boolean\",\"chosen_routine\":\"string\""```[quote="italosport111, post:5, topic:606263, full:true"]
Like this?

Question: what routines are available? . Please respond completely with as much detail as you can. Answer in Portuguese. user_answer: Your answer, suggestions: Array of a maximum of 3 positions with simple sentences that guide the user to continue processing the routine,has_context: Is this question in context?,chosen_routine: Return the ID of the user-selected routine or an empty string. Respond in JSON using the following scheme:"user_answer":"string;","suggestions":"string","has_context":"boolean","chosen_routine":"string""```
[/quote]

Hi everyone.

How can I make this chat conversation prompt more assertive?

Leave it in the entire format in json, xml, etc…

{
	"model": "gpt-35-turbo-16k",
	"messages": [
		{
			"role": "system",
			"content": "Consider the context: The available routines are Software Analysis (analyse-software) and Software Comparison (compare-software)"
		},
		{
			"role": "user",
			"content": "Question: what routines are available? . Please respond completely with as much detail as you can. Answer in Portuguese. Respond through JSON with the keys:{\"user_answer\":\"Your answer\",\"suggestions\":\"Array of a maximum of 3 positions with simple sentences that guide the user to continue processing the routine.\",\"has_context\":\"Is this question in context? Answer true or false\",\"chosen_routine\":\"Return the ID of the user-selected routine or an empty string.\""
		}
	],
	"temperature": 0.5,
	"max_tokens": 12000
}

Try this restructuring of your system message and insertion of documentation:

{
“model”: “gpt-3.5-turbo”,
“messages”: [
{
“role”: “system”,
“content”: “You are a helpful programming and language AI expert assistant. Your task is to answer the user’s questions and provide suggestions based on the available routines.\n\nYour assistant responses must be formatted in JSON, with the following keys and example output value descriptions: {"user_answer": "Your answer in Portuguese", "suggestions": "Array of a maximum of 3 positions with simple sentences that guide the user to continue processing the routine", "has_context": "Is this question in context? Answer true or false", "chosen_routine": "Return the ID of the user-selected routine or an empty string."}”
},
{
“role”: “assistant”,
“content”: "## Context\n\nAI should consider this information when answering the user’s questions and providing suggestions. The available routines are:\n\n### Software Analysis (analyse-software)\n\n—\n\n### Software Comparison\n\n(compare-software). "
},
{
“role”: “user”,
“content”: “Question: what routines are available?. Please respond completely with as much detail as you can. Answer in Portuguese.”
}

1 Like

This is how I did it using XML, and it improved the responses dramatically: API Prompt for gpt-3.5-turbo-16k - #12 by SomebodySysop

Thanks for the help @_j ,

Now with this structure you gave it always returns in the desired format, but checking whether the question is in context is very inconsistent and makes a lot of mistakes.

Do you know anything to solve this?

Thanks in advance!