← AI Practitioner study path

Applications with foundation models · 12 min

How do you evaluate a model and an AI application?

In this lesson you will learn which types of evaluation Amazon Bedrock offers, how an LLM as a judge works, what ROUGE, BLEU and BERTScore measure, how a RAG application or an agent is evaluated and which business metrics the exam asks about.

Evaluating a model or an AI application means measuring the quality of its responses with a set of prompts and some metrics, instead of eyeballing a few responses. This measurement is needed every time you change the prompt, connect a or tune a model, because reading ten responses doesn't tell you whether the change broke something in the other thousand. That is why Amazon Bedrock has evaluation jobs, which in the case of a judge model score up to 1,000 prompts at once.

For example, an online store has an assistant that answers questions about shipping. Before changing its prompt, the store gathers hundreds of real questions from its customers, runs them through the old assistant and the new one, and compares the scores of the two.

Types of evaluation in Amazon Bedrock

The four types of evaluation in Amazon Bedrock: programmatic, human-based, model as a judge and RAG evaluation

Amazon Bedrock evaluations offer four types of job:

  • Programmatic (automatic) evaluation, where you use your own prompt dataset or a built-in one, which is a public benchmark, and Bedrock calculates metrics such as accuracy, robustness and toxicity. Robustness measures whether the model keeps answering well when the question comes with typos, and toxicity measures whether it answers with insults or offensive content.
  • Human-based evaluation, where a work team, made up of employees of your company or industry experts, rates the responses of up to two models.
  • Evaluation with a judge model, where a second scores each response and explains its score.
  • RAG evaluation, which measures whether a knowledge base retrieves relevant content and generates good responses.

Each type answers a different question. For example, the store uses human-based evaluation if it wants its customer service employees to say which of two models answers better, and it uses a judge model if it needs to score a thousand responses without anyone reading them.

These job types are also charged differently. In programmatic evaluation, the algorithmic scores, which are the ones a program calculates, cost nothing extra and you pay only for the of the model you evaluate, while in human-based evaluation you pay for the inference and 0.21 USD for each completed human task.

How does an LLM as a judge work?

An LLM-as-a-judge job starts with the prompt dataset, which is a .jsonl file in with up to 1,000 prompts per job. Each line of that file has a prompt and, if you want, a reference response (referenceResponse), which is the response a person considers correct. For example, a line from the store can have the prompt "how long will my shipment take?" and, as the reference, the answer its best customer service employee gave.

LLM as a judge in Amazon Bedrock: prompt dataset, generator model, evaluator model and score with explanation

The generator model answers each prompt, and then the evaluator model scores each response with the metrics you chose and explains why it gave that score. In this type of job you pay for the generator model's inference, and the evaluator's are charged at the standard tier on-demand price.

For scoring, Bedrock comes with eleven built-in metrics for the judge: correctness, completeness, faithfulness, helpfulness, logical coherence, relevance, following instructions, professional style and tone, harmfulness, stereotyping and refusal. Besides these metrics, you can also write your own. Of the eleven built-in metrics, faithfulness is the one most related to , because it measures whether the response includes information that was not in the context the model received. For example, if the store's policy says that shipping takes three days and the assistant answers that it takes one, the judge gives it low faithfulness.

Match each question with the judge metric

0 of 4 pairs

Tap what you want to know and then the metric.

0 of 4 pairs.

ROUGE, BLEU and BERTScore

ROUGE, BLEU and BERTScore are three metrics that compare what the model generated with a reference text written by a person. To understand the first two you need to know what an n-gram is, which is a sequence of n words: "shipping" is a unigram and "the shipping" is a bigram.

With that idea, each metric compares the response in a different way:

  • ROUGE (Recall-Oriented Understudy for Gisting Evaluation), which counts how many n-grams from the reference appear in the response and which is used mostly with summaries.
  • BLEU (Bilingual Evaluation Understudy), which measures the precision of the response's n-grams against the reference and which, according to AWS, is used mostly with translations.
  • BERTScore, which turns the sentences into and compares their meaning.

ROUGE and BERTScore with the same example

