Lesson 6 of 7 Retrieval Augmented Generation

Monitoring RAG Retrieval and Generation Quality

This lesson explains how to monitor retrieval and generation separately, since RAG systems degrade silently as documents, questions and models change, and a wrong answer can come from either stage.

Learning outcomes

After completing this lesson, you will be able to:

  • Separate retrieval failures from generation failures.
  • Combine offline and online monitoring.
  • Track RAG monitoring metrics.
  • Build and maintain a retrieval test set.

Separating retrieval and generation failures

When a RAG application gives a wrong answer, the first diagnostic question is where the failure occurred. If the relevant passage was not retrieved, the failure is in retrieval: chunking, embeddings, metadata filters or stale content are the likely causes. If the passage was retrieved but the answer is still wrong or unsupported, the failure is in generation: the prompt, the model or the length of the context.

This diagnosis is possible only if the retrieved chunks are logged with each answer. Without them, every failure looks like a model problem, and teams change the model when the real fix is in retrieval.

The following diagram shows why a benefits assistant's answer quality dropped after a new policy was uploaded, and the effect on retrieval.

Why the benefits assistant's quality dropped. The new parental-leave policy was uploaded to a prefix outside the knowledge base's data source, so it was never ingested and low-score retrievals rose from 4% to 19%. Adding the prefix and syncing restored context coverage above 0.9; a larger generation model would not have helped.
The prefix and file names, and the rate after the sync, are illustrative.
Sort into groups

Retrieval or generation failure?

Exam skills 2.3.10

Decide where each failure happened in the RAG pipeline.

Log in to try this activity Interactive activities are free with an account.

Offline and online monitoring

Offline, rerun Bedrock RAG evaluation jobs on a fixed test set after every change to documents, chunking, embedding model, prompt or generation model: retrieve-only jobs measure context relevance and coverage, and retrieve-and-generate jobs measure correctness, faithfulness and citation quality. Online, log queries, retrieved chunk IDs and scores, answers and user feedback; publish metrics such as the rate of empty retrievals, low top scores, "I don't know" answers and negative feedback to CloudWatch; and sample production traffic for periodic judge scoring of faithfulness.

Metrics to track

The following table lists useful RAG monitoring metrics.

MetricSignals
Context relevance / coverage (evaluation)Retrieval quality
Faithfulness (judge)Hallucination beyond retrieved context
Citation precision and coverageWhether citations support claims
Empty or low-score retrieval rateMissing content or new question topics
Negative feedback rateUser-perceived quality
Retrieval and generation latencyPerformance of each stage
Match the pairs

RAG metrics

Exam skills 2.3.10

Match each RAG quality metric with what it measures.

Log in to try this activity Interactive activities are free with an account.

Building and maintaining a retrieval test set

Offline retrieval metrics need a test set of questions with known relevant passages or reference answers. A good set covers the main document collections, the question types users actually ask, and difficult cases such as questions that combine two topics, contain exact identifiers or have no answer in the corpus. Production logs are the best source of realistic questions; subject-matter experts then write reference answers or mark the passages that should be retrieved. A judge model can draft candidate questions from documents, but people should review them, because generated questions tend to repeat the document's own wording and make retrieval look easier than it is.

The test set must change as the system changes. When new document collections are added, questions about them should be added too; otherwise the evaluation keeps passing while users fail. Each version of the test set should be stored with a version identifier, so that scores from different months remain comparable and a change in score can be attributed to the system rather than to the test.

Online signals complement the test set by covering questions nobody anticipated. A rising share of queries with low top retrieval scores, a cluster of similar questions with negative feedback, or a new topic that appears in many queries all suggest gaps in the corpus. Reviewing these queries regularly and adding representative ones to the test set turns production experience into regression protection for future changes.

Worked example

A sudden quality drop

User thumbs-down feedback on a benefits assistant doubles in one week. Logs show the rate of low-score retrievals rose from 4% to 19%, mostly for questions about a new parental-leave policy.

The new policy PDF was uploaded to a different S3 prefix that is not part of the data source, so it was never ingested. Adding the prefix and syncing fixes retrieval, and a retrieve-only evaluation job confirms context coverage is back above 0.9. Switching to a larger generation model would not have helped, because the information was never retrieved.

Check yourself

Why log the retrieved chunks with every answer?

Show answer

To tell retrieval failures from generation failures when an answer is wrong.

Exam Tips

Remember for the exam

  • Log retrieved chunks with every answer to separate retrieval from generation failures.
  • Retrieve-only evaluation: context relevance and coverage.
  • Faithfulness detects answers unsupported by the context.
  • Rising low-score retrievals often mean missing or stale content.
  • Rerun RAG evaluations after every configuration or content change.