Minor prompt variation causes model to fail retrieving information from the web #199
-
Hey ! I am having trouble fetching information from the web. I noticed that a very slight change in my prompt can cause the whole web search to fail. My use-case consists in fetching information on a company given its name and its website URL. Here's one of the most simple prompts examples: # Prompts
company_name = "Association Delphinea"
website_url = "https://associationdelphinea.com"
user_prompt_1 = f"""
Find detailed information on the following company:
Company name: `{company_name}`
Company website URL: `{website_url}`
"""
user_prompt_2 = f"""
Find detailed information on the following company:
Company name: `{company_name}`
Company website URL: `{website_url}`
Describe your findings.
""" Strangely enough, with
Also, I am not using any parameter in my API request. # API call
import requests
url = "https://api.perplexity.ai/chat/completions"
payload = {
"model": "sonar",
"messages": [
{
"role": "user",
"content": user_prompt_1
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.request("POST", url, json=payload, headers=headers) I am stuck here as it seems that a very small additional instruction destroys the web search. Any kind of help would be kindly appreciated, thanks a lot ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @ahmedkooli ! This is a very interesting phenomenon you're coming across here, which goes back to general best practices of prompt engineering, which at times may be more art than science :) . Why I believe this happensAt the high level, our retrieval system operates in two key phases:
When using What I suggest to fix itTry one of these approaches:
You can read about all our models here. Example API request using payload = {
"model": "sonar-deep-research",
"messages": [{"role": "user", "content": user_prompt_1}]
}
|
Beta Was this translation helpful? Give feedback.
Hey @ahmedkooli ! This is a very interesting phenomenon you're coming across here, which goes back to general best practices of prompt engineering, which at times may be more art than science :) .
Why I believe this happens
At the high level, our retrieval system operates in two key phases:
When using
user_prompt_1
, Sonar focuses purely on retrieving information about the company (via the desired web search). However, adding"Describe your findings."
inuser_prompt_2
might be shifting the model’s focus away from direct ret…