← All news

News / Learn / Building AI products

How do you measure whether an AI feature works?

You'll be able to design a simple, repeatable way to tell whether an AI feature is working for your users.

An AI feature gives different answers to the same question, so you cannot judge it by a single good output. You need a fixed set of test cases, a clear definition of a good answer, and a way to score many outputs. This practice is called evaluation, or an eval.

Without measurement, you cannot tell if a change to your prompt, model, or data made things better or worse. Teams often ship a feature because a few demos looked good, then discover failures only after users complain. A small eval set lets you change things with confidence and catch regressions before users do.

Start by writing down what success means for your feature in plain terms. For a support assistant, that might be: the answer is correct, cites the right document, and stays under a set length. Turn each part into a check you can apply to an output.

Next, build a dataset of realistic inputs. Include common cases, edge cases, and past failures. Store each input with an expected result or a grading note. Keep it in a file under version control so it grows over time.

Then score the outputs. Some checks are simple code: does the output parse as valid JSON, does it contain a required field, is it under a word limit. Other checks need judgment, such as whether an answer is factually right. For those, you can have a person grade a sample, or use a second model as a grader with a clear rubric. Check the grader against human labels before you trust it.

Finally, run the eval every time you change the prompt, the model, retrieval settings, or tools. Compare the scores to the previous run. Track the failures, read them, and add new cases to the set. Over time, the eval becomes a record of what your product must not break.

A small eval that checks structured output and a required fact for each test case.

import json

cases = [
    {"input": "Refund policy for annual plans?", "must_include": "30 days"},
    {"input": "Can I change my email address?", "must_include": "account settings"},
]

def run_feature(text):
    # Replace with a call to your AI feature.
    return json.dumps({"answer": f"Stub answer for: {text}"})

def score(case):
    raw = run_feature(case["input"])
    try:
        data = json.loads(raw)
    except json.JSONDecodeError:
        return False
    return case["must_include"].lower() in data.get("answer", "").lower()

results = [score(c) for c in cases]
print(f"Passed {sum(results)} of {len(results)}")

A short sketch to show the idea. Check the official docs of the tool you use.

  • Judging by a few demos Build a fixed set of realistic test cases and score all of them each time you change something.
  • Measuring only what is easy Combine simple automatic checks with human review of a sample, so you also catch quality problems that code cannot detect.
  • Trusting an automatic grader blindly Compare the grader's scores with human grades on a sample. Fix the rubric until they mostly agree.
  • Letting the test set go stale Add every real failure from users or production logs to the eval set so the same bug cannot return unnoticed.

Learn about grading rubrics, inter-rater agreement, and how to sample production traffic for review. Also look into testing retrieval separately from generation, so you can see whether a wrong answer came from missing documents or from the model.

How many test cases do I need?

Start with a few dozen covering your main use cases and known failures. Grow the set as you learn. Quality and realism matter more than raw count.

Can I skip evals if my feature is small?

Small features still change when prompts or models change. Even a short list of checks saves time when something quietly breaks.

Do I need to measure with real users?

Offline evals catch problems before release. Live measures, such as user corrections or thumbs-down rates, show how the feature performs in practice. Use both.

Who should write the eval cases?

People who know the domain should write or review them. Include support staff or domain experts, not only engineers.

Written with AI by CapyLaunch. Spotted a mistake? Email hello@capylaunch.com.