← All Google Cloud AI guidesGen AI · 2.3, 6.2

Evaluating LLMs and agents

How to tell whether a gen AI system is good enough and stays that way: building evaluation datasets, computation-based vs model-based (LLM-as-a-judge) metrics, judge biases and how to control them, pointwise vs pairwise and rubric-based evaluation, Agent Platform Evals, agent trajectory metrics, safety evaluation, online monitoring, and statistics for comparing versions. Includes a win-rate confidence calculator.

1. Why LLM evaluation is different

Classic models have one right label per input. Generative outputs are open-ended: many answers can be right, wording varies run to run, and quality has several dimensions (correct, grounded, safe, helpful, on-format). So evaluation combines several kinds of metric over a fixed, versioned dataset, and runs on every change.

WhenPurpose
Model or tier selectionWhich model meets the quality bar at the lowest cost?
Prompt and RAG iterationDid this change help or hurt?
Before every release (CI)Regression gate: prompt, model version, retrieval or tool changes
After tuningTuned model vs base model with prompting, on held-out data
In productionOnline monitoring of sampled traffic, user feedback, safety

2. Building the evaluation dataset

3. Computation-based vs model-based metrics

TypeExamplesStrengthsWeaknesses
Computation-basedExact match, BLEU, ROUGE, JSON schema validity, tool-call validity and parameter match, regex checksCheap, fast, deterministicNeed references; penalize valid paraphrases; miss meaning
Model-based (LLM-as-a-judge, autorater)Fluency, coherence, groundedness, instruction following, safety, helpfulness, custom criteriaJudge meaning without references; scaleBiased, costs tokens, must be validated against humans
Human evaluationExpert ratings, side-by-side preferencesThe ground truth for subjective qualitySlow, expensive, inconsistent between raters
MetricGood for
Exact matchClassification labels, short factual answers, extracted fields
BLEUN-gram precision against references: translation
ROUGE (ROUGE-L and variants)N-gram / longest-common-subsequence recall: summarization against references
Schema validityStructured output
GroundednessRAG: answer supported by context
Instruction following, fluency, coherence, safetyOpen-ended generation
High ROUGE doesn't mean a good summary: a summary can share many words with the reference and still get the key fact wrong. Use overlap metrics as a cheap signal alongside model-based or human judgement.

4. Pointwise, pairwise and rubrics

ModeHowUse when
PointwiseJudge scores one response on a scale (for example 1–5) against criteriaAbsolute quality tracking, thresholds, monitoring
PairwiseJudge picks the better of two responses (baseline vs candidate) for the same prompt; report win rateComparing two models, prompts or settings; more sensitive to small differences
RubricsA list of specific, checkable criteria ("mentions the 30-day limit", "doesn't promise refunds for shipping")Making judgements consistent and explainable
Adaptive rubricsAgent Platform Evals generates prompt-specific rubrics, then checks responses against themDiverse prompts where one generic rubric is too vague
"Which of two prompt versions is better for open-ended answers with no single reference?" → pairwise model-based evaluation on a fixed dataset, calibrated against human ratings.

5. LLM-as-a-judge: biases and how to control them

BiasWhat happensMitigation
Position biasPairwise judge prefers the first (or second) responseEvaluate both orders and average or count only consistent wins; randomize order
Verbosity biasLonger answers win regardless of qualityRubrics that reward concision; length-controlled comparisons; check length vs score correlation
Self-preferenceA judge favours outputs from its own model familyUse a different (often stronger) judge model; validate with humans
Leniency / score compressionEverything gets 4/5Clear rubrics with anchored examples per score; prefer pairwise or binary checks
InconsistencySame input, different scoreLow judge temperature, multiple samples, explanations before scores
Domain blind spotsJudge lacks domain knowledge (medical, legal)Give references or context to the judge; expert human review

Validating the judge

  1. Have humans label a sample (for example 100–200 items) with the same rubric.
  2. Measure agreement between judge and humans: accuracy, and Cohen's kappa (agreement corrected for chance), or correlation for scores.
  3. Iterate on the judge prompt and rubric until agreement is acceptable; recheck when the judge model changes.

Kappa interpretation (rough): below 0.4 weak, 0.4–0.6 moderate, 0.6–0.8 substantial, above 0.8 strong. Use the calculator below.

6. Agent Platform Evals

Agent Platform Evals (formerly the Gen AI evaluation service) runs evaluations of models, prompts, RAG systems and agents.

CapabilityWhat to know
DatasetsPrompts, responses (or generate them during the run), references, context, expected trajectories
Computation-based metricsExact match, BLEU, ROUGE, tool-call validity, tool name and parameter match
Model-based metricsPrebuilt pointwise and pairwise templates (fluency, coherence, safety, groundedness, instruction following, summarization and question-answering quality) and custom criteria
Adaptive rubricsPer-prompt rubrics generated and checked automatically
Agent metricsTrajectory and tool-use metrics; multi-turn task success
ResultsPer-row scores and explanations, summary tables; logged to Experiments for comparison over time
ProductionOnline evaluation monitors on sampled live traffic; user and environment simulators for agents
# Sketch with the Agent Platform SDK; module and metric names vary by release.
import pandas as pd
import vertexai
from vertexai.evaluation import EvalTask, PointwiseMetric, MetricPromptTemplateExamples

