BM
Bashar ModallalSOFTWARE · AI · SYSTEMS
← All field notes

AI

Build a Small Evaluation Dataset Before Tuning Your RAG System

A practical method for building a compact, versioned RAG evaluation set that separates retrieval, grounding, answer quality, and safe abstention.

An evaluation dataset flows through retrieval and answer checks into a balanced scorecard, with separate answerable, ambiguous, unsupported, and restricted paths.

Build a Small Evaluation Dataset Before Tuning Your RAG System

Estimated reading time: 9 minutes

Read the Arabic edition: ابنِ مجموعة تقييم صغيرة قبل تحسين نظام RAG

When a retrieval-augmented generation system gives a weak answer, the visible symptom is often blamed on the language model. The cause may instead be a missing source, a retriever that ranks the wrong passage, a chunk that lost its heading, a prompt that fails to use the evidence, or an answer policy that should have declined to guess. Changing the model before locating the failing layer can increase cost without fixing the defect.

A small, carefully designed evaluation dataset gives engineers a repeatable way to separate these causes. It is not a miniature benchmark that proves broad capability. It is a compact set of representative questions, expected evidence, and acceptable outcomes that lets a team compare one change with another on the same cases. Its value comes from deliberate coverage and trustworthy labels, not a large row count.

Start with the decision

Write down what a release decision should answer before selecting metrics. Should a new chunking rule replace the current one? Does a reranker retrieve the policy clause that answers a question? Does the generator cite evidence rather than invent a detail? Does it abstain when a source is absent? Does an access filter prevent one tenant from seeing another tenant’s document?

These are different questions. A single aggregate score can conceal opposite changes: retrieval may improve while answer grounding gets worse. Keep component checks alongside end-to-end outcomes. The RAGAS paper describes dimensions including context relevance, faithfulness, and answer quality. ARES evaluates context relevance, answer faithfulness, and answer relevance, using trained judges and a small human-labeled set to calibrate estimates. Such frameworks help structure measurement; they do not decide what “correct” means for a particular product.

A dataset row should preserve enough detail to reproduce and review the test:

Field Purpose
case_id Stable identity for diffs and review
question Exact user request
answerability Answerable, ambiguous, unsupported, or restricted
expected_facts Claims a correct response must include
relevant_source_ids Documents or passages containing those facts
forbidden_claims Plausible details the evidence does not support
expected_behavior Answer, clarify, or abstain
locale Language and code-switching characteristics
risk Consequence if the answer is wrong
label_provenance Reviewer, source version, and date

A reference answer can help with correctness checks, but it encodes one phrasing and may penalize a valid alternative. Expected facts and source spans often make reviews more flexible. Preserve the source version too: if policy P-17 changes, an old expected answer must not silently be judged against the new policy.

Cover failures, not only common questions

A useful starter set contains ordinary answerable queries, exact identifiers, multi-part questions, questions whose evidence is spread across documents, ambiguous wording, missing evidence, conflicting versions, multilingual or mixed-language queries, and access-restricted requests. Include cases where the correct system should not answer. If every row is answerable and neatly phrased, the test set rewards confident completion rather than safe behavior.

Keep cases small enough that a reviewer can inspect the source and label. A dozen cases may expose an obvious regression, but cannot support a strong claim about population-level quality. Forty to eighty carefully chosen cases can form a practical smoke suite for a narrow workflow; they still do not prove performance for every department, language, or user group. Report composition and uncertainty instead of presenting a mean as universal truth.

flowchart TD
  A["Representative questions"] --> B["Retrieve candidate passages"]
  B --> C["Check coverage and ranking"]
  C --> D["Generate or abstain"]
  D --> E["Review claims and behavior"]
  F["Versioned labels"] --> C
  F --> E
  E --> G["Compare by slice"]

The upper path follows a question through retrieval and generation. Versioned labels supply evidence for retrieval and answer checks. The last step compares meaningful slices rather than hiding everything in one number.

Worked example: a policy answer

Suppose an internal handbook says, “Expense claims must be submitted within 30 calendar days of purchase.” The question is, “How long do I have to submit a receipt?” Expected facts are the 30-day period and that the clock starts at purchase. The relevant source is the exact handbook section and its version. A good answer says “within 30 calendar days after purchase” and cites that section.

Now test retrieval separately. If the system returns a travel reimbursement page saying 60 days, retrieval is the immediate failure. If the correct 30-day passage is present but the answer says 60, generation or evidence selection is more likely. If the current handbook was updated to 45 days but the index serves an old version, source-version metadata exposes stale ingestion rather than attributing everything to the model. This single case can be reviewed by checking the source, retrieved passages, and final answer in order.

