Home / Insights / QA and Software Testing
QA and Software Testing
Building a Test Set for Enterprise Knowledge Search: How to Measure RAG Quality Before and After Launch
A knowledge search assistant is only as trustworthy as the evidence that it finds the right passages and answers from them. This guide explains how to build that evidence: a test set of real questions, scored in a way your team can repeat every time something changes.
Key takeaways
- Score retrieval and answering separately; most bad answers start with the wrong passages.
- Source test questions from real search logs, tickets and subject experts, not from the documents themselves.
- Include unanswerable and permission-restricted questions so the system is tested on saying no.
- Agree pass thresholds and a regression gate before launch, then rerun the set on every index, prompt or model change.
- Keep the set alive: add production failures to it each month and retire questions when documents are withdrawn.
On this page
Most enterprise knowledge search projects reach a demo quickly. A few sample questions return sensible answers with citations, and stakeholders are impressed. The trouble starts a few weeks after launch, when an employee gets a confident answer based on last year’s travel policy, or a support engineer is told a runbook step that does not exist. Nobody can say whether the system has got worse, whether it was always like this, or whether the latest prompt tweak fixed or broke anything.
The remedy is not more demos. It is a test set: a curated list of representative questions with known correct sources and acceptable answers, scored the same way every time. This article walks through how we approach that test set when building enterprise knowledge search, from where the questions come from to how the results become release gates.
Decide what you are measuring
A retrieval-augmented generation (RAG) system has two stages that fail in different ways. Retrieval finds candidate passages; answering turns those passages into a response. If you only score the final answer, you cannot tell which stage to fix. We recommend scoring at least four things separately.
| Measure | Question it answers | How it is usually scored |
|---|---|---|
| Retrieval hit | Did the right passage appear in the top results? | Gold passage present in top k (for example top 5) |
| Faithfulness | Is every claim in the answer supported by the retrieved text? | Reviewer or model-assisted check, claim by claim |
| Answer correctness | Does the answer actually resolve the question? | Comparison against a reference answer or rubric |
| Appropriate refusal | Does the system say it does not know when the documents do not cover the question? | Pass/fail on unanswerable and restricted questions |
Citation accuracy (does the linked source contain the quoted point?) is worth tracking as a fifth measure when users are expected to click through, for example in legal or policy search. Latency and cost per query matter too, but they belong in performance monitoring rather than the quality test set.
Where good test questions come from
The most common mistake is generating questions by reading the documents and writing questions they answer. That produces a set the system will pass easily, because the wording mirrors the source. Real users phrase things differently, use internal shorthand and ask about situations rather than sections.
Better sources, in order of value
- Existing search logs and helpdesk tickets. HR inboxes, IT tickets and internal chat channels are full of genuine questions with the phrasing people actually use.
- Subject expert interviews. Ask the people who answer questions today which ones come up repeatedly and which ones they find hard.
- Edge cases from the documents. Exceptions, regional variations and recently changed rules, where an outdated answer would cause harm.
- Synthetic variants. Once you have real seed questions, a model can help create paraphrases and typos, but a person should review them.
Balance the set deliberately
For each document collection, aim for a mix of simple lookups, questions that need two passages combined, questions that use synonyms or acronyms not in the text, and questions that should not be answered. A practical starting size is often a few dozen questions per major collection, growing over time. Small and well-labelled beats large and noisy.
Labelling: gold passages, reference answers and negatives
Each test item needs enough labelling to be scored without debate. We use a simple record per question.
- Question text exactly as a user would type it.
- User role so permission-aware retrieval can be tested (for example, a contractor should not see payroll policy).
- Gold passages: document ID and section that contain the answer. Allow more than one where several are acceptable.
- Reference answer or rubric: the key facts that must appear, and anything that must not.
- Expected behaviour: answer, ask a clarifying question, or decline.
- Owner and review date so stale items are noticed when policies change.
Negative items deserve special attention. Include questions the corpus genuinely does not cover, questions about documents the test user is not allowed to see, and questions whose answer changed recently so an older version still exists in the index. These are where enterprise search does the most damage when it fails, and where a vendor demo almost never looks.
Running the evaluation and reading the results
Once labelled, the set should run automatically from the command line or the CI pipeline against a named configuration: index version, chunking settings, embedding model, prompt version and answering model. Store every run so results can be compared.
Automated and human scoring together
Retrieval hit rate is fully automatic. Faithfulness and correctness can be pre-scored with a separate model acting as a judge, but judge models make mistakes, so sample their verdicts. A useful pattern is to have a reviewer check every item the judge marks as failed plus a random sample of passes. Disagreements tell you whether the judge prompt needs work.
Reading failures by stage
| Pattern | Likely cause | Typical fix |
|---|---|---|
| Gold passage not retrieved | Chunking splits the answer, acronyms not matched, filters too strict | Adjust chunk boundaries, add keyword search alongside vectors, enrich metadata |
| Retrieved but answer wrong | Prompt allows the model to fill gaps, too many distracting passages | Tighten grounding instructions, re-rank, pass fewer passages |
| Answers when it should decline | No explicit “not found” instruction, low-relevance passages still passed | Relevance threshold, explicit refusal wording, test more negatives |
| Restricted content appears | Permissions applied after retrieval or missing on some sources | Filter at query time, audit connector permissions |
For a deeper look at how the vector store affects permission filtering, see our guide to choosing a vector database for a permission-aware RAG product.
Turning scores into release gates
A test set only changes behaviour if results are tied to decisions. Before launch, agree with the business owner what “good enough” means for each measure, written down alongside the scope. There is no universal number; an HR policy assistant and a contract clause finder will have different tolerances. What matters is that thresholds are explicit and set before anyone sees the results.
- Launch gate: minimum retrieval hit rate and faithfulness on the full set, and zero failures on permission-restricted items.
- Regression gate: any change to chunking, embeddings, prompts or models must not reduce a measure beyond an agreed margin, and must not introduce new restricted-content failures.
- Critical items: a small subset of high-risk questions that must always pass, regardless of the overall score.
This mirrors how we treat any other software release. If you are setting up acceptance testing more broadly, our article on planning user acceptance testing that catches problems covers how business users can take part.
Keeping the test set alive after launch
Documents change, users find new ways to ask things, and models are updated by providers. A test set that is frozen at launch slowly stops representing reality. We recommend a light monthly routine.
- Review thumbs-down feedback and unanswered queries from production logs.
- Add genuine failures to the test set with labels, so they become permanent regression checks.
- Retire or update items whose source documents were withdrawn or rewritten.
- Rerun the full set after any provider model update, even if you did not change anything yourself.
- Report trends to the business owner, not only the latest score.
This is also where the test set pays for itself commercially. When someone proposes switching to a cheaper model or a different embedding provider, you can answer with evidence within a day instead of opinion. Our article on running ML and AI features reliably in production covers the wider monitoring picture.
Frequently asked questions
How many questions does a RAG test set need?
Enough to cover each major document collection and question type, including negatives. Many teams start with a few dozen well-labelled questions per collection and grow the set from production feedback. Labelling quality matters more than size.
Can we use an LLM to grade the answers?
Yes, as a first pass. A judge model can pre-score faithfulness and correctness, but a person should review all failures and a sample of passes, and the judge prompt should itself be checked against human ratings.
Who should own the test set?
Ownership is usually shared: subject experts own the correctness of reference answers, and the engineering or QA team owns the tooling and runs. Each item should have a named owner and review date.
Does the test set replace user feedback?
No. User feedback finds new failure types; the test set makes sure fixed failures stay fixed. Feedback should flow into the test set every month.
What if our documents contain conflicting versions of the same policy?
Add test items specifically for the conflict and decide which version is authoritative. Often the fix is in ingestion, such as excluding superseded documents or adding effective-date metadata, rather than in the prompt.
Related reading
Continue your research
Do you know how often your knowledge assistant finds the right passage?
We can review an existing RAG system or plan a new one, starting with a test set built from your real questions and documents.
