Retrieval-augmented generation (RAG) systems can produce fluent, confident answers while the retrieval layer underneath them quietly fails. Google Cloud’s guidance on RAG evaluation warns that systems without thorough evaluation develop “silent failures” that undermine reliability and trust, and that RAG is easy to describe but difficult to implement well. Pinecone puts the dependency bluntly: a RAG pipeline is only as performant as its retrieval phase is accurate. This guide explains how to evaluate that retrieval phase directly using recall, precision, and rank-aware metrics, how to build a test set that makes the numbers meaningful, and which failure cases to look for when the scores drop.
It is written for practitioners who already have a working RAG pipeline — local or hosted — and want to know whether it retrieves the right material before they tune prompts or swap models.
Why answer quality hides retrieval problems
Most teams start by reading generated answers and judging them. That is useful, but it is not a retrieval measurement. A large language model can produce a plausible answer from its own parametric knowledge, from a partially relevant chunk, or from a single lucky passage. The final answer can look acceptable even when the retriever returned nothing useful, which is exactly the silent-failure pattern Google Cloud describes.
The fix is to separate the pipeline into stages and measure them separately. Retrieval evaluation asks a narrow question: for a given query, did the system return the documents that a knowledgeable human would consider relevant, and did it rank them near the top? Generation evaluation asks a different question: given the retrieved context, was the answer faithful and complete? Conflating the two makes debugging nearly impossible, because a bad answer could originate in either stage.
The core metrics: recall and precision
Recall and precision are the foundation. Both are computed against a labeled set of queries where you already know which chunks or documents are relevant.
As an illustrative example, imagine a query where 10 chunks in the index are genuinely relevant. The retriever returns the top 5, and 3 of those are relevant.
- Recall@5 = relevant chunks retrieved / all relevant chunks in the corpus = 3 / 10 = 0.30. It answers: how much of what exists did we find?
- Precision@5 = relevant chunks retrieved / chunks retrieved = 3 / 5 = 0.60. It answers: how much of what we returned is actually useful?
These definitions follow standard information-retrieval practice; the numbers above are a worked illustration, not a benchmark result.
Recall: did the retriever find what exists?
Recall is the metric that matters when a missing document makes the answer wrong or incomplete. Support documentation, compliance material, and technical reference content are typical cases: if the one passage that answers the question is not in the context window, the generator cannot use it.
Low recall usually points at one of a few causes: the content is not in the index at all; chunking split the answer across boundaries so no single chunk is fully relevant; the embedding model represents the query and the document in poorly aligned ways; top-k is too small; or a metadata filter excluded the right document.
Precision: how much noise did the retriever bring?
Precision matters because the context window is a finite, expensive resource. Irrelevant chunks dilute the signal, can distract the generator, and increase latency and token cost. Low precision commonly comes from top-k set too high, weak or mismatched embeddings, near-duplicate chunks that crowd out diverse results, or queries too broad to have a precise answer.
Recall and precision trade off against each other. Increasing top-k tends to raise recall and lower precision. The right balance depends on whether your application is harmed more by a missing fact or by a noisy context.
Rank-aware and graded metrics
Recall and precision at a fixed k treat every retrieved item equally. Rank-aware metrics add position. Mean reciprocal rank (MRR) rewards putting the first relevant result high in the list. Normalized discounted cumulative gain (nDCG) rewards relevant results appearing near the top and can account for different degrees of relevance.
Pinecone’s RAG evaluation overview distinguishes binary relevance metrics, where an item is either relevant or not, from graded relevance metrics, where items receive different relevance levels. If your domain has shades of usefulness — a canonical answer versus a tangentially related passage — graded labels and nDCG will describe your system better than a binary hit rate.
Build a test set before you tune anything
Metrics are only as meaningful as the questions and labels behind them. Google Cloud’s first recommended step is to create a testing framework, and the prerequisites it names are a test dataset of high-quality questions and a “golden” reference dataset of desired outputs.
For the question set, the same guidance recommends covering a broad subset of the underlying data and including variations in phrasing and question complexity that match real-world use cases, ideally with input from stakeholders and end users. In practice that means:
- Write questions the way users actually ask them, including typos, jargon, and multi-part questions.
- Spread questions across the corpus rather than concentrating on the documents you know best.
- Label the relevant chunk or document IDs for each question, not just a reference answer.
- Include unanswerable questions, so you can measure whether the system returns noise instead of nothing.
- Hold back a portion of the set from tuning, so you can detect overfitting.
Google Cloud notes that some metrics can be calculated without a reference dataset, but that having known-good outputs allows a more comprehensive and nuanced range of evaluation. Recall and precision specifically require relevance labels, because they are defined relative to what should have been retrieved.
A reproducible evaluation loop
Evaluation only helps if it is rigorous, automated, and repeatable — the criteria Google Cloud sets out for a testing framework. A workable loop looks like this:
- Freeze a snapshot of the corpus and record the index version, embedding model, chunk size, and retrieval configuration.
- Run retrieval only, without generation, and log the returned chunk IDs and scores for every query in the test set.
- Compute recall@k, precision@k, and one rank-aware metric such as MRR or nDCG.
- Inspect the failures individually and sort them into categories: not indexed, poorly chunked, misranked, filtered out, or genuinely ambiguous query.
- Change one variable at a time — chunk size, embedding model, top-k, reranker, filter logic — and re-run the same set.
- Keep a dated results log so you can tell whether a change helped or merely moved the error around.
- Promote previously failing queries into a regression set so the same defect cannot return unnoticed.
Reporting the configuration alongside the score is what makes the number interpretable. A recall@5 of 0.8 means little without knowing the corpus snapshot, the embedding model, and the chunking strategy that produced it.
Failure cases to look for
Silent failures. The system returns an answer with no error, but the retrieved context was empty or wrong. Google Cloud identifies these as the core risk of unevaluated RAG, because nothing in the user interface signals that retrieval failed.
Retrieval misses (recall failure). The relevant passage exists in the corpus but never appears in the top-k. Check whether it was indexed at all before assuming the embedding model is at fault.
Context dilution (precision failure). The right passage is present, but buried under irrelevant chunks. The generator may still answer correctly, which masks the problem until a harder query arrives.
Ranking failure. The relevant chunk is retrieved but sits below the cutoff. This can be invisible in a recall@k number when k is large, and obvious in MRR or nDCG.
Vocabulary mismatch. The user’s phrasing and the document’s phrasing share little surface overlap, and the embedding model does not bridge the gap. This is a common reason a system works on internal test questions written by the team and fails on real user queries.
Chunking failure. The answer spans a boundary, so each chunk is only partially relevant and neither scores highly. Smaller chunks improve precision but can worsen recall; larger chunks do the reverse.
Duplication. Near-identical chunks occupy several top-k slots, reducing the effective diversity of the context.
Stale or partial index. Content changed, was unpublished, or was never re-embedded, so retrieval returns outdated material or nothing at all.
Generation masking retrieval. The model answers from parametric knowledge and the retrieval failure never surfaces in the final text. Only stage-separated evaluation catches this.
Local AI and WordPress pipelines
If you run embeddings and generation locally, retrieval evaluation has a practical advantage: the labeled query set, the corpus, and the scores can all stay on your own hardware, and you can re-run the full loop without per-query API cost. The hard part is not compute — it is producing honest relevance labels.
For WordPress-based RAG, where a site’s content is indexed to answer visitor or editor questions, the most useful test set is usually drawn from real search queries, support requests, and editor questions rather than invented ones. Two failure modes deserve specific attention: markup and shortcode noise inside chunks, which can distort embeddings, and content that should not be retrievable — drafts, private posts, or internal pages — appearing in results. Verify both with explicit test queries rather than assuming the indexing job handled them.
Defining “good enough”
There is no universal passing score. Pinecone’s guidance includes real-world tips on defining “good enough,” and the honest answer is that the threshold depends on the cost of being wrong. A documentation assistant may tolerate moderate recall if the fallback is a link to search results. A compliance or medical-information system cannot.
A more reliable approach than chasing an absolute number is to establish a baseline, track it across releases, and treat any regression as a defect to investigate. Pair the aggregate score with a review of the actual failing queries, because two systems with identical recall can fail in very different ways.
Start with thirty questions
The fastest path to useful retrieval evaluation is small and unglamorous: write thirty real questions, label the chunks that should answer them, log what your retriever actually returns, and compute recall@k and precision@k. That first run will usually expose a chunking problem, a missing document, or a ranking issue before any model swap would have helped.
Readers working through this on a local stack or a WordPress site are welcome to share their query set structure, configuration, and the failure categories they found in the community discussion.
FAQ
Can I evaluate RAG retrieval without a labeled dataset?
Some metrics can be calculated without a reference dataset, but Google Cloud notes that known-good outputs enable a more comprehensive and nuanced evaluation. Recall and precision specifically require relevance labels, because they are defined relative to what should have been retrieved.
Is recall or precision more important for RAG?
It depends on the cost of each error in your use case. Low recall means the generator never sees the passage that answers the question; low precision means irrelevant chunks consume context and may distract the model. Track both, and use a rank-aware metric to catch ordering problems.
How many test questions do I need?
The supplied guidance does not prescribe a fixed number. Google Cloud recommends a test set that covers a broad subset of the underlying data and includes variations in phrasing and complexity matching real-world use cases. Start small with real user questions, then expand the set from the failures you observe.
Why does my RAG answer look fine when retrieval is failing?
This is the silent-failure pattern Google Cloud describes. The model may answer from parametric knowledge or from a partially relevant chunk, so the final text looks plausible even though the retrieved context was empty or wrong. Evaluating retrieval separately from generation is the way to detect it.