How to build a small evaluation set for an AI assistant
Build a six-case answer key for a library assistant. Change one detail at a time to see whether the assistant follows a renewal rule or just gives the usual answer.
Prerequisites
Use Python 3.8 or later and a shell that supports here-documents, such as Bash. Run both command blocks in the same empty directory. The example uses invented requests and runs offline.
Worked example
- Choose one decision a reader relies on. Our fictional library allows a renewal when a book has fewer than two prior renewals and nobody else has a hold. A hold or two prior renewals means DENY. If the request lacks the facts needed to decide, the assistant should ASK. An answer passes when it gives the correct decision without a second prompt.
- Write the answer key before collecting replies. Give each case a permanent ID, the input the assistant will see, and your expected decision. The first two cases ask the same thing in different words. Compare the third case with the fourth: one prior renewal becomes two. Compare the third with the fifth: only the hold changes. The last case tests whether the assistant asks for missing information.
cat > cases.psv <<'CASES' id|request|expected basic|No holds, never renewed. Can I renew?|RENEW reword|First renewal, nobody waiting. May I keep it longer?|RENEW below|One prior renewal, no holds. Can I renew?|RENEW limit|Two prior renewals, no holds. Can I renew?|DENY hold|One prior renewal, one hold. Can I renew?|DENY missing|Can I renew this book?|ASK CASES- Collect one decision per case. For a real run, give the assistant the library rule and each request in a fresh conversation. Keep the expected column out of the prompt. Record the first reply even if it is wrong. The sample below scores six invented replies so you can try the method without a model account.
python3 - <<'PY' import csv # Sample replies, keyed by case ID. replies = { "basic": "RENEW", "reword": "RENEW", "below": "RENEW", "limit": "DENY", "hold": "RENEW", "missing": "ASK", } with open("cases.psv", encoding="utf-8", newline="") as src: cases = list(csv.DictReader(src, delimiter="|")) ids = [case["id"] for case in cases] if len(ids) != len(set(ids)) or set(ids) != set(replies): raise ValueError("Each case needs a unique ID and one reply") passed = 0 for case in cases: key, want = case["id"], case["expected"] got = replies[key] if got == want: passed += 1 else: print(f"{key}: expected {want}, got {got}") print(f"{passed}/{len(cases)} cases passed") PY- Read the failed request next to its passing neighbor. The sample replies allow renewal in both the “below” and “hold” cases. The hold should change the decision. Save the failed case as a regression check. Before changing the assistant, set aside fresh requests and their answer keys for a later check; keep paraphrases of the same request together so the later check uses genuinely new cases.
- Keep the case file with a short note recording where the requests came from, which rule version you used, and what the set leaves out. For each run, save the replies, model and prompt version, date, and any human corrections. These records let another reader rerun the comparison after the policy or assistant changes.
Expected output
hold: expected DENY, got RENEW
5/6 cases passed
Limitations
Six handpicked cases can reveal a specific mistake. They cannot estimate how often real patrons encounter it. The sample replies are fixed; repeat real model runs to see whether answers vary. Exact labels suit this routing decision. For free-text answers, write a rubric and have reviewers score meaning, including whether the explanation cites the right rule.