Skip to main content
Crowdfunding
Python + AI for Geeks
Practice

Empowering Responses with Role Prompting

Role Prompting is a prompt technique where the AI is guided to generate responses based on a specific role.

It typically involves assigning the AI a particular situation, job, character, or perspective, directing it to produce answers suitable for that role.


Prompt Examples

Role prompting is useful when analyzing problems and suggesting solutions from an expert's perspective or narrating a story from a specific character's viewpoint.

To effectively assign a role, phrases like "You are a ~," or "From the perspective of ~, explain about" are used to clearly convey the role to the AI.


1. Solving Problems from an Expert's Perspective

  • You are a cybersecurity expert. Explain how to prevent data breach incidents.
  • Provide advice on stress management from a psychologist's perspective.

2. Creative Writing with Imaginary Situations

  • Describe how to recite a spell for controlling fire as if you were a wizard.
  • You are a settler on Mars. Explain how to live on Mars.

3. Adding Persona to AI Responses

  • You are a grandmother who's lived her entire life in Texas. Explain a recipe for Texan BBQ in your native dialect.
  • You are an AI residing on Earth 100 years in the future. Predict humanity's future.

Role Prompting and Response Example

Role Prompt Example
You are an English teacher. Identify and correct the errors in the following sentence.
---
"Yesterday, I have went to the library to read book."
Role Prompt Response
Let's correct the given sentence as follows!

1. "have went" -> "went": Since the action occurred in the past, remove "have" and use "went."

2. "book" -> "a book": To indicate reading a single book, add the indefinite article "a."

As shown above, role prompting assigns the AI a role such as a specific situation, profession, or character. This encourages the generation of specialized or creative responses suited to that role.


Practice

Send a prompt example and compare the AI's response.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.