Quick revision
The short answer
Before each release I would run the RAG feature against a labelled dataset of real questions, each with the sources that should be retrieved and the key facts the answer must contain, and measure retrieval quality separately from answer quality. Answer checks combine deterministic checks with LLM-as-judge evaluators, such as Spring AI's RelevancyEvaluator and FactCheckingEvaluator, whose verdicts are calibrated against human review. Results are tracked over time and a regression beyond an agreed margin blocks the release, while user feedback from production keeps adding new cases to the dataset.
What to remember
In this answer, we built a labelled dataset of real questions with expected sources and key facts, measured retrieval with recall at k and mean reciprocal rank separately from answer quality, and checked answers with deterministic checks plus judge models such as Spring AI's RelevancyEvaluator and FactCheckingEvaluator, calibrated against human review. Results were stored with all versions, regressions beyond a margin larger than the noise blocked the release, and production feedback added new cases to the dataset every week.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Before each release I would run the RAG feature against a labelled dataset of real questions, each with the sources that should be retrieved and the key facts the answer must contain, and measure retrieval quality separately from answer quality. Answer checks combine deterministic checks with LLM-as-judge evaluators, such as Spring AI's RelevancyEvaluator and FactCheckingEvaluator, whose verdicts are calibrated against human review. Results are tracked over time and a regression beyond an agreed margin blocks the release, while user feedback from production keeps adding new cases to the dataset.
Why this question is asked
A RAG feature can get worse without a single line of Java changing: a new chunking setting, a model update, a prompt tweak or a batch of new documents can all shift the answers. Without an evaluation process, the team finds out from users. Interviewers ask this design question to see whether we can turn answer quality into numbers that a release decision can rely on. In this answer, we will build the dataset, measure retrieval, measure answers with both simple checks and model judges, calibrate the judges, wire the evaluation into the release, and close the loop with production feedback.
1Building the Labelled Dataset
Everything starts with a dataset of questions that represent real use. For a support assistant, we take 200 to 500 questions from real tickets and search logs, anonymised, covering the common topics and the known hard cases: questions with exact error codes, questions whose answer spans two documents, questions about recently changed policies, and questions the documents cannot answer, where the right response is not found.
Each question is labelled by someone who knows the domain with three things: the documents or chunks that should be retrieved, the key facts a correct answer must contain, such as 25 days or request in the HR portal, and whether the question is answerable. Labelling takes real effort, perhaps a few minutes per question, which is why we start with a few hundred and grow it. The dataset is versioned alongside the code.
2Measuring Retrieval Separately
If the right chunk never reaches the prompt, no model can answer well, and if it does reach it, a bad answer is the model's or prompt's fault. Measuring the two separately tells us where to look. For retrieval, we run each question through the search exactly as production does, with filters and reranking, and compare the returned chunks with the expected sources.
Two simple metrics cover most needs. Recall at k is the share of questions for which at least one expected source appears in the top k results, for example recall at 5 of 0.91. Mean reciprocal rank rewards putting the right chunk near the top. These metrics need no model and run in minutes, so we run them on every change to chunking, embeddings, filters or retrieval code.
3Measuring Answer Quality
For answers, deterministic checks come first, because they are cheap and exact: does every key fact appear, are citations present and do they point to retrieved chunks, does an unanswerable question produce not found, is the length within limits. They catch many regressions on their own.
Some qualities need judgement: is the answer relevant to the question, and is every statement supported by the retrieved context rather than invented. For those we use a second model as a judge, called LLM-as-judge. Spring AI includes evaluators for this. RelevancyEvaluator asks a judge model whether the answer is relevant to the question given the context, and FactCheckingEvaluator checks whether a claim is supported by the provided documents. Each returns an EvaluationResponse with a pass flag. Constructors and options have changed between versions, so check yours.
4Using Model Judges Carefully
A judge model is another model, with its own errors. It can be lenient with fluent answers, prefer longer ones, or miss a subtle wrong number. So before we trust a judge's verdicts in a release gate, we calibrate it: two or three people review 100 answers by hand, and we compare their verdicts with the judge's. If the judge agrees with humans in, say, 90 percent of cases, its scores are useful as a trend; if it agrees in 70 percent, we fix the judge prompt or rely more on deterministic checks. We repeat the calibration when the judge model changes, use a judge that is at least as capable as the model being judged, and keep a human review of a small sample in every release.
5Tracking Results and Blocking Regressions
Every evaluation run stores its results with the versions of everything that can change quality: dataset, prompt, chat model, embedding model, chunking settings and code commit. A dashboard shows each metric over time, so a slow decline is as visible as a sudden drop. The release pipeline runs the full evaluation on the release candidate and compares it with the current production version. If a key metric drops beyond an agreed margin, for example recall at 5 down more than 2 points or grounded answers down more than 3 points, the release is blocked until someone investigates. Because model outputs vary, the margin must be larger than the run-to-run noise we measured by running the same version several times.
- Labelled dataset, versioned300 questions, sources, key facts
- Run retrieval metricsrecall at 5, mean reciprocal rank
- Run answer checkskey facts, citations, not found, judges
- Compare with production versionsame dataset, same judges
- Drop beyond margin?YesBlock release, investigateNoRelease
- Production feedbackthumbs down and escalations become new cases
6 steps in order. Play them, or step through them one at a time.
6Feeding Production Back Into the Dataset
The dataset only knows the questions we thought of. In production, we collect thumbs up and down on answers, escalations to a human agent after an answer, and questions that returned not found. Each week someone reviews a sample, labels the useful cases and adds them to the dataset, especially failures. Over a few months, the dataset shifts from what we imagined users would ask to what they actually ask, and the evaluation becomes a much better predictor of real quality.
7Follow-up questions
How large does the dataset need to be?
Large enough that a real regression shows up above the noise. With 300 questions, a drop from 90 to 85 percent is 15 questions and clearly visible; with 30 questions, it is a single question and could be chance. Start with what the team can label well, often 100 to 200, and grow it from production.
Can the judge model be the same as the answering model?
It can, but it tends to agree with its own style of answer and share its blind spots. A different, at least equally capable model is a better judge, and calibrating against human review matters either way.
How long should the evaluation take?
Retrieval metrics for a few hundred questions take minutes and can run on every change. The full answer evaluation with judges may take 20 to 30 minutes and cost a few dollars, which is fine before a release or nightly, but not on every commit.
8Conclusion
In this answer, we built a labelled dataset of real questions with expected sources and key facts, measured retrieval with recall at k and mean reciprocal rank separately from answer quality, and checked answers with deterministic checks plus judge models such as Spring AI's RelevancyEvaluator and FactCheckingEvaluator, calibrated against human review. Results were stored with all versions, regressions beyond a margin larger than the noise blocked the release, and production feedback added new cases to the dataset every week.
Open with
I would start with a labelled dataset of a few hundred real questions, anonymised, each with the sources that should be retrieved, the key facts a correct answer contains, and whether it is answerable at all, so we also test not-found behaviour.
Then, if they want more
Then I measure retrieval on its own, recall at five and mean reciprocal rank, because if the right chunk never reaches the prompt it is a retrieval problem, not a model problem, and those metrics are cheap enough to run on every change.
For answers, I run deterministic checks first, key facts present, citations pointing at retrieved chunks, not found for unanswerable questions, and then LLM-as-judge checks for relevance and groundedness, for example Spring AI's RelevancyEvaluator and FactCheckingEvaluator.
I would not trust the judge blindly: we calibrate it against human review of about a hundred answers and keep a small human sample in each release.
Every run is stored with the dataset, prompt, model, embedding and chunking versions, results are tracked over time, and the release pipeline blocks a release if a key metric drops by more than an agreed margin, which must be bigger than the run-to-run noise.
Finally, thumbs-down answers, escalations and not-found questions from production are reviewed weekly and added to the dataset.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring AI reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Design an evaluation process for a RAG feature before each release, including what you...": https://scrivio-interview-library.netlify.app/spring-boot/spring-ai/2ce867ebf9/