CertSafari
    Databricks Certified Generative AI Engineer Associate· Lessons

    Domain 2 · Lesson 12/56

    Retrieval evaluation metrics and tools: recall@k, DCG@10 and retrieval judges

    Use tools and metrics to evaluate retrieval performance

    18 min read
    1.75% of exam
    7 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Assemble a retrieval evaluation set from labeled pairs, synthetic queries or ground-truth-free judges, and size and split it correctly
    • Choose between recall@k and precision@k from the cost of a missed document versus an irrelevant one
    • Explain how graded 0–3 relevance feeds DCG@10, NDCG, MRR and MAP, and why DCG@10 is the recommended primary metric
    • Run AI Search's built-in retrieval evaluation and turn its dashboard patterns into configuration decisions
    • Pick the MLflow retrieval judges that fit the ground truth you have

    Key concept

    Query–document relevance judgment — Every retrieval metric is computed from one basic fact: how relevant a retrieved document is to the query that fetched it. That label comes either from human ground truth or from an LLM judge. Precision, recall, DCG and the rest are different ways of adding those labels up.

    1.Why retrieval gets its own measurement

    A RAG answer can go wrong in two places, and a score on the final answer alone cannot tell you which. The retriever may have fetched the right chunks and the LLM still answered badly. Or the retriever may have missed, and the LLM still produced a plausible answer from what it already knew. Retrieval quality metrics check one thing: did the retriever return relevant supporting data? Response metrics such as correctness and groundedness judge the answer, and cost and latency metrics judge the system.

    In the AI Search retrieval quality guide, measurement comes before any tuning. Before you try hybrid search, metadata filters or a reranker, you need a reproducible way to score retrieval. Without one you cannot tell whether a change helped. The same guide asks you to fix a latency target first, such as under 2 seconds to first token for a RAG agent or under 100 ms for a search bar. A configuration that scores higher but misses that budget is not a candidate.

    Checkpoint 1 of 9· Check yourself

    A team evaluates its RAG app only with a correctness judge on the final answers. After a change, the scores improve. What can the team conclude about the retriever?

    Sources12

    2.Building a retrieval evaluation set

    A retrieval evaluation set pairs each query with the documents that should come back for it. Databricks recommends a human-labeled set of representative queries with ground-truth answers and, optionally, the supporting documents that should be retrieved. Those expected documents are what make recall measurable. Without them you can tell whether what came back is relevant, but not what was missed.

    If you have no labels yet, don't wait for subject matter experts. You have three starting points, and any automated measurement beats none:

    • Existing golden dataset: labeled query-answer pairs you already own.
    • Synthetic evaluation set: test cases generated automatically from your own documents.
    • Ground-truth-free evaluation: LLM judges that assess quality without labels.

    When the set is imperfect, compare strategies against each other instead of trusting absolute scores. Even a small synthetic set can show whether reranking or hybrid search helps on your data.

    Size and maintenance matter as well. Databricks recommends at least 30 questions, ideally 100–200, and the best sets eventually grow into the thousands. A good set is representative of production traffic and includes hard and adversarial cases. Update it as usage, the indexed data and the requirements change. To avoid overfitting your retrieval configuration to one set of queries, split it into about 70% training, used to screen every experiment; 20% test, for the strongest candidates; and 10% validation, as a final check before production. Store the set as a Delta table. When you evaluate with MLflow, it logs a snapshot of the version you used.

    Split of an evaluation set to avoid overfitting
    SplitShareUsed for
    Training set~70%Initial pass over every experiment to find promising ones
    Test set~20%Evaluating the highest-performing experiments
    Validation set~10%Final check before deploying to production

    Checkpoint 2 of 9· Match them up

    You split your retrieval evaluation set so that tuning doesn't overfit to one set of queries. Match each split to its job in the experiment workflow.

    Tap a term, then the definition that fits it.

    Sources324

    3.Precision@k and recall@k: completeness against a clean top

    Precision@k asks: of the k results I returned, what fraction are relevant? Recall@k asks: of all the documents known to be relevant, what fraction appear in the top k? Suppose a retriever returns three chunks, two of them relevant, and four relevant documents exist. Precision is 2/3, about 0.66, and recall is 2/4 = 0.5. Precision can be computed without knowing every relevant item. Recall cannot, because its denominator is the full list of relevant documents in your ground truth. In AI Search's evaluation, a result counts as relevant for precision@k when its judged score is 2 or higher.

    Choose the metric by asking which failure hurts more. Choose recall@k when a missed document breaks the outcome. In a RAG agent, a missing piece of context leads to an incomplete answer or a hallucination. The same holds for clinical trial matching and compliance search. These are typically tracked at generous cutoffs such as recall@10 or recall@50. Choose precision@k when only the first few results are read and an irrelevant one costs trust or space. Examples are entity matching, part matching, and a support knowledge base where engineers need the exact fix at the top. These are tracked at small cutoffs such as precision@3. Precision also matters when the LLM's context window is tight: every irrelevant chunk you pass takes a slot that a useful chunk could have used. Due-diligence and prior-art search need both.

    Choosing between recall@k and precision@k
    AspectRecall@kPrecision@k
    QuestionWhat % of known relevant docs appear in the top k?What % of the top k are relevant?
    Needs full list of relevant docs?YesNo
    Wins whenMissing a document means a wrong or incomplete answerOnly the top few results are read or fit in context
    Typical cutoffrecall@10, recall@50precision@3, precision@10
    Example use caseRAG agents, clinical trial matchingTech support knowledge base, entity resolution

    Checkpoint 3 of 9· Check yourself

    Support engineers use an internal knowledge base and usually read only the first three articles returned before giving up. The current retriever scores 0.95 on recall@50. Which metric should go on the dashboard to track what these engineers actually experience?

    Sources152

    4.Graded relevance and rank-aware metrics

    Yes/no relevance hides the difference that matters most. AI Search's judge uses four grades:

    • 3, Highly relevant: directly answers the query.
    • 2, Relevant: useful but possibly incomplete.
    • 1, Partially relevant: mentions the topic without useful information.
    • 0, Not relevant: unrelated, or written in a different language from the query.

    A binary metric counts a perfect answer and a passing mention the same. Graded scores keep them apart, and metrics that use the grades reward the better document.

    DCG@10 (discounted cumulative gain over the top 10) uses both the grade and the position. Each result contributes a gain of 2^relevance − 1, so a 3 is worth 7 and a 1 is worth 1. That gain is then divided by a logarithmic discount based on rank. Position 1 counts in full, while position 10 is divided by log₂(11) ≈ 3.46. The theoretical maximum at k=10 is 31.80, reached when every result scores 3. If all ten results score 2, DCG@10 is 13.63. At that level, a 1-point gain is about a 7% relative improvement, roughly one result getting noticeably better.

    NDCG divides DCG by the ideal DCG, which is the DCG of the same results sorted best-first. The result runs from 0 to 1 and measures ordering only. That is why both sets above score 1.00 even though B gives the user nearly twice as much. DCG answers a different question: how much useful information did the user actually get? For that reason, Databricks recommends DCG@10 as the primary metric for overall retrieval quality. Use NDCG when you want to check ranking independently of how many relevant documents exist.

    The other rank-aware metrics each answer one narrower question. MRR averages 1/rank of the first relevant result (score ≥ 2). If the first good hit is usually at rank 2, MRR is near 0.5. MRR fits question-answering, where the top result is what matters. MAP computes precision at the position of each relevant result and averages them, so it summarizes how consistently all relevant documents rank near the top. Average relevance (0–3) gives a quick snapshot. The relevance distribution shows the percentage of results that are Highly Relevant, Relevant+ and Not Relevant. Look at the distribution because two strategies can have the same average: a mix of many 3s and many 0s suggests some query pattern is not being retrieved at all.

    Rank-aware and graded metrics at a glance
    MetricRangeUse it when
    DCG@100 to 31.80Default headline for overall retrieval quality
    NDCG0 to 1Checking order independent of how many relevant docs exist
    MRR0 to 1The first relevant result matters most, as in question-answering systems
    MAP0 to 1One number for ranking quality across all relevant docs
    Average relevance0 to 3Quick quality snapshot
    Relevance distribution% per bucketSpotting bimodal quality hidden by an average

    Checkpoint 4 of 9· Match them up

    Your retrieval dashboard can show several graded, rank-aware metrics. Match each metric to the question it is best suited to answer.

    Tap a term, then the definition that fits it.

    Checkpoint 5 of 9· Exam question

    According to Databricks AI Search retrieval quality guidance, which metric is recommended as the primary metric for evaluating overall retrieval quality?

    Checkpoint 6 of 9· Exam question

    A technical support search tool must return the single correct troubleshooting article at the very top of the results, since agents only read the first couple of results before acting. Which metric best evaluates this requirement?

    Sources5

    5.Running AI Search's built-in retrieval evaluation

    AI Search (Beta) includes a built-in retrieval evaluation that needs no labeled data. It works on a managed Delta Sync index. You click Evaluate search quality on the index page, and defaults are pre-filled from the index metadata. Anyone with query access to the index can start a run and view the results, because both inherit the index's Unity Catalog permissions. The person who starts the run owns the job, even if they don't own the index.

    Each run is a four-stage pipeline:

    1. Generate queries: sample documents from the source table and have an LLM write realistic natural-language and keyword queries.
    2. Search across strategies: run every query with ANN, hybrid and full-text retrieval, each with and without the reranker.
    3. Score relevance: an LLM judge grades every query–document pair on the 0–3 scale.
    4. Compute metrics: calculate the metrics with 95% confidence intervals and save them for later comparison.

    Synthetic queries plus a graded judge are what remove the need for human labels. Every strategy also runs on the same query set, so the comparison between them is fair.

    Select a finished run from the Select Run drop-down on the results dashboard. The top shows three indicators: the best DCG@10, the query type that achieved it, and the number of queries evaluated. Below them, a bar chart and two tables compare DCG@10 and average relevance for each query type, with and without the reranker. A line chart shows how relevance falls off by result position. The dashboard also lists the best and worst queries and the failed queries, meaning queries whose top-1 result scored 0. At the bottom, a metric-over-time chart tracks a selected metric across runs.

    Turning dashboard patterns into decisions
    PatternWhat it meansAction
    Hybrid significantly better than ANNQueries benefit from keyword matchingUse hybrid search in production
    ANN approximately equal to hybridKeywords add no value for your dataEither works; ANN is simpler
    Full-text significantly better than ANNEmbeddings may not capture your domainConsider fine-tuning the embedding model or using full-text
    Reranker improves metrics significantlyCross-encoder gives a real quality liftEnable reranker if latency budget allows
    Wide confidence intervalsToo few queries for a reliable comparisonIncrease the number of evaluation queries
    All strategies score lowData quality or relevance issuesWork through the retrieval quality guide

    Check the confidence intervals before you act on a gap between strategies. If hybrid beats ANN by half a point and the intervals overlap heavily, the run has not shown that hybrid is better. Add queries and run the evaluation again. How the reranker produces its lift is covered in re-ranking in retrieval.

    Checkpoint 7 of 9· Check yourself

    Your first built-in evaluation run on a managed Delta Sync index shows hybrid at DCG@10 14.1 and ANN at 13.6. The 95% confidence intervals are wide and overlap heavily. What should you do next?

    Checkpoint 8 of 9· Exam question

    A team wants to evaluate their Vector Search retriever's quality but has no labeled query-document pairs and no time to have subject matter experts label a test set. What approach lets them measure retrieval performance without existing ground truth?

    Sources5

    6.MLflow judges for retrieval in traces

    AI Search's evaluation scores the index on its own. MLflow's built-in judges score retrieval inside your running application. A scorer receives a trace from mlflow.genai.evaluate() or from the monitoring service. It parses the trace to pull out the fields it needs, such as the retrieved context, then attaches its verdict to the trace as Feedback. Because the same scorer works in development and in production monitoring, a retrieval check you build during evaluation can keep running after deployment. Tracing itself is covered in MLflow scoring and tracing.

    Three built-in judges deal with retrieved context, and they differ in what they need. RetrievalRelevance asks whether the retrieved context is relevant to the request. It needs only inputs and outputs, so you can run it on unlabeled traffic. RetrievalSufficiency asks whether the context contains everything needed to produce the expected facts. It needs expectations, which is ground truth. RetrievalGroundedness asks whether the response sticks to the retrieved context or hallucinates. It needs no ground truth, and it judges the generator's use of retrieval rather than the retriever. Agent Evaluation's retrieval metrics follow the same split. chunk_relevance/precision is judged by an LLM without labels, context_sufficiency is judged by an LLM with labels, and document_recall is deterministic and needs the ground-truth documents. For the full list of judges that need ground truth, see judges that require ground truth.

    Retrieval-focused MLflow judges
    JudgeArgumentsRequires ground truthWhat it evaluates
    RetrievalRelevanceinputs, outputsNoIs the retrieved context relevant to the request?
    RetrievalSufficiencyinputs, outputs, expectationsYesDoes the context hold all information needed for the ground-truth facts?
    RetrievalGroundednessinputs, outputsNoIs the response grounded in the context, or hallucinated?

    Checkpoint 9 of 9· Check yourself

    After deployment, you reuse your MLflow retrieval scorers to monitor production traces. These traces carry inputs and outputs but no ground-truth expectations. Which built-in judge can't produce a verdict on them?

    Sources671

    Sources

    (7)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “A RAG application can respond poorly despite retrieving the correct context; it can also provide good responses based on faulty retrievals.”
      ↩︎ Why retrieval gets its own measurement
      “a subset of the retrieval metrics can also be computed deterministically”
      ↩︎ Why retrieval gets its own measurement
      “Computing recall requires your ground-truth to contain all relevant items.”
      ↩︎ Precision@k and recall@k: completeness against a clean top
      “What % of the ground truth documents are represented in the retrieved chunks?”
      ↩︎ MLflow judges for retrieval in traces
    2. 2.
      “If you don't have evaluation in place, stop here and set it up first. Optimizing without measurement is guesswork.”
      ↩︎ Why retrieval gets its own measurement
      “Ground-truth free evaluation: Use Databricks Agent Evaluation judges to assess quality without labels.”
      ↩︎ Building a retrieval evaluation set
      “RAG agents: Missing key context leads to incorrect answers or hallucinations.”
      ↩︎ Precision@k and recall@k: completeness against a clean top
      “Tech support knowledge base: Engineers need the exact solution in top results.”
      ↩︎ Exam trap 3
      “Synthetic evaluation set: Use Databricks synthetic data generation to auto-generate test cases from your documents.”
      ↩︎ Exam trap 4
      “Tech support knowledge base: Engineers need the exact solution in top results.”
      ↩︎ Checkpoint
    3. 3.
      “Databricks recommends at least 30 questions in your evaluation set, and ideally 100 - 200.”
      ↩︎ Building a retrieval evaluation set
      “Training set: ~70% of the questions. Used for an initial pass to evaluate every experiment to identify the highest potential ones.”
      ↩︎ Checkpoint
    4. 5.
      “The fraction of top-k results that are relevant (relevance score >= 2).”
      ↩︎ Precision@k and recall@k: completeness against a clean top
      “Databricks recommends using DCG@10 as the primary metric for evaluating overall retrieval quality.”
      ↩︎ Graded relevance and rank-aware metrics
      “a score-3 result contributes 7, while a score-1 result contributes 1.”
      ↩︎ Graded relevance and rank-aware metrics
      “MRR is the average of 1/rank across queries, where rank is the position of the first relevant result (score >= 2).”
      ↩︎ Graded relevance and rank-aware metrics
      “The system samples documents from your source table and uses an LLM to generate realistic search queries.”
      ↩︎ Running AI Search's built-in retrieval evaluation
      “An LLM judge evaluates every query and retrieved document pair on a 4-point relevance scale.”
      ↩︎ Running AI Search's built-in retrieval evaluation
      “The user who starts the evaluation run is the owner of the job, not the owner of the index.”
      ↩︎ Running AI Search's built-in retrieval evaluation
      “All metrics include 95% confidence intervals computed across per-query values”
      ↩︎ Running AI Search's built-in retrieval evaluation
      “An LLM judge evaluates every query and retrieved document pair on a 4-point relevance scale.”
      ↩︎ Key concept
      “DCG@10 captures both how relevant results are and where they appear in the ranking, using the full 0–3 relevance scale.”
      ↩︎ Exam trap 1
      “Databricks recommends using DCG@10 as the primary metric for evaluating overall retrieval quality.”
      ↩︎ Exam trap 2
      “Result Set B delivers nearly twice the total value (DCG 8.02 vs 4.26) because every result is useful.”
      ↩︎ Prediction
      “Wide confidence intervals | Not enough queries for reliable comparison. | Increase the number of evaluation queries.”
      ↩︎ Checkpoint
    5. 6.
      “Parses the trace to extract specific fields and data that are used to assess quality”
      ↩︎ MLflow judges for retrieval in traces
      “You can use the same scorer for evaluation in development and monitoring in production”
      ↩︎ MLflow judges for retrieval in traces
    6. 7.
      “Is the retrieved context directly relevant to the user's request?”
      ↩︎ MLflow judges for retrieval in traces
      “Does the context provide all necessary information to generate a response that includes the ground truth facts?”
      ↩︎ Exam trap 5
      “RetrievalSufficiency | inputs, outputs, expectations | Yes | Does the context provide all necessary information to generate a response that includes the ground truth facts?”
      ↩︎ Checkpoint

    Ready to test yourself?

    Practise the 6 questions on this subdomain.

    Spotted a mistake, or was something unclear? Tell us.