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?
A final-answer score mixes retrieval and generation. Good answers can come from faulty retrievals, and bad answers can come from correct context. Only a separate retrieval metric shows whether the retriever returned relevant data.
“A RAG application can respond poorly despite retrieving the correct context; it can also provide good responses based on faulty retrievals.”Source: docs.databricks.com
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 | Share | Used 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.
Each split has a narrower job than the one before. The largest split screens everything, the test split compares the best candidates, and the small validation split stays unused until the final pre-deployment check. That way the configuration you ship is never judged only on the queries it was tuned on.
“Training set: ~70% of the questions. Used for an initial pass to evaluate every experiment to identify the highest potential ones.”Source: docs.databricks.com
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.
| Aspect | Recall@k | Precision@k |
|---|---|---|
| Question | What % of known relevant docs appear in the top k? | What % of the top k are relevant? |
| Needs full list of relevant docs? | Yes | No |
| Wins when | Missing a document means a wrong or incomplete answer | Only the top few results are read or fit in context |
| Typical cutoff | recall@10, recall@50 | precision@3, precision@10 |
| Example use case | RAG agents, clinical trial matching | Tech 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?
When users read only the top few results, the failure that hurts is junk at the top, so precision at a small cutoff like precision@3 is the right metric. A high recall@50 only shows that the right article appears somewhere in 50 results, which these engineers never scroll through.
“Tech support knowledge base: Engineers need the exact solution in top results.”Source: docs.databricks.com
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.
| Metric | Range | Use it when |
|---|---|---|
| DCG@10 | 0 to 31.80 | Default headline for overall retrieval quality |
| NDCG | 0 to 1 | Checking order independent of how many relevant docs exist |
| MRR | 0 to 1 | The first relevant result matters most, as in question-answering systems |
| MAP | 0 to 1 | One number for ranking quality across all relevant docs |
| Average relevance | 0 to 3 | Quick quality snapshot |
| Relevance distribution | % per bucket | Spotting 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.
DCG@10 combines the relevance grade with the rank, so Databricks recommends it as the headline metric. NDCG only checks ordering, MRR looks only at the first relevant hit, and the distribution shows a bimodal shape that a single average hides.
“Databricks recommends using DCG@10 as the primary metric for evaluating overall retrieval quality.”Source: docs.databricks.com
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?
Correct answer: A — DCG@10
- A. Discounted Cumulative Gain at rank 10 is the metric Databricks recommends as the primary measure of overall retrieval quality, since it rewards relevant documents appearing near the top of a fixed-size result window using graded relevance.
- B. Normalized DCG rescales scores to a 0-1 range to compare across queries with different numbers of relevant documents, which is useful as a supplementary metric but is not the recommended primary metric.
- C. Recall at k measures the fraction of all relevant documents retrieved and is best suited to coverage-sensitive use cases, not the general primary quality metric Databricks recommends.
- D. Mean Reciprocal Rank captures how quickly the first relevant result appears and is a supplementary metric for scenarios where only one good result matters, not the recommended primary metric.
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?
Correct answer: A — Precision@3 computed on the top three results, reporting the share of those articles that are relevant
- A. Precision at a small cutoff measures how many of the few results an agent actually reads are relevant. That is the quality of the top of the list, which is what the requirement is about.
- B. Recall at a cutoff of fifty measures how much of the relevant material shows up somewhere in a broad result window. A relevant article at position forty still counts, but agents only read the first couple of results, so it says nothing about the top.
- C. A mean relevance score over the whole candidate set mixes the top positions with many lower-ranked results that agents never read. Strong results deep in the list can offset a wrong article in first place, so it does not show whether the top result is correct.
- D. A grade histogram over fifty results shows how many articles fall into each relevance bucket but ignores their positions. It looks identical whether the best article is first or fiftieth, so it cannot confirm that the top results are right.
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:
- Generate queries: sample documents from the source table and have an LLM write realistic natural-language and keyword queries.
- Search across strategies: run every query with ANN, hybrid and full-text retrieval, each with and without the reranker.
- Score relevance: an LLM judge grades every query–document pair on the 0–3 scale.
- 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.
| Pattern | What it means | Action |
|---|---|---|
| Hybrid significantly better than ANN | Queries benefit from keyword matching | Use hybrid search in production |
| ANN approximately equal to hybrid | Keywords add no value for your data | Either works; ANN is simpler |
| Full-text significantly better than ANN | Embeddings may not capture your domain | Consider fine-tuning the embedding model or using full-text |
| Reranker improves metrics significantly | Cross-encoder gives a real quality lift | Enable reranker if latency budget allows |
| Wide confidence intervals | Too few queries for a reliable comparison | Increase the number of evaluation queries |
| All strategies score low | Data quality or relevance issues | Work 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?
Overlapping, wide confidence intervals mean the difference between strategies isn't statistically meaningful yet, so the fix is to evaluate more queries. Synthetic queries are fine for this comparison because every strategy runs on the same query set.
“Wide confidence intervals | Not enough queries for reliable comparison. | Increase the number of evaluation queries.”Source: docs.databricks.com
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?
Correct answer: A — Generate synthetic queries from the indexed documents, then have an LLM judge score each query-document pair on a 0-3 relevance scale.
- A. Databricks Agent Evaluation can build a test set without labels: it generates synthetic queries from the documents, and an LLM judge grades each query-document pair on a graded relevance scale. That yields a retrieval measure with no existing ground truth and no expert labeling time.
- B. Overlap between two retrievers shows only that they agree, not that either returns relevant documents. Two models can share the same wrong results, so the score does not measure retrieval quality and gives no ground-truth-free evidence of relevance.
- C. NDCG needs independent relevance grades to compute gain. Using the retriever's own similarity scores as those grades is circular: the ranking is scored against itself, so the metric looks near-perfect whatever the true relevance is.
- D. A public MTEB score reflects the embedding model's performance on benchmark datasets, not on this team's documents and queries. It says nothing about how well this retriever surfaces relevant content from their own corpus.
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.
| Judge | Arguments | Requires ground truth | What it evaluates |
|---|---|---|---|
| RetrievalRelevance | inputs, outputs | No | Is the retrieved context relevant to the request? |
| RetrievalSufficiency | inputs, outputs, expectations | Yes | Does the context hold all information needed for the ground-truth facts? |
| RetrievalGroundedness | inputs, outputs | No | Is the response grounded in the context, or hallucinated? |
It returns on-topic chunks, but not enough of them to cover the expected facts. This is a recall problem. Retrieving more chunks or improving coverage is more likely to help than filtering out noise.
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?
Only RetrievalSufficiency takes expectations, because it judges the context against ground-truth facts. RetrievalRelevance and RetrievalGroundedness run on inputs and outputs alone, so they still work on unlabeled production traffic.
“RetrievalSufficiency | inputs, outputs, expectations | Yes | Does the context provide all necessary information to generate a response that includes the ground truth facts?”Source: docs.databricks.com
Sources
(7)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://docs.databricks.com/aws/en/agents/tutorials/ai-cookbook/evaluate-assess-performanceOfficial docs
“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.
“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.https://docs.databricks.com/aws/en/agents/tutorials/ai-cookbook/evaluate-define-qualityOfficial docs
“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.https://docs.databricks.com/aws/en/agents/tutorials/ai-cookbook/evaluate-enable-measurementOfficial docs
“In Databricks, you can manage your evaluation set as a Delta Table.”
↩︎ Building a retrieval evaluation set - 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 - 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 - 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