Lesson 1 of 2 Prompt Engineering for Generative AI

Separating System Prompts from User Prompts

This lesson explains the two kinds of prompt that shape a generative model's behaviour: the system prompt, which sets the rules for the conversation, and the user prompt, which makes each request. Putting each kind of content in the right place is the foundation of prompt engineering.

Learning outcomes

After completing this lesson, you will be able to:

  • Identify the elements of a good system prompt.
  • Describe what a user prompt contains in an application.
  • Decide whether an instruction belongs in the system prompt or the user prompt.

The system prompt

The system prompt, also called the system message or instructions, is written by the developer and applies to every turn. A good system prompt usually covers the following elements.

  • Role and audience: You are a support assistant for Contoso's home-insurance customers.
  • Task and scope: what the assistant does and which topics it declines.
  • Grounding rules: Answer only from the policy text provided. If the answer is not there, say so.
  • Tone and style: formal or friendly, length, reading level.
  • Output format: bullet points, a table, JSON with given fields.
  • Safety rules: what never to do, such as giving legal advice.

Instructions in the system prompt are not a security control: users can try to override them, so guardrails and application logic enforce the rules that must never be broken.

Select all that apply

Write a system prompt

Exam skills 2.1.1

Decide what belongs in the system prompt of a home-insurance assistant.

Log in to try this activity Interactive activities are free with an account.

The user prompt

The user prompt is the specific request in each turn: a question, a document to summarize, text to classify. In an application, it often combines the user's words with content the application adds, such as retrieved documents or the text to analyze. Earlier turns of the conversation are also sent so that the model can resolve references such as it or the second option.

Where each instruction belongs

Put persistent behaviour in the system prompt and per-request content in the user prompt. A rule written only in one user prompt is forgotten when the user asks something else, and a document pasted into the system prompt is sent with every request even when it is not relevant, which wastes tokens. The following table recaps the split.

ContentBelongs in
Role, tone, scope and output format rulesSystem prompt
What to do when the answer is unknownSystem prompt
The question or task for this turnUser prompt
The text, document or data to process this turnUser prompt (delimited)

The following diagram shows the system prompt applying to every turn of a conversation.

Where instructions belong. The system prompt holds persistent behaviour: the role, tone, scope, output format rules and what to do when the answer is unknown; it applies to every turn. Each user prompt holds only that turn's question or task and the text or data to process, separated with delimiters. A rule written in only one user prompt is forgotten on the next turn, and a document pasted into the system prompt wastes tokens on every request.
Persistent rules go in the system prompt.
Troubleshooting

Misplaced instructions

Exam skills 2.1.1

Find the fix for assistants whose instructions are in the wrong place.

Log in to try this activity Interactive activities are free with an account.
Worked example

Fixing an inconsistent assistant

A travel assistant sometimes answers in long paragraphs and sometimes in lists, and occasionally gives medical advice about vaccinations. The developer has been adding answer in three bullet points to some user prompts.

Formatting and scope rules belong in the system prompt so they apply to every turn: Answer in at most three bullet points. Do not give medical advice; for health questions, recommend consulting a travel clinic. A guardrail can additionally block clearly harmful content, but the scope rule is an instruction matter rather than a content-filter matter.

Check yourself

Can a rule in the system prompt be relied on as enforcement?

Show answer

No. System prompt rules are guidance. Hard rules are enforced with guardrails and code.

Exam Tips

Remember for the exam

  • The system prompt sets role, scope, tone, grounding rules and format for every turn.
  • The user prompt carries the request and the content for one turn.
  • System prompt rules are guidance, not enforcement; guardrails and code enforce hard rules.