P

Role Prompting: Definition and Examples

Role prompting consists of assigning a specific role, identity, or expertise to an AI model in the prompt, in order to guide the style, tone, and depth of its responses.

Full definition

Role prompting is a prompt engineering technique that consists of asking a language model to adopt a specific role before responding to a query. By assigning an identity — for example, "You are a cybersecurity expert" or "Act as a physics teacher" — the model is conditioned to draw on the knowledge and language register associated with that character.

This technique is based on a simple principle: language models have been trained on massive corpora containing texts produced by professionals in all fields. By specifying a role, we activate a subset of this knowledge, allowing for more relevant, precise, and well-calibrated responses for the intended context.

Role prompting can be used simply (a single instruction sentence) or sophisticatedly, by combining the role with an experience level, target audience, format constraints, and situational context. For example, asking the model to be "a senior Python developer specialized in data engineering, who explains to a junior" produces very different results from "a theoretical computer science researcher."

This approach is particularly effective for creative, educational, technical, or writing tasks. It often forms the first building block of a well-structured prompt and naturally combines with other techniques like few-shot prompting or chain-of-thought.

Etymology

The term combines "role" (from French, meaning a function or character to embody) and "prompting", the action of formulating an instruction for an AI model. The concept is directly inspired by role-playing and theatrical improvisation techniques, transposed to the field of generative artificial intelligence.

Concrete examples

Get a technical explanation suitable for a beginner audience

You are a patient and pedagogical computer science professor. Explain the concept of recursion to a first-year student who has never programmed.

Write marketing content with a specific tone

Act as a senior copywriter specialized in B2B SaaS. Write a sales page for a project management tool, using a professional but accessible tone.

Analyze a problem from an expert perspective

You are a software architect with 15 years of experience in distributed systems. Analyze this microservices architecture and identify potential points of failure.

Practical usage

To apply role prompting effectively, start your prompt with a clear instruction defining the role, expertise level, and possibly the target audience. Be specific: "a nutritionist specialized in sports nutrition" will yield better results than simply "a health expert." Combine the role with format and tone constraints to maximize the relevance of the responses.

Related concepts

System PromptPersonaFew-Shot PromptingChain-of-Thought

FAQ

Does role prompting work with all AI models?
Most large language models (GPT-4, Claude, Gemini, Llama) respond well to role prompting. However, smaller or less trained models may struggle to maintain a role consistently over long exchanges. Recent models often have a dedicated "system prompt" field, ideal for placing the role definition.
What is the difference between role prompting and system prompt?
The system prompt is a technical location (a separate field in the API) where general instructions for the model are placed. Role prompting is a technique that can be used in the system prompt or directly in the user message. In practice, placing the role in the system prompt is recommended as it persists throughout the conversation.
Can you assign multiple roles at the same time?
It is possible but not recommended to assign multiple roles simultaneously, as it can create contradictions in the responses. A better approach is to define a precise hybrid role (e.g., "a full-stack developer who also has training in UX design") or to switch roles between different stages of a conversation.

See also

How to use this prompt

  1. Copy the prompt with the button above.
  2. Paste it into ChatGPT, Claude or your favorite AI assistant.
  3. Replace the bracketed variables with your details, then refine the result.

About Prompt Guide

Prompt Guide is a free library of 2500+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.

More definitions

Get new prompts every week

Join our newsletter.