vertexai.init(project="PROJECT_ID", location="us-central1")
data = pd.DataFrame({"prompt": prompts, "response": responses, "reference": references})
task = EvalTask(dataset=data,
                metrics=["exact_match", "rouge_l_sum",
                         MetricPromptTemplateExamples.Pointwise.GROUNDEDNESS],
                experiment="support-bot-eval")
result = task.evaluate()
print(result.summary_metrics)
SDK surfaces for evaluation move between modules across releases, and some modes (for example pairwise) are only in some client libraries. Learn the concepts: dataset, metrics (computation and model-based), pointwise vs pairwise, experiments for tracking.

7. Evaluating agents: trajectories and tool use

For agents, the final answer isn't enough: the trajectory (sequence of tool calls) shows whether the agent got there safely and efficiently.

MetricPasses when
Trajectory exact matchTool calls exactly equal the reference sequence
In-order matchAll reference calls appear in order; extra calls allowed
Any-order matchAll reference calls appear, in any order
Trajectory precisionShare of predicted calls that are in the reference (penalizes unnecessary calls)
Trajectory recallShare of reference calls that the agent made (penalizes missed steps)
Single tool useA specific required tool was called
Tool-call validity and parameter matchCalls are well-formed with correct arguments
Final response qualityModel-based metrics on the answer
Multi-turn task successThe user's goal was achieved over a whole conversation (often with a simulated user)
Exact = same calls, same order, nothing extra. In-order = same order, extras OK. Any-order = all present. Precision punishes extras; recall punishes misses.

8. Safety evaluation and red-teaming

9. Online evaluation and monitoring

SignalHow
Sampled judge scoresOnline evaluation monitors run metrics on a sample of live requests
User feedbackThumbs up/down, edits, escalations to humans, task completion
OperationalLatency (time to first token, total), token usage, cost, error and 429 rates, safety blocks
TracingPer-request traces of retrieval and tool calls (Cloud Trace, Agent Runtime tracing)
A/B testsSplit traffic between prompt or model versions and compare business metrics

10. Regression testing in CI/CD

  1. Store prompts, model version, retrieval settings and tools in version control.
  2. On every change, a pipeline (Cloud Build or a Pipelines run) generates responses for the frozen evaluation set.
  3. Compute computation-based checks (schema, exact match, tool calls) and model-based metrics; compare with the current production baseline.
  4. Gate: block the release if key metrics drop beyond a tolerance or safety checks fail.
  5. Log the run to Experiments for history; pin model versions so upgrades are deliberate and evaluated.

11. Win-rate and judge-agreement calculator

Pairwise win rate with a 95% Wilson interval (ties excluded), and Cohen's kappa between the judge and human labels.

12. Lab: evaluate two prompt versions and an agent

  1. Build a 50-row dataset from realistic questions with references (and expected sources for RAG).
  2. Run prompt A and prompt B. Compute exact match or ROUGE where references fit, and a pointwise groundedness or instruction-following metric.
  3. Run a pairwise comparison of A vs B; then swap the response order and rerun. How many verdicts flip (position bias)?
  4. Label 40 rows yourself; compute judge–human kappa with the calculator.
  5. For an ADK agent, write expected tool trajectories for 10 tasks; compute exact, in-order and any-order match, precision and recall.
  6. Wire the evaluation into a Cloud Build step that fails when groundedness drops by more than a set tolerance.

13. "Which evaluation method?" chooser

Pick an item to see what it means, why, and the tempting wrong choice.

Pick one above.

14. Sample outputs

What the tools return. Expand an item to see a typical result and what to read in it.

Illustrative output, not captured from a real project. IDs, numbers and some field names are invented or simplified, and formats change between releases. Learn the shape and the fields called out under each one.
Agent Platform Evals summary (simplified)Pairwise comparison of two prompt versions
metric                       candidate (grounded)   baseline (ungrounded)
groundedness (pointwise, 1-5)        4.6                    3.1
pairwise_quality win rate            0.71                   0.22   (ties 0.07)
rouge_l                              0.48                   0.41
avg latency (s)                      1.9                    1.2

What to look at: The grounded version wins 71% of pairwise judgements and is much more grounded, at the cost of 0.7 s more latency from retrieval. Before trusting the judge, spot-check its decisions against human labels on a sample.

15. Scenarios

Exam-style situations: how to diagnose each one, the likely cause and the fix.

16. Searchable reference

ItemMeaning

17. Flashcards (click to flip)

18. Common gotchas in one list

  1. Open-ended outputs need model-based or human evaluation; exact match and BLEU alone mislead.
  2. Pairwise for comparisons, pointwise for tracking.
  3. Validate the judge against humans before trusting it; measure agreement with kappa.
  4. Swap order in pairwise judging to cancel position bias.
  5. Long answers aren't better answers: watch verbosity bias.
  6. Don't let a model judge itself when you can avoid it.
  7. Small win margins on small sets are noise: compute an interval.
  8. Evaluate agent trajectories, not just final answers.
  9. Precision punishes extra tool calls; recall punishes missed ones.
  10. Frozen, versioned datasets with edge cases and past failures; run in CI on every change.
  11. Pin model versions so upgrades go through evaluation.
  12. Safety evaluation measures over-refusal too, not just harmful content.
  13. High ROUGE can hide wrong facts.
  14. Offline evaluation doesn't replace online monitoring and user feedback.

19. Practice quiz (22 questions)

Score: 0 / 0
← RAG and its failure modesNext: Data, Feature Store, notebooks, experiments →