Evaluating Retrieval Quality: From Vibes to MRR

Search quality is notoriously difficult to measure because "relevance" is subjective. Without a rigorous evaluation harness, every change to a search algorithm is just a "vibe check." Industrial systems use a Gold Set of queries to produce deterministic metrics.

1. The Core Metrics

A. Recall@K

The percentage of queries for which the "ideal" document appears in the top K results.

B. Mean Reciprocal Rank (MRR)

MRR rewards the system for putting the correct answer as high as possible.

\text{MRR} = \frac{1}{|Q|} \sum_{i=1}^{|Q|} \frac{1}{\text{rank}_i}

Where \text{rank}_i is the position of the first relevant document for query i.

2. Building a "Gold Set"

A retrieval evaluation set (e.g., eval/retrieval-queries.csv) consists of triples: (query, ideal_page, category).

Quality Categories:

3. The Continuous Evaluation Loop (CI/CD)

Search evaluation should be an automated part of the build pipeline, not a manual task.

  1. Baseline: Run the evaluation set and commit the results (Recall@5, MRR).
  2. Experiment: Modify a weight or add a reranking step.
  3. Validate: Run the evaluation again. If MRR drops, the "improvement" is a regression.

External Deep Dive:

See Also: