AI products

RAG evaluation before production: the golden dataset, the metric and the gate

A demo shows that a retrieval system can answer. An evaluation shows how often it answers correctly on your documents, and whether it still does after the next change. This is how we measured it on a live platform, with the numbers.

Short answer. Evaluate a RAG system the way it will be used: on a labelled set of your own real documents, with the metric defined per field or per answer, re-run on every change, and with a threshold that blocks the release when the number drops. On the logistics platform in our case study that meant about 2,000 documents labelled by our engineers together with the client’s analysts, 99.2% field-level extraction accuracy on production flows, about 4% of fields routed to an analyst because the model was not confident enough, and an evaluation run on every change to prompts, models or the pipeline that could stop a release.

Why a demo is not an evaluation

Most RAG demos are built on the documents that make it look good: clean PDFs, one language, the questions the builder already knows the answers to. Production sends everything else. On the logistics platform the documents came from 14 disconnected sources — invoices, customs paperwork, shipment documents, email attachments, internal exports — in five operating languages, against a knowledge base of about 2,500 documents and 15,000 pages that was reindexed every day.

An evaluation answers two questions a demo cannot. How often is the output correct on the documents this business actually receives? And is it still correct after the prompt, the model, the chunking or the retrieval settings change? Without the first, nobody can say whether the system is good enough to replace manual work. Without the second, every improvement is a guess that might have broken something else.

Build the golden dataset from your real documents

A golden dataset is a set of inputs with the correct output already agreed by people. On the logistics build it was about 2,000 documents, built across the languages and document types the system had to handle, and it existed from week one — before the extraction flows were shipped, so every version of them could be measured against the same thing.

The labels were made by our engineers together with the client’s analysts, and that pairing is the point. Engineers know what the pipeline sees in a document; analysts know what “correct” means for the business. Where two careful people disagree about a label, the disagreement is itself a finding: a definition of correct that people read differently will be read differently by a model too.

Three rules hold for any golden set, ours or not:

RAG evaluation metrics: retrieval and generation separately

A wrong answer from a RAG system has two possible causes: retrieval did not find the right material, or the model did something wrong with material it had. One overall score hides which one it was, so the standard practice is to measure the layers apart.

LayerQuestion it answersTypical metricNeeds a human label?
RetrievalWas the right source in the context the model saw?Recall or hit rate at k; rank of the first correct sourceYes: which source holds the answer
GroundingIs every claim in the output supported by that context?Faithfulness, groundednessCan be checked against the context itself
AnswerDoes the final answer match what a person agreed is correct?Correctness against the labelYes: the label
ExtractionIs each value written to the target system right?Field-level accuracy, per field typeYes: the correct value per field
ConfidenceDoes low confidence really mean a likely error?Accuracy above and below the review thresholdYes, to calibrate the threshold
OperationsIs it fast and cheap enough at real volume?Latency (average and p95), cost per answerNo

On the logistics platform the headline metric was field-level accuracy, because the output was not prose but values written into the client’s ERP: a wrong date or amount is the error the business pays for. The operating numbers were measured the same way: 1.9 seconds on average to the last token (4.2 s at p95), and about $0.011 per answer across roughly 40,000 queries a month. Running that cost for your own volume is what the LLM cost calculator is for.

Field-level vs document-level accuracy

The 99.2% on our case study is field-level: each extracted value is counted on its own, and 99.2% of them were correct. That is the honest unit for this system, but it is not the same number as “documents processed without an error”, and an evaluation report has to say which one it gives.

Arithmetic, not a measurement from the project. If a document carried 20 fields and errors were independent, 99.2% per field would leave about 85% of documents with every field right (0.99220 ≈ 0.85). Real errors cluster — one bad scan breaks several fields at once — so the true document-level figure is usually higher than that, but the gap is why a vendor quoting “99% accuracy” without a unit has told you very little.

Report both, and per field type where it matters. An average across field types can hide a weak one: easy fields such as dates pull the total up while a hard one, such as a free-text description, sits well below it.

Route uncertain outputs to people

No extraction system is right every time, so the useful question is which outputs a person should see. On the logistics platform every value carried a confidence score, and values below the threshold went to an analyst review workspace with the source highlighted and every decision kept in an audit trail. After all the improvements, about 4% of fields were routed there.

That is how 87% less manual processing and human control live in the same system: the analysts’ work moves from keying values to checking the small share the model is unsure about, with the source highlighted beside it.

The threshold is a business decision as much as a technical one. Set it lower and more values reach people, so review costs more. Set it higher and more errors go through unseen. The golden set is what makes the choice measurable: it shows the accuracy of the values above the threshold and of those below it, so the trade can be priced instead of guessed.

Make evaluation a release gate

On the logistics build the golden set was re-run on every change to prompts, models or the pipeline, and a drop below the accuracy threshold blocked the release. That turns evaluation from a report somebody reads into a test the deployment has to pass, the same way unit tests stop a build. Four things make such a gate trustworthy:

  1. Pin what is being compared. The same frozen golden set, the same scoring code, results stored per run, so two runs can be compared field by field.
  2. Gate on the number the business relies on. For an extraction system that is field-level accuracy; for an answer system, correctness and grounding together.
  3. Look at slices, not only the total. A change that improves one language and breaks another can leave the average unchanged.
  4. Treat a model upgrade as a change. A newer model is not automatically better on your documents, and the gate is how you find out before your users do.

The gate covers changes to the system. Changes to the data — a new supplier, a new document format — arrive without a release, which is why the platform also went live with monitoring and accuracy dashboards in production.

What the score does not tell you

What evaluation costs, and when to start

Evaluation is part of the build, not an add-on after it. On our published bands, a full AI product — retrieval pipeline, frontend, backend, integrations and the evaluation work a demo does not need — runs $40,000–$120,000 over 8–12 weeks. The logistics platform went live in 10. An LLM feature added to a product you already run is $15,000–$30,000 over 2–4 weeks, and it needs a smaller golden set, not none.

The cheapest moment to start is before anything is built. A data audit on a genuine random sample of your documents tells you whether a golden set can be agreed at all, and it is the first step of AI consulting by the hour. Where it leads next: custom AI document processing when the output is values, AI integration when it is answers inside your product, and the trade-off in RAG or fine-tuning if retrieval is not the right tool at all.

Common questions

Four that come up once a RAG system has to be trusted.

RAG evaluation is measuring a retrieval-augmented system against answers you already know are correct: whether retrieval found the right source, whether the output is supported by that source, and whether the final answer or extracted value matches a label a person agreed on. Done properly it runs on your own documents and on every change, not once on a demo set.
Measure retrieval and generation separately. For retrieval: did the right source make it into the context (recall or hit rate at k). For generation: is every claim supported by the retrieved context (faithfulness or groundedness), and does the answer match the label (correctness). For systems that extract values into another system, field-level accuracy is the number the business feels, and the unit has to be stated, because field-level and document-level accuracy are very different numbers.
Large enough to cover every source, language and document type the system will see in production. On the logistics platform in our case study it was about 2,000 documents across the platform’s languages and document types, labelled by our engineers together with the client’s analysts. A narrower product can start smaller, but never with only the tidy examples.
Not for ground truth. A model grading another model is a useful second check on open-ended answers, where exact matching does not work. For values that end up in a system of record, the correct answer has to come from people who know the documents, and the judge itself has to be checked against those labels before anyone trusts its scores.

Need to know how good your RAG system really is?

Send a sentence about what it does and what it is fed. We will tell you what a golden set for it would look like, and what measuring it properly would take.

Message received

We’ll review your enquiry and respond within one business day.

Related reading