Measure each layer with suitable evidence

For retrieval, measure whether relevant passages appear in the top k and whether useful passages outrank distractors. Recall at k asks whether required evidence was retrieved; reciprocal rank emphasizes the position of the first useful result; precision-oriented measures show how much irrelevant context is included. These measures require relevance labels at passage or document level. A query-level “good answer” label cannot identify which passage was missed.

For generation, separate faithfulness, correctness, and completeness. Faithfulness asks whether response claims are supported by retrieved context. Correctness asks whether they match the authoritative answer or source. Completeness asks whether required facts were omitted. An answer can be faithful to an outdated passage and still be wrong today. It can be factually correct from prior knowledge while failing to ground itself in the supplied evidence. Record these dimensions separately.

For behavior, score abstention, clarification, and permission boundaries. Refusing an unanswerable question is not a failure simply because the system did not produce a reference answer. Conversely, a fluent answer to a restricted request may be severe. Define expected behavior before seeing outputs; review a refusal against its reason.

Automated judges can reduce review effort, but their scores remain estimates. RAGAS introduced reference-free metrics for some dimensions. ARES trains lightweight judges and uses a small set of human annotations for prediction-powered calibration. Neither makes subjective labels objective. Compare judges against human judgments on a representative subset, inspect disagreements, and retain human review for high-risk cases. Avoid using the same model family as both the system and the sole judge without checking correlated errors.

Worked example: missing evidence should not become a guess

Consider “Which database engine does the finance team use?” The approved knowledge set contains no answer. Label the case unsupported, set expected behavior to abstain, and list plausible forbidden claims if the system is likely to guess. Then run it through the pipeline.

“I cannot find this in the approved sources” is acceptable. “They use PostgreSQL” is unsupported even if it happens to be true in the world, because the indexed evidence did not support it. If the system retrieves an unrelated migration guide and confidently infers PostgreSQL, that points to retrieval and grounding defects. This case tests whether the system recognizes insufficient evidence, not whether it guesses a common technology.

Add variants: one where a source exists but is below the retrieval cutoff; one where two documents conflict; and one where the user lacks permission. They should not share a label. The first tests retrieval recall, the second tests conflict handling, and the third tests authorization. A broad “wrong answer” label would blur three engineering problems.

Prevent leakage and keep comparisons fair

Separate development examples from a held-out evaluation set. Engineers naturally tune prompts, chunk sizes, and filters after inspecting failures. Once a team repeatedly optimizes against a set, it has become development data. Keep an untouched set for release decisions, rotate in reviewed examples, and record when each case was exposed.

Deduplicate near-identical questions and documents across splits. Watch for leakage through generated paraphrases, shared source passages, answer templates, or temporal overlap. A test set drawn from only one document family may overstate quality on that family and say little about another. Stratify by language, source type, task, answerability, and risk; report counts per slice. A small slice can reveal a failure, but its percentage is noisy.

Version the full evaluation contract: corpus snapshot, index configuration, embedding model, reranker, prompt, generation model, judge version, and code revision. When any changes, record it alongside results. Otherwise, the score difference cannot be attributed to the change under test.

Make evaluation part of engineering

A useful evaluation is not a dashboard number; it is a path from an observed failure to a specific system change. Store retrieved passage IDs and ranks, the final answer, citations, judge outputs, human labels, and configuration versions. For a disagreement, inspect the trace: was the source absent, retrieved below the cutoff, omitted during context assembly, or ignored during generation?

Use deterministic checks for properties that do not need a language judge: whether a cited URL is among retrieved sources, whether required fields exist, whether an answer includes a forbidden identifier, and whether a restricted document crossed a tenant boundary. Use human review or calibrated judges for semantic properties. This keeps cheaper checks precise and reserves subjective judgment for questions that need it.

A practical release rule could require no critical access-control regression, no rise in unsupported answers in a high-risk slice, and review of any substantial drop in retrieval or completeness. Set thresholds from product risk and baseline variation; there is no universal pass mark. If the dataset is too small to detect a change reliably, say so and gather more representative cases.

Treat the dataset as a maintained product asset. Assign an owner, accept corrections, preserve label provenance, and retire cases when their policy or workflow disappears. Add production examples only after removing private data and reviewing permission. The goal is not to collect every question; it is to maintain a compact, inspectable set that catches important regressions and makes trade-offs visible before release.

Primary references

YOUR TAKE

What did you think?

Choose one reaction for this article.

Was this useful?

A cookie helps limit repeat responses. Your feedback is private.

Share this noteLinkedIn ↗X ↗Email ↗

Keep exploring.