⚡0 XP🔥0

Roles, Personas and Context

Lesson 5 of 19 ⏱ 5 min read ✎ 2 exercises ❓ 4-question quiz ▶ Runs Python

Use role prompting to set expertise and tone, give rich background context, ground answers in documents you provide, and use conversation context effectively.

Role prompting#

Starting a prompt with "You are..." sets the expertise, viewpoint and tone of the answer. It's one of the simplest and most effective techniques.

▶ Try it YourselfPython
Ctrl + Enter to run

Paste each into an AI assistant - the advice, vocabulary and examples change with the role.

Make roles specific#

Weak role Strong role
You are an expert. You are a chartered accountant with 15 years of experience advising small manufacturers in Madhya Pradesh.
You are a teacher. You are a patient maths teacher who explains NCERT Class 9 concepts using everyday Indian examples.
You are a developer. You are a senior Python developer who reviews code for readability, security and performance.
हिंदी में समझें

Role prompting का मतलब है AI को बताना कि वह किस भूमिका में जवाब दे - जैसे "आप एक अनुभवी CA हैं" या "आप Class 9 के गणित शिक्षक हैं"।

इससे जवाब का स्तर, भाषा और नज़रिया बदल जाता है। एक ही सवाल पर doctor, teacher और businessman अलग-अलग तरह से जवाब देंगे - AI भी वैसा ही करता है।

ध्यान रखें: role जितना specific होगा (अनुभव, क्षेत्र, किसके लिए), जवाब उतना ही बेहतर होगा। सिर्फ "आप expert हैं" लिखना काफ़ी नहीं है।

Common Mistake

A role adds a style and focus - it does not give the model real credentials. A "doctor" role still needs verification by a real doctor for medical decisions.

Roles for review and critique#

Roles are powerful for getting critical feedback:

You are a strict interviewer at a top IT company. Review my answer to
"Tell me about yourself" below. List the 3 biggest weaknesses and rewrite it.

<answer>
...
</answer>

Context - the information the AI can't guess#

Context is the background that makes an answer relevant to you:

  • Who you are and who the output is for
  • Why you need it (goal, what happens next)
  • Situation details: location, budget, deadline, tools, level
  • What you already tried or already know
Without context
Suggest a marketing plan.
With context
I run Vindhyaedu, a computer training institute in Indore with 3 classrooms.
We teach Python, web development and AI tools to college students and working
professionals. Most students find us through Google and Instagram. We have a
marketing budget of Rs. 25,000 per month and one part-time designer.

Suggest a 3-month marketing plan to get 60 new admissions for our January
batch. Focus on low-cost digital channels. Present it as a month-by-month table
with channel, activity, cost and expected leads.

Grounding: answer from MY material#

To get answers about your documents - a policy, syllabus, contract, product catalogue - paste the material and tell the model to rely on it:

Answer the student's question using only the course brochure below.
If the brochure doesn't contain the answer, say "Please contact the office
at 98xxxxxx10."

<brochure>
Python Programming - 3 months, Mon/Wed/Fri, 6-8 pm. Fee Rs. 8,000
(Rs. 1,000 discount for full payment). Certificate after final project.
</brochure>

Student question: Is there a weekend batch?

Grounding:

  • reduces hallucinations,
  • keeps answers consistent with your official information,
  • works even for information newer than the model's knowledge cutoff.
Tip

Ask the model to quote the sentence it used from the document. Quotes are easy to check, and it makes the model stick closer to the source.

Conversation context#

In chat tools, earlier messages are part of the context. Use this:

  1. Set the scene once at the start: role, project, audience, rules.
  2. Refer back: "Using the same format as before, do the next chapter."
  3. Correct, don't restart: "Good, but make the examples about hospitals instead of shops."

But long chats have limits:

  • Very old messages may get less attention.
  • Mixing unrelated topics confuses the model.

When a chat becomes long or messy, ask: "Summarise our decisions and the instructions I've given so far", then paste that summary into a new chat.

Custom instructions and projects#

Most AI tools let you save context that applies to every chat - often called custom instructions, memory, projects or custom GPTs / Gems. Put stable information there:

I am a Python trainer at Vindhyaedu, Indore. My students are college students
and freshers. Prefer simple English with Indian examples. When I ask for
code, use Python 3.12, add comments, and include a sample output.

You'll build full custom assistants in the System Prompts lesson.

Summary#

  • Roles set expertise, focus and tone - make them specific (experience, field, audience).
  • Context = who, why, situation, constraints - the things the AI can't guess.
  • Grounding: paste your material and say "answer only from this"; allow "not found".
  • Manage chat context: set the scene early, refer back, and restart with a summary when chats get long.

Practice Exercises

Write your code, then press Check. Your program is tested automatically.

1

Persona prompt

Write persona(role, audience, task) that returns:

You are <role>. Your audience is <audience>. <task>

2

Grounded question

Write grounded(document, question) that returns a prompt in exactly this format:

Answer the question using only the document below. If the answer is not in the document, reply "Not found in the document."

<document>
DOCUMENT TEXT
</document>

Question: QUESTION

Quick Quiz

Q1.

What does role prompting ("You are a ...") mainly change?

Q2.

Which role is most useful for reviewing a loan agreement for a small business owner?

Q3.

What is "grounding" a prompt?

Q4.

In a long chat, the AI starts forgetting your early instructions. Best fix?