<div class="statcounter"><a title="Web Analytics" href="https://statcounter.com/" target="_blank"><img class="statcounter" src="https://c.statcounter.com/12795394/0/d64e9537/1/" alt="Web Analytics" referrerPolicy="no-referrer-when-downgrade">

AI Quick Tips 260: Are you using prefixes in your prompts?

AI Quick Tips

If you read through Google’s Gemini API docs then you have probably already seen most of what will be in this post.  After thinking about it, most people don’t read through Gemini’s API docs and, I would guess that, a lot of people don’t even know what API docs are.

Anyway, Google recommends adding prefixes to your Gemini prompts when it makes sense.  


They define a prefix as a word or phrase that you add to the prompt content that can serve several purposes, depending on where you put the prefix:

  • Input prefix - Adding a prefix to the input signals semantically meaningful parts of the input to the model. 
    • For example, the prefixes “English:” and “French:” demarcate two different languages
  • Output prefix - Even though the output is generated by the model, you can add a prefix for the output in the prompt.  The output prefix gives the model information about what’s expected as a response. 
    • For example, the output prefix “JSON:” signals to the model that the output should be in JSON format.
  • Example prefix - In few-shot prompts, adding prefixes to the examples provides labels that the model can use when generating the output, which makes it easier to parse output content


In the following example, “Text:” is the input prefix and “The answer is:” is the output prefix

 A screenshot of an AI prompting interface. The prompt provides a few-shot example for the AI to learn from. The input prompt is: "Classify the text as one of the following categories: - large - small." Examples are then listed: "Text: Rhino The answer is: large," "Text: Mouse The answer is: small," "Text: Snail The answer is: small," and finally, "Text: Elephant The answer is:". The AI's response box below provides the final answer: "The answer is: large." This image demonstrates a few-shot classification task given to the AI.

Email Course Blog CTA - 1-1

Stop Copying Prompts. Start Creating Better Ones.

Start the free ChatGPT Kickstarter Email Course.

Comments

Related posts