Skip to content
NEXVYRA LABS home

AI Engineering

Evaluate your LLM feature before it ships

“It looked good in the demo” is not a release criterion. A practical way to build an evaluation set, choose graders and turn quality into something you can measure on every change.

NEXVYRA Labs Engineering3 min read

Most LLM features fail quietly. They answer fluently, so nobody notices when a prompt change makes them slightly worse, or when a model upgrade changes behaviour on the cases that matter most. The fix is not more prompt tweaking. It is treating quality as something you measure, the same way you measure test coverage or latency.

Start by defining the job

Before writing a single test case, write down what the feature is for and what a wrong answer costs. A support assistant that occasionally gives a vague answer is annoying; one that confidently states the wrong refund policy creates liability. The cost of error decides how strict your evaluation needs to be and where a human must stay in the loop.

  • Who uses the output, and what do they do with it?
  • What does a good answer contain — and what must it never contain?
  • When should the system refuse or escalate instead of answering?

Build a small, honest evaluation set

You do not need thousands of examples to start. Fifty to a hundred well-chosen cases will catch most regressions. The important word is honest: the set should look like real traffic, including the awkward cases, not like the examples you used while building the prompt.

  1. Collect real inputs where you can — support tickets, search logs, emails — with personal data removed.
  2. Add edge cases deliberately: ambiguous questions, out-of-scope requests, adversarial phrasing, missing information.
  3. Write the expected behaviour for each case, not necessarily the exact expected text.
  4. Keep a held-out slice you never look at while tuning, so you can check you have not overfit.

Choose graders that match the question

Different properties need different checks. Use the cheapest grader that answers the question reliably, and reserve model-based grading for judgments code cannot make.

  • Code checks for anything deterministic: valid JSON, required fields present, length limits, forbidden phrases, a citation exists.
  • Reference comparison when there is a known right answer, such as an extracted invoice total.
  • Model-graded rubrics for qualities like groundedness or helpfulness — with a specific rubric, and spot-checked against human judgment.
  • Human review for a sample of outputs, especially early on and for high-risk categories.
ts
type EvalCase = {
  id: string;
  input: string;
  expect: {
    mustCite?: boolean;      // answer must reference a source
    shouldEscalate?: boolean; // system should hand off, not answer
    mustNotContain?: string[];
  };
};

function gradeDeterministic(c: EvalCase, out: { text: string; citations: string[]; escalated: boolean }) {
  const failures: string[] = [];
  if (c.expect.mustCite && out.citations.length === 0) failures.push("missing citation");
  if (c.expect.shouldEscalate !== undefined && out.escalated !== c.expect.shouldEscalate)
    failures.push(c.expect.shouldEscalate ? "should have escalated" : "escalated unnecessarily");
  for (const phrase of c.expect.mustNotContain ?? [])
    if (out.text.toLowerCase().includes(phrase.toLowerCase())) failures.push(`contains "${phrase}"`);
  return { id: c.id, pass: failures.length === 0, failures };
}

Make it part of every change

An evaluation you run once is a report. An evaluation you run on every prompt, model or retrieval change is a safety net. Wire it into your release process so a change that lowers the pass rate on a critical category is blocked, just like a failing unit test.

Let production grow the set

Once the feature is live, every correction a reviewer makes and every complaint a user raises is a new test case. Feeding those back into the evaluation set is how quality improves over time instead of drifting.

Written by the NEXVYRA Labs engineering team. Talk to us about applying this to your systems.

  • AI Engineering2 min read

    Retrieval that holds up in production

    Retrieval-augmented generation is easy to demo and hard to get right. The decisions that matter most — chunking, ranking, permissions and citations — and how to make each one measurable.

Start a conversation

Your next big idea starts here.

Tell us what you’re trying to achieve. We’ll help you work out what to build, how to build it and what it will take.