CertBrain
Sign in
← Back to decks
Sign in to save your progress.Sign in

Writing System and User Prompts

A model can only follow the instructions it is given, so the wording of your prompts decides how useful its replies are. This lesson covers writing system and user prompts, adding examples, and testing your wording before an app depends on it.

10 cards

Writing System and User Prompts

In this lesson · 6 sections
Show one section at a time

Terms you'll meet

Tap a card to see what it means.

A model can only follow the instructions it is given, so the wording of your prompts decides how useful its replies are. This lesson covers writing system and user prompts, adding examples, and testing your wording before an app depends on it.

What a system prompt should settle

The system prompt lets the developer settle several things once, so every conversation starts from the same place. A useful one answers four questions. What is the assistant, and what is its job? Who is it talking to, and in what tone? What is out of bounds, and what should it say when a request falls outside its job? What shape should replies take? Picture a help assistant for a city library. Its system prompt could name that role, ask for plain language aimed at members of the public, limit it to library services, and tell it to point people to the front desk when it cannot answer. Microsoft's system message guidance adds tools and data sources as an optional component, advises second person ("You are...") and favors concise wording. Always spell out the fallback, so the edge of the assistant's scope is covered by an instruction.

Writing the user prompt

The user prompt carries the job of the moment, and a vague request gets a vague reply. Say what you want done, for whom and in what form. Microsoft's prompt engineering page suggests stating the task before supplying extra material; in its tests on GPT-4-era chat models, order made no visible difference, so treat ordering as something to test. When you paste in material to work on, such as a transcript, mark where it starts and ends with a separator such as ###, or with tags. Give the model an exit token, for example telling it to answer UNKNOWN when the material lacks the answer, which can help it avoid inventing one. Ask for a defined output structure, such as fixed fields, so code can parse replies. One caution: that page opens by saying its techniques are not recommended for reasoning models, and its examples come from a base GPT-4 model. That covers its prompting techniques, not system prompts in general, but Microsoft's deployment quickstart uses a model from a family the page counts among reasoning models, so expect to meet the caveat.

Examples instead of rules

Some behavior is hard to describe and easy to show. Including sample input and output pairs in a prompt is called few-shot prompting (one-shot for a single pair, zero-shot for none). In a chat request, the pairs go into the message list as invented user and assistant turns placed after the system message. The model is not retrained by them: they steer only the request that carries them, so they must be sent every time. Choose examples that cover awkward cases, not just easy ones, and make each sample reply look exactly like the reply you want. To sort expense claims into your company's own category names, three sample claims with the names you would assign teach the scheme faster than a paragraph describing it.

Choosing where a fix belongs

This table is the lesson's own rule of thumb, not a Microsoft table.

SymptomBest place for the change
A rule should hold in every conversation, whatever users typeSystem prompt
This one request needs a different task or a particular source textUser prompt
The format or labels keep being misapplied even though they are describedFew-shot examples
Replies are too random or too rigid from run to runA parameter such as temperature, if the model accepts it

A rule that must always apply belongs where the user cannot forget it, which is the system prompt. Material that matters for one request belongs in that request. Examples help when description alone fails. A parameter changes how the model samples its words; it cannot teach a rule or a format, and some models do not accept every sampling setting, as the Area 1 lesson on deployment options explains. In practice the changes combine, with a system rule backed by examples and a tested parameter, but changing them one at a time shows which layer actually did the work.

Testing before you trust the wording

Treat a prompt like code that needs tests. The Foundry portal's model playground lets you edit a system prompt, send messages and adjust settings without writing application code. Build a small test set that mixes ordinary requests with awkward ones, including attempts to push the assistant off its job, and rerun it after every edit. Change one thing at a time so you know which edit helped. Microsoft's guidance warns that a determined adversarial user can get around a system message or weaken it, and that one that is too broad or too strict can reduce usefulness, so a system prompt is one layer of protection, not a complete safety solution. Whatever the technique, verify it on the model you actually deploy.

On the exam

Study tips: for each prompt problem, ask where the fix belongs. A rule that must hold regardless of what the user types points to the system prompt. A format that keeps going wrong despite a clear description points to examples. A pasted document that blurs into the instructions points to separators. A model that invents missing facts points to giving it an exit token. Remember that prompts and examples never change the model itself, and that testing in the playground comes before the wording goes into an app.

CertBrain is an independent study tool. It is not affiliated with, endorsed by, or sponsored by Amazon Web Services, Inc. or Microsoft. Learn more

Quiz me on this
What should a system prompt settle?
Save
Few-shot prompting in a chat request
Save
Why add separators around pasted material?
Save
Give the model an exit
Save
How to iterate on a prompt
Save