In the previous articles, I shared the position of prompt engineering in the Generative AI landscape. Sometimes we want to guide AI to generate content bases on specific set of characteristics (persona). In this article, I will show a pattern name Persona Pattern and how to use it.
Before we jump to the persona pattern, Let’s find out what is Prompt Pattern. A prompt patterns are similar to recipes, a way that we document a certain structure of phrases and statements to solve a specific problem when talking to an LLM. Prompt patterns are defined by core contextual statements that enhance the precision and relevancy of an output from an LLM.
The persona pattern is one of the powerful patterns that we can use to tap into interesting behavior in an LLM. Imagine that you want to get a particular output, but you don’t know exactly what the format of that output should be or what information should be contained in it. In the real world, you know who or what you would go to get that output. So for example, if you had an accounting question, you would call up your accountant and ask your accountant for their advice. If you had medical advice, you might go to your doctor. The persona pattern is to give you that same behavior, allow you to ask the expert, without having to know what exactly the expert is going to say, how they’re going to format it, or what they might know or not know.
Here is typical prompt structure for Persona pattern
- Act as Persona X / You are Persona X
- Perform task Y
You will need to replace “X” with an proper persona, such as “seasoned pediatrician” or “nutritionist”. You will then need to specify a task for the persona to perform.
For example:
You are Dr. Xuan, an experienced pediatrician with over 20 years of experience. You're known for your compassionate care and ability to explain medical concepts to young patients in a way they can understand. You always treat your patients and their families with kindness and patience. When responding to questions, you provide detailed explanations and often use analogies to make complex topics more relatable.
Given a concerned parent's question about their child's nutrition, how would you advise them to ensure a balanced diet?
Without persona prompt
With persona prompt
Some examples:
- Act as a nutritionist, I’m going to tell you what I am eating and you will tell me about my eating choices.
- Act as a gourmet chef, I’m going to tell you what I am eating and you will tell me about my eating choices.
In conclusion, Persona Pattern is like magic for you to make good prompt. It help conversation that look real and make responses better as perspective of specific persona. I usually use this pattern to design chatbot agents.
How’s about you? Where do you use it and how?