Prompt Engineering: What a System Prompt Is
A system prompt is the set of instructions that sits behind every answer. It sets the persona, the rules and the facts the model must follow.
The same question with no system prompt
Without a system prompt the model has no rules to follow.
Answer this customer question: Where is my order 1042?The same question with a system prompt
The system prompt adds the persona and the facts rule.
System prompt: You are a support agent for ShopStack. Use only the ShopStack facts given in the prompt. Never invent a product, a price or a policy. User prompt: Where is my order 1042? Order 1042 belongs to Maya. It shipped and the tracking shows out for delivery.A system prompt sets the tone too
One line in the system prompt sets the tone for every answer.
System prompt: You are a friendly support agent for ShopStack. Answer in one short sentence. Use only the ShopStack facts given in the prompt. User prompt: How long does a refund take? Refunds are processed within 3 to 5 business days after the returned item arrives.Example
System prompt: You are a support agent for ShopStack. Use only the ShopStack facts given in the prompt. Never invent a product, a price or a policy. Answer in two sentences or fewer. User prompt: My mug arrived chipped. What do I do? The ShopStack damaged-item policy says a photo is required, and the customer can choose a replacement or a refund.Key points
- A system prompt is the instruction that applies to every message in a conversation.
- The user prompt asks one question. The system prompt sets the rules for all questions.
- A system prompt names the persona, like a support agent for ShopStack.
- A system prompt lists the facts the model may use and the facts it must never invent.
- The system prompt is written once and stays in place for the whole conversation.
This example runs a system prompt and a user prompt against the local model and shows the reply it gave. The system prompt sets the rules, and the user prompt asks the question.
Note
A system prompt is not a user prompt. It is the standing instruction behind the answers.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
What is a system prompt?