News / Learn / Evaluation & safety
Why do AI apps need evals?
You'll be able to explain why AI apps need evals and set up a simple test loop for one.
In plain English
An eval is a repeatable test for an AI feature. You give the app a set of inputs, check the outputs against what you expect, and record the score. Unlike normal software, an AI app can give different answers to the same question, and a small change to a prompt can break things nobody noticed.
Why it matters
AI features fail in quiet ways. An answer can sound fluent and still be wrong, off-topic, or unsafe. Without evals, you learn about these failures from users. With evals, you can change a prompt, swap a model, or adjust retrieval and see whether the app got better or worse before it ships.
How it works
Traditional code is deterministic. The same input gives the same output, so unit tests with exact matches usually work. An LLM is probabilistic. Its output depends on the input, the model, sampling settings like temperature, and even small wording changes in the prompt. A test that passes once may fail on the next run.
An eval handles this by measuring quality across many examples rather than checking one answer. You build a set of representative inputs, often with reference answers or clear criteria. You run the app on each input, then score the outputs. The score might be an exact match, a rule check such as valid JSON or a required field, or a judgment about whether the answer is correct and grounded in the source material.
The score matters most when you compare versions. Run the same eval before and after a change. If the average goes up but a specific category drops, you have found a tradeoff to review. Keep the results with the version of the prompt, model, and settings that produced them.
Evals also guard against regressions. Each time a user reports a bad answer, add that case to the set. Over time the set reflects the real failures your product has seen, and it becomes a shared record of what good behavior means for your app.
A concrete example
A minimal eval loop: a few cases, a rule-based check, and a pass rate. Replace `call_app` with your own function.
cases = [
{"input": "What is the refund window?", "must_contain": "30 days"},
{"input": "Can I cancel anytime?", "must_contain": "cancel"},
{"input": "Do you ship abroad?", "must_contain": "countries"},
]
def call_app(question: str) -> str:
# Call your model or pipeline here.
raise NotImplementedError
def run_eval():
passed = 0
for case in cases:
answer = call_app(case["input"])
ok = case["must_contain"].lower() in answer.lower()
passed += ok
print(("PASS" if ok else "FAIL"), case["input"])
rate = passed / len(cases)
print(f"Pass rate: {rate:.0%}")
return rate
if __name__ == "__main__":
run_eval()A short sketch to show the idea. Check the official docs of the tool you use.
What goes wrong
- Testing only with examples you wrote Add real user questions and past failures. Your own examples tend to be the cases your app already handles well.
- Judging by one run Run each case several times or use a larger set. Single results can be noise because model output varies.
- Changing many things at once Change one variable at a time, such as the prompt or the model, so you can tell which change caused a result.
- Treating a score as the whole truth Read the failing outputs yourself. A number tells you that something changed, not why.
Going deeper
Next, learn how to build a larger eval set from real usage, and how to score open-ended answers when a simple string check is not enough.
FAQ
Do I need evals if my app only does a simple task?
Yes, though the eval can be small. Even ten well-chosen cases will catch a prompt change that breaks a common request.
Can I use the same eval for every model?
You can, and that is useful. Running the same cases on different models gives you a fair comparison for your own use case.
How many cases do I need?
Start with 20 to 50 that cover your main use cases and known failures. Grow the set as you learn where the app breaks.
Are evals the same as benchmarks?
No. Public benchmarks measure general ability. Evals measure whether your app does the job your users need.
Written with AI by CapyLaunch. Spotted a mistake? Email hello@capylaunch.com.