🎓 A1Learner
🔍
0 of 50 lessons completed

Prompt Engineering: Writing a System Prompt for ShopStack

A good system prompt for ShopStack is built line by line. Each line adds one thing: the persona, the facts rule, the tone and the shape of the answer.

Line one: the persona

One line sets who the model is.

System prompt: You are a support agent for ShopStack. User prompt: Where is my order 1042? Order 1042 belongs to Maya. It shipped and the tracking shows out for delivery.

Lines one and two: persona plus facts rule

The second line stops the model from inventing facts.

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: What is the discount code for first orders? There is no first-order code.

The full system prompt

Four lines cover the persona, the facts, the honesty rule and the tone.

System prompt: You are a friendly support agent for ShopStack. Use only the ShopStack facts given in the prompt. Never invent a product, a price or a policy. If the facts do not cover a question, say so plainly. Answer in two sentences or fewer. User prompt: Do you ship to Canada? ShopStack ships within the country only.

Example

System prompt: You are a friendly support agent for ShopStack. Use only the ShopStack facts given in the prompt. Never invent a product, a price or a policy. If the facts do not cover a question, say so plainly. Answer in two sentences or fewer. User prompt: I ordered the Hearthstone Desk Lamp yesterday and it still says processing. When will it ship? Order 1043 belongs to Tom. It was placed yesterday and is still processing, not yet shipped. Delivery takes 2 to 4 business days.

Key points

  • A system prompt for ShopStack starts with the persona. The model is a support agent for the shop.
  • The second line is the facts rule. The model uses only the ShopStack facts in the prompt.
  • The third line is the honesty rule. A question with no answer in the facts gets a plain no, not an invented answer.
  • The fourth line sets the tone and the shape. Short answers in a friendly tone.
  • Each line is tried on its own before the next line is added.

This example runs the full ShopStack system prompt against the local model and shows the reply it gave. Each line of the system prompt was added and tried on its own.

Note

Add lines one at a time. A system prompt built all at once is hard to fix when it goes wrong.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

What is the second line of the ShopStack system prompt?