Concept · Builds on AIF-C01
Evaluating RAG retrieval and answers
Score the search and the answer separately on a fixed set of golden questions, and keep watching over time.
You know from AI Practitioner
- RAG fails in retrieval or in generation, so test each stage.
- Bedrock can evaluate a knowledge base with a judge model. Faithfulness checks that answers stick to the retrieved text.
- 1Run the golden questions.
- 2The retrieved chunks go to the model.
- 3Score retrieval on its own.
- 4Score the final answer on its own.
Context relevance
- Layer
- Retrieval
- It asks
- Are the passages on topic?
Context coverage
- Layer
- Retrieval
- It asks
- Do they hold what is needed?
Precision at k
- Layer
- Retrieval
- It asks
- How many of the top k are relevant?
Recall at k
- Layer
- Retrieval
- It asks
- How many relevant ones were found?
MRR
- Layer
- Retrieval
- It asks
- How high is the first hit?
Faithfulness
- Layer
- Generation
- It asks
- Does it use only the passages?
Helpfulness
- Layer
- Generation
- It asks
- Is the answer useful?
| Metric | Layer | It asks |
|---|---|---|
| Context relevance | Retrieval | Are the passages on topic? |
| Context coverage | Retrieval | Do they hold what is needed? |
| Precision at k | Retrieval | How many of the top k are relevant? |
| Recall at k | Retrieval | How many relevant ones were found? |
| MRR | Retrieval | How high is the first hit? |
| Faithfulness | Generation | Does it use only the passages? |
| Helpfulness | Generation | Is the answer useful? |
1 / 3
Context relevance
- Layer
- Retrieval
- It asks
- Are the passages on topic?
Context coverage
- Layer
- Retrieval
- It asks
- Do they hold what is needed?
Precision at k
- Layer
- Retrieval
- It asks
- How many of the top k are relevant?
| Metric | Layer | It asks |
|---|---|---|
| Context relevance | Retrieval | Are the passages on topic? |
| Context coverage | Retrieval | Do they hold what is needed? |
| Precision at k | Retrieval | How many of the top k are relevant? |
2 / 3
Recall at k
- Layer
- Retrieval
- It asks
- How many relevant ones were found?
MRR
- Layer
- Retrieval
- It asks
- How high is the first hit?
Faithfulness
- Layer
- Generation
- It asks
- Does it use only the passages?
| Metric | Layer | It asks |
|---|---|---|
| Recall at k | Retrieval | How many relevant ones were found? |
| MRR | Retrieval | How high is the first hit? |
| Faithfulness | Generation | Does it use only the passages? |
3 / 3
Helpfulness
- Layer
- Generation
- It asks
- Is the answer useful?
| Metric | Layer | It asks |
|---|---|---|
| Helpfulness | Generation | Is the answer useful? |
What it is
Retrieval metrics ask whether the right chunks came back. Bedrock judge metrics are context relevance (are the passages on topic) and context coverage (do they hold everything needed; needs ground truth). Ranking metrics you compute yourself against a golden set: precision at k (share of the top k that is relevant), recall at k (share of all relevant chunks found in the top k) and MRR, the mean of 1 divided by the rank of the first relevant result. A first-place hit scores 1, a third-place hit 0.33.
What it is
Generation metrics ask whether the answer is good, given the chunks: faithfulness (uses only the retrieved text), correctness and completeness against a reference answer, helpfulness (is the answer useful?), and citation precision and coverage (citations support the claims, and claims are cited). Answer relevance is a common name in other tools. In Bedrock, helpfulness is the closest metric.
What it is
The golden set is a fixed list of realistic questions, each with a reference answer. Bedrock takes it as JSONL in S3 with a prompt and referenceResponses (the reference answers). Context coverage needs referenceResponses. The optional referenceContexts (the expected passages) is used only by custom metrics. Precision at k, recall at k and MRR you compute yourself from the expected passages. Keep the set fixed so scores stay comparable.
What it is
A retrieve-only job scores retrieval. A retrieve-and-generate job scores the answer too. Both work on a Bedrock knowledge base, or on a RAG system outside Bedrock whose responses you supply. Run the same set on two settings (chunk size, number of results, reranker, generator model) to pick the better one. Good retrieval with a poor answer is a generation problem. Poor retrieval is a search problem.
What it is
Rerun the set after every ingestion, chunking or model change and on a schedule, and alarm on a drop. Knowledge base logging (APPLICATION_LOGS, to CloudWatch Logs, S3 or Data Firehose) shows per-file ingestion failures, each a retrieval miss waiting to happen. You can also sample live questions with thumbs up or down into a judge job.
Remember
- Golden set: JSONL in S3 with a prompt and reference answers. Expected passages are optional and only for custom metrics.
- Rerun after changes and on a schedule. Logs show files that failed to ingest.
On the exam
- “How high does the first correct passage rank” points to MRR.
- “Answers include facts that are not in the retrieved text” points to low faithfulness.
- “Compare two chunking settings of a knowledge base” points to the same golden set in a RAG evaluation job.
Do not mix it up with
- Optimizing retrieval and embedding modelsTune chunking, top-k, the embedding model, hybrid search, filters and query rewriting, and measure recall.
- Monitoring FM quality in productionInfrastructure metrics cannot tell if answers are good. Sample live traffic, score it, and alarm on the scores.
- LLM-as-a-judge and AI output assessmentChoose the judge model, write the rubric and rating scale, and check the judge against human ratings.
In this task · 2.3
- Experiment tracking: managed MLflow
- Amazon Bedrock evaluations
- Performance baselines and drift detection
- Shadow variants and A/B tests
- Explaining model outputs
- Debugging model convergence
- Evaluating traditional ML models
- NLP and text-generation metrics
- Human evaluation and human-in-the-loop
- LLM-as-a-judge and AI output assessment
- Evaluating RAG retrieval and answers