Before You Ship an AI Feature, Build a Small Test Set
An AI feature is easy to demo and hard to trust. You try three prompts, the answers look impressive, and the feature ships. A week later a customer finds a case where it confidently says something wrong, and nobody can tell whether the problem is new, rare or typical.
The gap is simple: traditional software has tests, and many AI features launch without anything equivalent. The good news is that a useful version costs an afternoon, not a platform.
Why "it seemed fine" isn't enough
Language models are variable by nature. The same input can produce different outputs. Small changes to a prompt, a model version, or the data you feed in can improve one kind of case and quietly break another.
Without a fixed set of examples to check against, every change is a guess. You can't tell whether the new prompt is better or just different. You end up arguing from the last example someone remembered.
Start with real examples
A test set is a collection of inputs, each paired with a description of what a good result looks like. The most important part is where the inputs come from.
- Use real or realistic data. Support messages, documents, search queries, whatever your users will actually provide. Remove or anonymise personal information first.
- Cover the range. Include typical cases, but also messy ones: typos, very short inputs, very long ones, different languages if you serve them, and unusual formats.
- Include cases where the right answer is "I don't know" or "this isn't something I can do". Many failures are about a model answering when it shouldn't.
- Add adversarial or tricky inputs. Users will test the limits, deliberately or not.
- Keep adding failures. Whenever a real problem appears, add it to the set. Over time the set becomes your memory.
Thirty to fifty well-chosen examples is a perfectly good start. More helps, but a small set you actually use beats a large one you don't.
Define what "good" means before you test
Vague goals produce vague scores. For each kind of task, write down what you'd accept. Examples:
- For classification: the label must match one of the allowed categories, and match the right one.
- For extraction: each field is correct, and missing fields are left empty rather than invented.
- For summaries: it mentions the key points and doesn't add facts that aren't in the source.
- For answers based on your documents: it uses only supplied information and says when something isn't covered.
- For tone: it follows your style guidelines and avoids promises you can't keep.
Keep it to a few criteria. You can score each example as pass or fail, or on a simple three-point scale. Simpler scoring is easier to keep consistent.
A spreadsheet is enough
A basic layout:
| Input | Expected / what good looks like | Output (current version) | Pass? | Notes |
|---|
Run each input through the feature, paste the output, mark pass or fail, and note the reason. When you change something, run the same set again and compare. You'll see quickly which cases improved and which regressed.
For tasks with clear answers, such as classification or extraction, you can automate the comparison with a small script. For open-ended text, human review is still the most reliable method, at least initially.
Using a model to grade a model
It's possible to use one language model to evaluate the output of another. It can scale review, but treat it carefully:
- Check its judgments against your own on a sample. If it disagrees with you often, it isn't a reliable grader yet.
- Give it a specific rubric, not just "is this good?"
- Keep a human in the loop for important categories.
It's a useful aid, not a replacement for looking at outputs yourself.
Test the whole system, not just the prompt
The model is only part of the feature. Failures often come from other places:
- Retrieval. If you pull in documents to answer questions, did it find the right ones?
- Input handling. Are long inputs truncated? Are special characters handled?
- Output parsing. If you expect structured data, what happens when the format is slightly off?
- Timeouts and errors. What does the user see when the model service is slow or unavailable?
- Cost and speed. A good answer that takes too long or costs too much per request may still be the wrong design.
Include these in your checks, and decide what the fallback is when something fails.
Decide the guardrails
Even with testing, some errors will reach users. Plan for them:
- Show sources or the underlying text where it helps people verify.
- Make it obvious that content is generated, where that matters.
- Give users a way to correct or report a bad result, and read what comes in.
- Keep a human step for high-stakes outputs.
- Limit what the feature is allowed to do. A feature that can only suggest is safer than one that can act.
Also think about data: what you send to a model provider, how it's stored, and what your own privacy commitments say. Check the provider's terms rather than assuming.
Keep checking after launch
Behaviour can change when models are updated, when your data shifts, or when users find new ways to use the feature. Re-run your test set whenever you change a prompt, model, or retrieval setting, and on a regular schedule even if you haven't. Sample real usage now and then and read it. Nothing replaces looking at what actually happened.
A simple plan for this week
- Pick one AI feature, existing or planned.
- Collect thirty realistic inputs, including a few awkward ones.
- Write what good looks like for each, in one line.
- Run them, score them, and look at the failures as a group. Patterns usually show up fast.
- Change one thing, run again, and compare.
- Save the set. It will be useful for every future change.
The short version
- AI outputs vary, so changes need a fixed set of examples to compare against.
- Build a small test set from real, messy inputs, including cases where the right answer is to decline.
- Define "good" in a few clear criteria before you score anything.
- A spreadsheet is enough to start, and a model can assist grading but shouldn't be trusted blindly.
- Test retrieval, parsing and failure paths too, plan guardrails, and keep re-running the set.
If your AI feature changed tomorrow, how would you know whether it got better?
We're nothink, a small team that designs and builds products for startups — more at nothink.site.
原文:https://www.a8q9.cn/en/article/before-you-ship-an-ai-feature-build-a-small-test-set-7f8651.html