đŸ„‹ LM Dojo

Foundations

Anatomy of a prompt

12 min · Needs:Text generation

Anatomy of a prompt

Before we name anything, inspect the whole prompt as plain model input. It is one sequence, but the lines are doing different jobs:


 tokens · 268 charactersLoading tokenizer


💡 This is the token view: honest, literal model input. The tokenizer does not know which words are instruction, task, context, format, or examples.

A prompt has two truths. The token view is what the model literally receives: token IDs in order. The anatomy view is what you, the writer, should be tracking: each clause needs a job. If a sentence has no job, it is filler. If two sentences have the same job, one of them is probably noise.

The five roles are simple:

Role Job Change this when

Instruction Sets behavior for the whole request the model is doing the wrong kind of work
Task Names the concrete operation the goal changed
Context Supplies the material to work on the facts, document, ticket, or conversation changed
Format Specifies the answer shape a human or program needs a different output form
Examples Shows boundary cases the model is confusing categories or style

This taxonomy is a writing tool, not a security wall. In September 2022, Simon Willison described prompt injection attacks against GPT-3, where text placed in a prompt could compete with the developer’s intended instruction. The durable lesson is not “delimiters solve it”; they do not create a hard boundary inside the model. The lesson is more basic: if you cannot tell which text is instruction and which text is untrusted context, you cannot even reason about the failure.

Now reread the support prompt. Instruction says “classify, do not answer.” Task says “pick one label.” Context is the ticket itself. Format says JSON. Examples teach where two labels start and stop. If you change the ticket text, you changed context. If you ask for CSV instead of JSON, you changed format. If you add a case like "Password reset loop" -> access, you changed examples. The model sees one stream, but you should edit it with a scalpel.

The fastest debugging move is to name the role before changing text. “It keeps apologizing” is probably an instruction problem. “It answered the wrong customer” is probably a context problem. “It wrote a paragraph when my parser needs fields” is a format problem. “It cannot tell refund requests from account-access requests” calls for examples. That habit keeps prompting from becoming folk magic: every edit is a hypothesis about which role is broken, and the next receipt tells you whether the hypothesis helped.

Exercise: role surgery

Write the compact support-triage prompt. The checker reads your prompt, not the model’s answer: it looks for the five anatomy labels in order and checks the prompt token budget.

Build the five-role prompt

Write a compact support-triage prompt with five labeled roles, in this order: Instruction, Task, Context, Format, Examples. The checker reads your prompt and keeps it under 85 prompt tokens.

0 prompt tokens (est.)

No model connected — connect one to run your attempt.

The model’s attempt — run yours first

Check your understanding

Question 1 of 4

What is the anatomy view for?