ladderlore
  • Type a service name, like S3 or IAM.

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.
Read the AI Practitioner lesson
Golden questions
Retrieve
Generate
Retrieval score
Answer score
  1. 1Run the golden questions.
  2. 2The retrieved chunks go to the model.
  3. 3Score retrieval on its own.
  4. 4Score the final answer on its own.
Score the search and the answer separately.
  • 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?
The metrics, by layer.

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?

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?

3 / 3

  • Helpfulness

    Layer
    Generation
    It asks
    Is the answer useful?
The metrics, by layer.

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.