Looking for advice from experienced “prompters” on this one.
I’m building a simple Question Answering application with gpt-3.5-turbo
, which involves asking the model to generate a JSON-formatted response containing an answer and the corresponding URL based on some context. This is all part of the system message.
Here’s how the context is formatted:
[
{
"url": "https://example.com/some-web-page-1",
"context": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
]
},
{
"url": "https://example.com/some-web-page-2",
"context": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
]
}
]
Here’s the JSON I’m expecting my model to return:
{
"answer": "[answer to user question extracted from context]",
"url": "[url that contains the answer]"
}
While this approach works well in general, the model sometimes includes the URL not only in the url
field, but also in the answer
field, as part of the answer, e.g.:
This is the answer to your question. Find out more at: https://example.com/some-web-page-1.
Given the format of the context and the expected response, how would you formulate the prompt in order to avoid getting the URL in the answer
field? I’ve tried telling the model explicitly to avoid doing this, but as others have noted, negative prompting does not work very well in general, and thus also didn’t work for me. Also, what alternative approaches can you recommend that might help me solve this issue?
EDIT: I’m not including the exact prompt I’m using here, but it contains some simple instructions telling the model to answer the question based on the given context using the specified JSON format, along with some additional instructions regarding the desired length and language of the answer. The prompt contains a single example of the correct solution, so it can be considered one-shot.