Notes
Same question
We asked ShopRung's chat, running on the local model llama three point two with three billion parameters, how much shipping costs, three times. Three different wordings came back. All three were right: four ninety nine, free from seventy five dollars. An assert equals on the text would fail on the second run. Yet the answers are fine.
1: Shipping costs $4.99 per order if your subtotal ... is less than $75.00, but it's free when your total is $75.00 or more. 2: Shipping costs $4.99 ... If you have a coupon that brings your subtotal above $75.00, ... 3: Shipping costs are $4.99 per order unless your subtotal after any discount is $75.00 or more, in which case it's free.
Sometimes wrong
Worse, the same question can be answered well twice and badly once. Asked whether a shipped order can be cancelled, two runs gave the correct rule from the help page. The first said it did not know, and suggested calling a customer service team that does not exist. One run of a test would have passed or failed by luck.
2, 3: No, a SHIPPED or DELIVERED order
can no longer be cancelled. ✓
1: I don't know how to cancel a
shipment. You can try emailing
support@shoprung.test ... or call
our customer service team. ✗
there is no phone team: invented Why
Why? A language model writes one piece of a word at a time, choosing from a probability list. With a temperature above zero, ShopRung uses zero point seven, it samples, so less likely words sometimes win. The answer also depends on its context: which help pages were retrieved, the conversation so far, the exact wording. New model versions answer differently. Even temperature zero can drift on different hardware.
- sampling: each next word is drawn from probabilities (temperature 0.7 here)
- context: retrieved pages, history, wording of the question
- model updates: new versions answer differently
- hardware and batching: even temperature 0 can drift
Not all of it varies
The good news: most of an AI feature is ordinary code. ShopRung's retrieval picks the same help sections for the same question every time. An off topic question, like the capital of France, got the same refusal three times out of three, with zero tokens in about a millisecond, because code refuses it before any model call. The order tool refused Bob access to Alice's order every time. Test these layers with normal unit and API tests.
retrieval: same sections for the same question, every run out of scope: "capital of France" 3/3 identical refusal, 0 tokens, about 1 ms, no model call order tool: Bob asking for Alice's order: refused 3/3 guardrails: rules in code
A fake model
To test the plumbing, swap the model. ShopRung starts with a built in fake model by default, which gives the same answer every time and needs no setup. Your API tests can then check status codes, the response shape, sources, refusals and guardrails exactly, in CI, in milliseconds. The real model, through Ollama, is for evals: the tests about answer quality.
fake (default): same answer every run no setup, CI-friendly llama3.2:3b via Ollama: real answers, real variation API tests use the fake; evals use the real model
Check properties
For the answers themselves, check properties instead of exact text. The shipping answer must contain four ninety nine and seventy five dollars, and must not contain a made up coupon. The sources must include the shipping page. Answers stay short, with no leaked markup. We wrote checks like these for twelve questions and ran each three times: thirty two of thirty six answers passed, eighty nine percent.
must contain: "$4.99", "$75.00" must not contain: "FREE100", "90 days", "Paris" sources include: shipping length: under 3 sentences format: no raw <help> tags real run: 32 of 36 answers passed these checks (89%)
Repeat and measure
Because one run proves little, repeat. Run each question several times and report a pass rate, per question and overall. Set thresholds: maybe ninety percent overall, but one hundred percent for safety checks, such as never inventing a coupon. Then compare every change, a new prompt or a new model, against the last run. The next episodes build exactly this.
- run each question N times
- report a pass RATE per question and overall
- set a threshold: e.g. ≥ 90% overall, 100% for safety checks (no fake coupons)
- compare with the last run before shipping a change
Common mistakes
Mistakes. Asserting the exact answer text. Running a question once and calling it done. Testing everything through the real model, which is slow and flaky, when most layers are deterministic. Forgetting retrieval, tools and guardrails, which cause many real failures. And having no fixed set of questions, so nobody can tell whether a change made things better or worse.
- assert answer == "..."
- one run, then "it works"
- testing only through the real model (slow, flaky)
- no tests for retrieval, tools and guardrails
- no fixed question set to compare versions
Say it like this
In the interview: I split the feature into layers. Retrieval, tools, guardrails and refusals are code, tested with unit and API tests, using a fake model in CI. Answer quality gets evals: a fixed set of questions, property checks such as must contain and must not contain, several runs per question, and pass rates with thresholds, compared from one version to the next.
- "I split it into layers.
- Retrieval, tools, guardrails and refusals are code: unit and API
- tests, with a fake model in CI.
- Answer quality gets evals: a fixed question set, property
- checks (must contain, must not), several runs per question, pass
- rates with thresholds, compared
- version to version."