Velamuvi AIAcademy

Lesson 4 of 15 · Foundations

Giving Context and Roles

Why context is the biggest prompt upgrade: who you are, the purpose, the audience and what you tried, plus when role prompts like 'You are an expert' help.

  • 7 min read
  • Beginner
  • Reviewed
In this lesson you will learn
  • What context is and why it matters more than clever wording
  • The five kinds of context worth giving
  • What a role prompt does, and its limits
  • How to use roles to get useful feedback and different perspectives

The model knows the world, not your world

A model has read about salary negotiations, school trips and bakery suppliers in general. It knows nothing about your manager, your school or your bakery, unless you say so.

Adding context is usually the single biggest improvement you can make to a prompt. It turns a general answer into an answer for you.

Five kinds of context worth giving

ContextQuestion it answersExample
SituationWhat is going on?"I've worked at a design agency for 2 years and have my review next week."
PurposeWhat is the output for?"I want a 10% raise, or a plan to reach it within 6 months."
AudienceWho reads or hears it?"My manager, who is supportive but has a tight budget."
HistoryWhat has been tried?"I mentioned it informally last month."
Facts it can't knowWhat is specific to you?Company policies, your product, your data, today's date

The program below builds the same request twice: once bare, once with a role and full context.

Try it yourselfPython
def with_context(task, role="", situation="", audience="", goal="", tried=""):
    lines = []
    if role:
        lines.append(f"You are {role}.")
    if situation:
        lines.append(f"Situation: {situation}")
    if audience:
        lines.append(f"Audience: {audience}")
    if goal:
        lines.append(f"Goal: {goal}")
    if tried:
        lines.append(f"Already tried: {tried}")
    lines.append(f"Task: {task}")
    return "\n".join(lines)

print(with_context("Help me plan what to say."))
print()
print(with_context(
    "Help me plan what to say, as 3 short talking points.",
    role="an experienced, practical career coach",
    situation="I have worked at a design agency for 2 years and have my yearly review next week.",
    audience="My manager, who is supportive but has a tight budget.",
    goal="A 10% raise, or a clear plan to reach it within 6 months.",
    tried="I mentioned it informally last month and was told to bring it up at the review.",
))

The first prompt can only get generic advice ("research market rates, highlight achievements"). The second can get talking points that mention the agency, the tight budget and the 6-month fallback.

Roles

A role is a compact way to set tone, vocabulary, level of detail and point of view all at once. "You are a patient maths tutor for 12-year-olds" implies simple words, encouragement, worked examples and no jumping ahead.

Roles are most useful for:

  • Tone and level: tutor, friendly support agent, formal legal writer.
  • Perspective: "Read my cover letter as the hiring manager at a small charity would."
  • Critique: "Act as a tough but fair editor and list the 3 weakest points of this article."

Prompt

Give me feedback on my cover letter. [cover letter]

Example response

Your cover letter is well written and shows enthusiasm. Consider adding more specific examples of your achievements, and make sure to tailor it to the role. Overall, a strong start!

Polite and generic. It could have been written about almost any cover letter.

Common mistakes

Practice exercise

Before writing a prompt, check which context is still missing. Print the question you would need to answer for each gap.

Your solutionPython
context = {
    "audience": "my team of 6 engineers",
    "goal": None,
    "deadline": "Friday",
    "tone": None,
}
questions = {
    "audience": "Who will read it?",
    "goal": "What should happen after they read it?",
    "deadline": "When is it needed?",
    "tone": "What tone should it have?",
}

# Print the question for every piece of context that is still None
Knowledge check

What usually improves a generic answer the most?

Summary

  • Context is what the model cannot know: your situation, purpose, audience, history and specific facts.
  • Adding context is usually the biggest single improvement to a prompt.
  • A role sets tone, level and perspective in a few words.
  • Roles are great for feedback and different perspectives, but do not add knowledge.
  • Never assume the model remembers your details from another chat.

Next: teaching by example, with zero-shot and few-shot prompting.

Finished reading? Tick it off to track your progress.