The difference between ROUGE and BERTScore shows up when a correct response uses other words. A response that repeats six of the seven words of the reference gets a high ROUGE, while one that says the same thing in other words ("your package is delivered within 72 business hours") gets a low ROUGE even though it is right. BERTScore, on the other hand, measures meaning and scores both of them high. For example, if the store wants its assistant to explain shipping in its own words, BERTScore is more useful to it than ROUGE, because it doesn't penalize different wording.

What do you use to measure it?

0 of 4

Tap the column that matches each case.

  1. Summaries of legal documents that must use the same words as the original

  2. Translations of manuals from English to Spanish compared against a reference translation

  3. Responses that must say the same thing as the reference, even if they change the wording

  4. Whether the assistant's responses are friendly and helpful, with no reference text

How is a RAG application or an agent evaluated?

An application has more pieces than the model, and each one can fail on its own. In a RAG application, for example, the search can fail, bringing back the wrong texts, or the model can fail, answering poorly even though it received the right texts.

RAG evaluation in Amazon Bedrock: retrieval only, and retrieval and generation

To separate those two failures, Bedrock has two types of RAG evaluation job. Both work with an Amazon Bedrock Knowledge Bases knowledge base or with the responses of a RAG application outside Bedrock:

  • The retrieval-only job, which measures whether the search brought back the relevant texts with context relevance and context coverage.
  • The retrieval and generation job, which also measures whether the response is correct, complete and faithful to what was retrieved, and whether the citations are right.

For example, if the store's assistant answers poorly about international shipping, the retrieval-only job tells you whether the search brought back the international shipping policy. If it did and the response is still wrong, the failure is in the model and not in the search.

Agent evaluation

An uses tools, so you also have to measure whether it used them well. For agents there is Amazon Bedrock AgentCore Evaluations, which measures how well the agent and its tools accomplish their tasks. This service has three modes:

  • Online mode, which scores a sample of real traffic, that is, of the conversations happening with real customers, for example 10 % of sessions.
  • On-demand mode, which scores the you choose.
  • Batch mode, which scores many sessions at once and which is useful for comparing before and after a change.

For example, if a customer complains that the store's agent canceled the wrong order, the store reviews the trace of that conversation in on-demand mode to see at which step it went wrong.

How is the business goal measured?

A model can get a good ROUGE and still be of no use to the business, so the exam guide also asks you to recognize business metrics.

The five business metrics of an AI application: productivity, user engagement, task completion rate, user satisfaction and cost per interaction

Each business metric measures a different thing:

  • Productivity, which compares the time per task before and after.
  • User engagement, which counts how many people use the application and how many come back.
  • Task completion rate, which counts how many out of every 100 conversations end up resolved without being handed off to a person.
  • User satisfaction, which measures how satisfied the person using the application is.
  • Cost per interaction, which is what the system costs divided by the number of interactions.

Alongside these metrics, the guide mentions task engineering, which consists of clearly defining what task the model does. Without that definition there is no way to measure whether the application accomplishes its task. For example, if the store defines the task as "resolve shipping questions without handing off to a person", it can measure the task completion rate, and if its assistant handles 1,000 conversations a month at a total cost of 100 USD, the cost per interaction is 0.10 USD.

On the exam

In questions about metrics, these words in the question point to the answer:

  • "Summary", which points to ROUGE.
  • "Translation", which points to BLEU.
  • "Meaning even if the words change", which points to BERTScore.
  • "Tone", "helpfulness" or "no reference response", which point to an LLM as a judge or to people.

To decide between those last two options, "experts", "subjective" or "human rating" point to people, and "scale to thousands of responses without people" points to an LLM as a judge. In business metrics, a question that talks about finance points to cost per interaction, and one that talks about customer service points to task completion rate or to satisfaction. For example, if the question says that a hospital wants doctors to check whether the responses are correct, the option is human-based evaluation.

cloud path tip: in an account on the new AWS experience, Bedrock and AgentCore are on the free plan, but that account stays in the us-east-2 and does not support cross-Region inference. According to their model cards, Amazon Nova Pro, Nova Micro, Nova 2 Lite and Claude Haiku 4.5 can only be called in us-east-2 with cross-Region inference, so in that account they won't work for you as a judge. In a full account you choose a Region where both the generator and the judge are available.

Review question

A team wants to measure its automatic summaries with a metric that compares the text generated by the model with a reference text written by a person. Which metric should it use?

Next