📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

How do you measure retrieval quality for a search or RAG feature? Explain hit rate, recall@k, MRR and nDCG, and how you build the labelled test set.

Intermediate Theory Intermediate ai evaluation rag retrieval-evaluation vector-search xunit

🎯 Key points

  • Labelled questions with expected chunk ids, from de-identified real usage and experts (Privacy Act / APPs)
  • Hit rate and recall@k for coverage
  • MRR = mean of 1/rank of the first correct chunk
  • nDCG@k for graded relevance by position
  • xUnit harness calling the app's own IEmbeddingGenerator and vector search
  • Fail CI when recall@k drops below the baseline
  • Fix retrieval before tuning prompts

⏱ 30-second answer

Build a labelled set of 50–200 real questions, each with the chunk ids that should come back, written with domain experts from real (de-identified) usage. Then measure:

  • Hit rate / recall@k: is a correct chunk in the top k, and what share of the correct chunks did we get?
  • MRR: the average of 1 / rank of the first correct chunk.
  • nDCG@k: graded relevance, discounted by position.

In .NET this is a small xUnit test project: load the set from JSON, call the same IEmbeddingGenerator and vector store search the app uses, compute the metrics with LINQ, and fail the build if recall@5 drops below the baseline. Run it on every change to chunking, the embedding model, hybrid weights or the reranker. Retrieval comes before answer quality: if the right chunk isn't retrieved, no prompt fixes the answer.

🔍 What the interviewer is checking

Checks whether they can measure retrieval rather than guess, and wire that measurement into the build.

Green flags

  • Defines recall@k, MRR and nDCG correctly
  • Builds the labelled set with experts and keeps personal data out of it
  • Runs the metrics in CI against the production retrieval code

Red flags

  • Only judges the final answer, never the retrieval
  • Tunes prompts to cover for missing chunks

↩ Usually asked after

More in .NET and AI

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me