epochs

Learn · Module 08 · Prompting and context · Lesson 1 of 6

Anatomy of a prompt

A good prompt isn't clever wording. It's a complete brief: who the model is, what to do, what to work from, and what to hand back.

5 minute read

In short
  • A prompt is a brief: role, task, context, examples, format and constraints.
  • Say what to do when information is missing, or the model will make it up.
  • Mark the material clearly with tags so it can't be confused with instructions.

In plain words

A model only knows what's in its context window. If your prompt leaves something out, the model fills the gap with a guess. Most bad outputs are missing information, not a bad model.

Think of the prompt as a brief for a capable new colleague who knows nothing about your company. A complete brief has six parts.

partwhat it answers
RoleWho are you, and who is this for?
TaskWhat exactly should be done?
ContextWhat material should you work from?
ExamplesWhat does a good answer look like?
FormatWhat shape should the answer have?
ConstraintsWhat must you never do, and what if you're unsure?

Worked example: fixing a vague prompt

A support team wants ticket summaries. Here is the first attempt.

Before
Summarise this ticket.

{ticket}

The model has to guess the length, the reader, what matters, and the layout. Each run will guess differently. Now add the missing parts one at a time.

  1. 1
    Role and task

    Say who the summary is for and what it's used for. That alone decides what's worth including.

    You write summaries of support tickets for engineers who must decide what to fix next.
  2. 2
    Format

    Name the fields and the length, so every summary looks the same.

    Reply with three lines:
    Problem: one sentence.
    Impact: who is affected and how badly.
    Next step: one action.
  3. 3
    Constraints

    Say what to do when the information isn't there. Without this, the model invents it.

    Use only what the ticket says. If the impact isn't stated, write "Impact: not stated".
  4. 4
    Context, clearly marked

    Put the ticket inside tags, so the model can't mistake the customer's words for your instructions.

    <ticket>
    {ticket}
    </ticket>
After
You write summaries of support tickets for engineers who must decide what to fix next.

Reply with three lines:
Problem: one sentence.
Impact: who is affected and how badly.
Next step: one action.

Use only what the ticket says. If the impact isn't stated, write "Impact: not stated".

<ticket>
{ticket}
</ticket>
Your turn

A prompt says: 'Classify this review as positive or negative.' The model sometimes answers 'Mixed' or writes a paragraph. Which part is missing?

What to remember in practice

Most chat models take a system prompt and user messages. Put the lasting brief (role, format, constraints) in the system prompt, and the material for this request in the user message.

Examples are the strongest tool you have. Two or three input and output pairs teach tone and format better than a paragraph of description. Choose varied examples, or the model will copy the one you gave too closely.

When output is wrong, don't add 'be accurate' or capital letters. Ask what information the model was missing, and add that.

Common mistakes

  • Writing vague instructions like 'be concise' instead of saying exactly what the output should contain.
  • Judging a prompt on two or three examples you tried by hand instead of a test set.
  • Burying the most important instruction in the middle of a long prompt.
Check yourself

Answer in your own words, out loud or on paper, before you open the model answer.

How do you approach writing a prompt for a new task?

I start by writing down what a good output looks like, with a few real example inputs and the answers I'd want, including tricky cases. Then I write the prompt in parts: the role and the task, the context the model needs, clear rules including what to do when it can't answer, the exact output format, and one or two examples if the format is unusual. I keep instructions specific, so 'reply in under 80 words with the order number first' rather than 'be brief'. Then I run it on a small evaluation set, look at the failures, and change one thing at a time. Once it's good, those examples become regression tests for future changes.

More to think about
  • A prompt works on your examples but fails for users. How do you debug it?
  • What goes in the system prompt versus the user message?

Go further

Was this lesson clear?