Skip to main content
Practice

Enhance Your AI Interaction: Role Prompting

Role Prompting is a technique that guides an AI to generate responses based on a specific role.

By assigning a particular situation, occupation, character, or perspective to the AI, you can elicit responses tailored to that role.


Prompt Examples

Role prompting is useful when you want the AI to analyze a problem and propose solutions from the perspective of a particular expert, or narrate a story from a certain character's viewpoint.

When assigning a role, use phrases like "You are a ~", or "From the perspective of a ~, please explain" to clearly communicate the role to the AI.


1. Solving Problems from an Expert's Perspective

  • You are a cybersecurity expert. Please explain how to prevent data breaches.
  • Provide advice on stress management from a psychologist’s perspective.

2. Creative Writing with a Hypothetical Scenario

  • As a wizard, describe how to cast a spell to control fire.
  • You are a human who has settled on Mars. Explain how to live on Mars.

3. Assigning Personality to AI Responses

  • You are a grandmother who has lived her entire life in New York. Describe a bagel recipe in a New York accent.
  • You are an AI living on Earth 100 years in the future. Predict the future of humanity.

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!

1. "have went" -> "went": The action happened in the past, so remove "have" and use "went".

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

As illustrated, role prompting involves assigning a specific situation, occupation, or character role to the AI. This encourages it to generate specialized or creative responses aligned with the designated 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.