A lot of people, including me, recommend iterating as part of prompt engineering.
For those of you who haven’t lived in tech and math circles, and might not have heard “iterating” before, here is an AI-generated definition (that I agree with) -
Iteration is the process of repeating a sequence of operations or instructions to achieve a desired result, often used in mathematics and computer science. Each repetition is called an iteration, and the outcome of one iteration typically serves as the starting point for the next.
The short version of that is to do things more than once (it leaves out some important information, though).
Now that we are all on the same page, one of the questions that I don’t think gets asked as much as it should is “Are there any recommended strategies for how to iterate?”. Short answer - yes. Again, it leaves out some details I think.
The following examples are from Google. I’ve found that each of these strategies has worked well with other vendor’s models though.
Using different words or phrasing in your prompts often yields different responses from the model even though they all mean the same thing. If you’re not getting the expected results from your prompt, try rephrasing it.
If you can’t get the model to follow your instructions for a task, try giving it instructions for an analogous task that achieves the same result.
Prompt: Which category does the Odyssey belong to:
Thriller
Sci-fi
Mythology
Biography
Response: The Odyssey belongs to the category of **mythology**.
Here's why:
* **Mythology:** The Odyssey tells the story of Odysseus, a hero from Greek mythology, and his
journey home after the Trojan War. It features gods, monsters, and supernatural events common to
Greek mythology.
The response is correct, but the model didn't stay within the bounds of the options. You also want to model to just respond with one of the options instead of in a full sentence. In this case, you can rephrase the instructions as a multiple-choice question and ask the model to choose an option.
Prompt: Multiple choice problem: Which of the following options describes the book The Odyssey?
Response: The correct answer is mythology
The order of the content in the prompt can sometimes affect the response. Try changing the content order and see how that affects the response.