🟢 Assigning Roles
- Understand role prompts
- Use role prompts to style text and improve accuracy
Role promptinga is a technique that can be used to control the style of AI generated text123. It can also improve the AI's accuracy when solving math problems. Implementing role prompting is as simple as instructing the AI to "embody a food critic" or to "act like a detective". Role prompting is a widely used technique, and is used in many of the examples on this site.
Role prompting is most often used to style text. This involves asking the AI to pretend to be a certain person, or act in a certain way, thus modifying how it writes based on the assigned role. This can be used to change the tone, style, and even the depth of the information presented. Let's delve into this concept with a food review example.
Food Review Example
When writing a review, it's important to tailor your approach based on the platform you're using and the audience you're writing for. Simply copying and pasting the same review across various sites like Google Reviews, TripAdvisor, and Yelp is not an effective strategy, especially if you're writing for a food critic in a magazine or blog post. To ensure your review resonates with your intended audience, consider factors like length, style, language, and tone, and use these to craft a review that speaks directly to your readers' interests and expectations. With a thoughtful approach and a focus on quality content, you can create a review that truly captures the essence of the pizza place you're writing about. Let's start with a simple prompt without a role.
This result is pretty good, but let's see what happens when the AI assumes the role of a food critic.
We can see that it adds more detail and goes a bit more in depth. Now let's go a step further and make it assume the role of a writer for the Michelin guide:
Now we can see how assign GPT-3 the role of a food critic makes the review seem more "rich" and "professional" in it's description.
You can try it for yourself here:
Email Writing Example
Let's consider another example of styling text with role prompting. When using a language model like ChatGPT to draft an email, considering the "role" of the AI is critical to shaping the content it generates. The direction you want your resultant email to take will decide which role you should task the AI with.
Let's say you task the AI with writing an email to a client to inform them about a delay in the delivery schedule due to logistical issues. Your goal is to effectively convey this update while ensuring the client's confidence in your services remains unwavering. There are several roles you could assign to the model to receive varied output.
For instance, one possible role is that of a communications specialist, whose style might be clear, professional, and to the point:
Alternatively, have the model adopt the role of a marketing expert to lean more on persuasion, positivity, and relationship building:
Lastly, the role of a customer service representative might lead to a more relational and solution-oriented output:
Each of these role prompts will yield different results, aligning more closely with the perspective of the assigned role. Whether you need the directness of a communications specialist, the persuasive positivity of a marketing expert, or the empathetic problem-solving approach of a customer service representative, role-prompts allow you to tailor the language model to better fit your needs.
As mentioned above, the accuracy of the output can be improved with role promptinga. Consider the following example:
This is a correct answer, but if the AI had simply been prompted with
What is 100*100/400*56?, it would have answered 280 (incorrect).
Please note that we used GPT-3 for this question. ChatGPT will answer the question incorrectly, but in a different way.
Try it here:
Role prompting is a powerful strategy for shaping the output of Generative AI models. It allows us to control the style, tone, and depth of the generated text, making it more suitable for specific contexts or audiences. Whether you're drafting an email, writing a review, or solving a math problem, role prompting can significantly enhance the quality and accuracy of the results. As we continue to explore the capabilities of AI, role prompting will remain a key prompt engineering strategy.
- This appears to be less effective with newer models. Read Revisiting Roles for more information.↩
- Shanahan, M., McDonell, K., & Reynolds, L. (2023). Role-Play with Large Language Models. ↩
- Li, G., Hammoud, H. A. A. K., Itani, H., Khizbullin, D., & Ghanem, B. (2023). CAMEL: Communicative Agents for “Mind” Exploration of Large Scale Language Model Society. ↩
- Santu, S. K. K., & Feng, D. (2023). TELeR: A General Taxonomy of LLM Prompts for Benchmarking Complex Tasks. ↩