Prompt Engineering: Choosing Good Examples
Good examples cover the edges of a task, not just the easy cases. One bad example can teach the model the wrong thing.
An edge example about shipping
The Canada question has an answer that must be stated plainly.
You are a support agent for ShopStack. Answer each customer question in one sentence. Example 1. Question: Where is my order 1042? Answer: Order 1042 shipped and is out for delivery. Example 2. Question: Do you ship to Canada? Answer: ShopStack ships within the country only. Question: Can I use two discount codes on one order? Answer:A bad example poisons the set
One invented code in the examples teaches the model to invent codes.
You are a support agent for ShopStack. Answer each customer question in one sentence. Example 1. Question: Where is my order 1042? Answer: Order 1042 shipped and is out for delivery. Example 2. Question: What is the discount code for first orders? Answer: Use code WELCOME10 for 10 percent off your first order. Question: What is the discount code for first orders? Answer:A good set covers the edges
Easy cases plus two edge cases make a set the model can trust.
You are a support agent for ShopStack. Answer each customer question in one sentence. Example 1. Question: Where is my order 1042? Answer: Order 1042 shipped and is out for delivery. Example 2. Question: Do you ship to Canada? Answer: ShopStack ships within the country only. Example 3. Question: What is the discount code for first orders? Answer: There is no first-order code. Question: Can I use two discount codes on one order? Answer:Example
You are a support agent for ShopStack. Answer each customer question in one sentence. Example 1. Question: Where is my order 1042? Answer: Order 1042 shipped and is out for delivery. Example 2. Question: Do you ship to Canada? Answer: ShopStack ships within the country only. Example 3. Question: What is the discount code for first orders? Answer: There is no first-order code. Example 4. Question: Can I return the cushion? I bought the wrong colour. Answer: Yes, returns are allowed within 30 days for unused items. Question: I want a refund for order 1044 but I already used the tote. Answer:Key points
- Good examples cover the easy cases and the edge cases.
- An edge case is a question with an answer that surprises, like a question with no code to give.
- One bad example poisons the set. The model copies the bad example as if it were correct.
- An example that invents a discount code teaches the model to invent discount codes.
- A good set mixes short answers and longer answers, so the model learns when each fits.
This example runs a few-shot prompt with edge cases against the local model and shows the reply it gave. The set covers the edges, so the new answer follows the policy instead of guessing.
Note
Check every example against the ShopStack facts before adding it to the prompt.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
Why does a good example set include edge cases?