RAG evals that caught bugs our users would have

A small, boring evaluation set that runs on every change found more real problems than any amount of chatting with the bot.

The easiest way to test a retrieval-augmented chatbot is to talk to it. You ask a few questions, the answers look right, and you ship. I did that for a while. Then I wrote a small evaluation set and ran it on every change, and it started catching problems that would otherwise have been reported by customers.

This post covers what goes into that set, how it runs, and the kinds of bugs it caught. None of it needs a framework, though frameworks exist if you want one.

What a RAG system can get wrong

There are three separate places to fail, and a single "is the answer good?" score hides which one broke:

  1. Retrieval: the right chunk never reaches the model.
  2. Grounding: the right chunk arrives, but the model answers from its own general knowledge or invents details.
  3. Refusal: the question is out of scope, and the bot answers anyway instead of saying it doesn't know.

For a multi-tenant product there is a fourth, and it is the one that matters most: isolation. One customer's question must never be answered from another customer's documents.

Building the set

I keep it small enough to read: somewhere between fifty and a hundred cases per test tenant. Each case is a question plus what a correct system should do.

json
{
  "q": "How long is the refund window?",
  "tenant": "demo-coffee",
  "expect_source": "refund-policy.pdf",
  "must_contain": ["30 days"],
  "kind": "answer"
}

The cases come from four places:

  • Questions real users asked, with personal details removed.
  • Paraphrases of those questions, because users rarely use the document's wording.
  • Out-of-scope questions with "kind": "refuse", such as asking a coffee shop's bot about tax law.
  • Cross-tenant traps: asking tenant A something only tenant B's documents can answer.

Scoring without a judge model

You can use an LLM to grade answers, and for nuanced cases it helps. But most of my checks are plain code, because plain code is cheap, fast and never has a bad day.

python
def score(case, result):
    out = {}
    srcs = [c.source for c in result.chunks]
    if case["kind"] == "answer":
        out["hit@k"] = case["expect_source"] in srcs
        out["contains"] = all(s.lower() in result.text.lower() for s in case["must_contain"])
        out["cited"] = case["expect_source"] in result.citations
    elif case["kind"] == "refuse":
        out["refused"] = result.refused
    elif case["kind"] == "isolation":
        out["no_leak"] = all(c.tenant == case["tenant"] for c in result.chunks)
    return out

The run prints a table of pass rates per kind and lists every failure with the retrieved chunks next to it. Reading those failures is where the value is.

The bugs it caught

A chunker that cut tables in half

Pricing questions started failing after a change to the chunk size. The new chunker split a pricing table between two chunks, so the row with the price and the row header naming the plan were never retrieved together. The fix was to treat tables as a single unit.

Stale answers after a document update

A customer edits their FAQ and expects the bot to follow. One eval re-uploads a changed document and asks about the new value. It caught a path where old vectors were never deleted, so the bot quoted both versions.

A prompt change that made the bot helpful in the wrong way

Softening the system prompt made answers friendlier, and the refusal pass rate dropped sharply. The bot had started answering general questions from its own knowledge. Without the refusal cases, that would have looked like an improvement.

Isolation, the one that must never fail

The isolation cases are a hard gate: a single failure blocks the release. The strongest protection is architectural, with a separate vector collection per tenant so a query physically cannot reach another tenant's data. The evals exist to prove that stays true as the code changes.

Rule of thumb

If a failure would be embarrassing, make it a hard gate. If it is a quality trend, track it and look at it weekly.

Running it

CheckWhen it runsGate
IsolationEvery pull requestMust be 100%
RefusalEvery pull requestNo drop from the last release
Retrieval hit@k, groundingEvery pull requestReported, reviewed by a person
LLM-judged answer qualityNightlyTrend only

Changes to the chunker, the embedding model, the prompt or the LLM provider all trigger the full set. Those are exactly the changes that feel safe and are not.

What I would tell someone starting

  • Start with twenty cases you wrote by hand this afternoon. A small set you run is worth more than a large one you plan.
  • Separate retrieval from generation in your scores, or you will fix the wrong half.
  • Write refusal and isolation cases first. They are the failures users remember.
  • Read the failures, not just the percentages.
Chatting with your bot tells you it can be right. An eval set tells you when it stopped being right.
Shakaut Hossain

AIoT engineer and tech lead in Dhaka. I build edge AI, firmware and LLM products, and teach robotics and AI for free.

More about me →
KEEP READING · related

More from the bench

All posts →
NEWSLETTER · monthly

Get the next one in your inbox.

New posts and lectures, once a month. Unsubscribe in one click.

Thanks, you’re on the list.