AI Engineering
/
Evaluation & Observability
/

Separate retrieval, packing, and generation failures

Evaluation & Observability · 90 minutes

Separate retrieval, packing, and generation failures

Use a request trace to tell retrieval, context-packing, and generation failures apart, and report answer quality with a named denominator next to operational signals.

Easy
Conceptual

1.5 h

Overview

Learn how to decide whether an AI feature works and how to investigate a failed request. You will separate retrieval quality from answer quality, report rates with named denominators, and read a trace to find where evidence disappeared.

Study time: 90 minutes

Interview format: Conceptual screen with a short trace-reading exercise

By the end you can

  • Define an evaluation case with observable success conditions
  • Distinguish retrieval quality from answer quality
  • Choose between deterministic checks, model graders, and human review
  • Calculate simple success rates with clear denominators
  • Explain metrics, logs, and traces, and read a trace to locate lost evidence

This topic measures quality and investigates failures. Production & Reliability covers running the application.

Evaluation begins with an observable task

An evaluation gives a system an input, observes its behavior or outcome, and applies a defined scoring rule. “The answer sounds good” is difficult to reproduce. “The answer states the current return window, includes the exception, and cites the supporting policy” can be checked.

Define success before inspecting candidate outputs. Otherwise, a team can unconsciously change the rubric to favor a result it already likes. Include behavior for ambiguous requests, missing information, and unsuccessful execution.

For an agent that closes a ticket, the final database state matters. A fluent message claiming that the ticket was closed does not establish task completion.

Components of an evaluation

ComponentMeaningExample
CaseOne task with input and scoring informationAsk about custom-product returns
DatasetA collection of casesOrdinary, exceptional, and unanswerable questions
TrialOne execution of a caseRun the current configuration once
GraderLogic or judgment used to assess a resultCheck required facts and unsupported claims
OutcomeThe actual result or environment stateSupported answer, correct abstention, or failure
HarnessCode that runs and records trialsSubmit fixtures and aggregate scores

A case can be run multiple times because model output may vary. Keep the case count and trial count distinct. Ten executions of the same question provide different evidence from ten different questions.

Retrieval quality and answer quality

Retrieval quality concerns whether useful, eligible evidence is found and ranked appropriately. Answer quality concerns whether the response correctly uses available evidence and satisfies the user's task.

An assistant can retrieve the correct exception clause and still ignore it. It can also fail to retrieve the clause and then produce an unsupported generalization. These failures may look identical in the final answer but require different corrections.

Inspect the actual context sent to the model, not only the top retrieval results. Context packing can remove a relevant passage after retrieval succeeds.

Useful quality dimensions

DimensionQuestion to ask
CorrectnessDoes the answer satisfy the task's factual or functional requirements?
GroundednessAre claims supported by the supplied evidence?
CompletenessAre all required parts addressed?
Citation supportDoes each cited passage support the associated claim?
Format validityDoes the output meet its structural contract?
Appropriate abstentionDoes the system decline or clarify when evidence is insufficient?
Task completionDid the intended operation actually succeed?

These dimensions can disagree. An answer may be grounded in an outdated document and therefore wrong for a current-policy question. A valid JSON response can contain fabricated values. A complete answer may be too slow for the product's requirement.

Automated and human grading

Use deterministic checks when expected behavior is precise, such as JSON schema validity, a permitted category, or a database state. Use human review when meaning, ambiguity, or domain judgment matters.

A model-based grader can help assess large sets of free-text answers, but it can make mistakes and favor style over substance. Give it an explicit rubric and compare its judgments with reviewed examples. Treat grader errors as part of the measurement system.

Exact text matching is appropriate only when one exact representation is required. Two different sentences may express the same correct answer. Conversely, a sentence can contain an expected keyword while reversing its meaning.

Positive, negative, and boundary cases

A positive case exercises a task the system should complete. A negative case exercises behavior such as refusing an unauthorized action or acknowledging that evidence is missing. Define these terms for each dataset because “negative” can also mean an incorrect candidate response.

Boundary cases probe distinctions that commonly fail. In a policy assistant, a standard product and a custom product may have different rules. Include both so a system cannot pass by applying the common rule to everything.

Synthetic cases make edge conditions explicit. Representative real-world cases reveal the actual language and task mix. Use permitted, minimized data and retain the source of each case so evaluation limitations are visible.

Worked quality example: assess four outcomes

Predict the outcome

Assess four outcomes

The fictional policy allows standard-product returns within 30 days and excludes custom-printed products from that standard window. For each observed behavior, decide how you would assess it before you reveal the answers.

CaseObserved behaviorAssessment
Standard product questionCorrect 30-day answer with supporting source?
Custom product questionThe exception passage was in the context sent to the model, but the answer says 30 days?
Shipping fee questionNo fee evidence, answer invents $10?
Shipping fee questionStates that the supplied policy does not specify the fee?

Calculate rates carefully

Suppose ten attempted cases produce eight successful outcomes, one incorrect answer, and one timeout. Overall task success is 8/10, or 80%. Excluding the timeout would report 8/9 and hide a user-visible failure.

Now suppose a different run of the same ten cases gives six substantive answers, five of them correct. Accuracy among answered cases is 5/6, about 83.3%, while answer coverage is 6/10, or 60%. These metrics answer different questions and should be reported together.

Always name the denominator. Distinguish attempted tasks, completed generations, answered cases, and scored outputs. If a judge fails to grade an output, report the missing judgment rather than silently treating it as a pass.

Metrics, logs, and traces

Metrics summarize measurements, such as error count or latency distributions. Logs record individual events. A trace connects steps belonging to one request, often through spans representing operations such as retrieval, model generation, and tool execution.

For an AI request, useful metadata includes configuration versions, candidate IDs, selected evidence IDs, tool-call outcomes, token usage, and elapsed times. This helps connect a quality failure to the stage that produced it.

Telemetry does not automatically explain correctness. A 200 response in 300 ms can still contain a wrong answer. Quality evaluation and operational signals need to be interpreted together.

Trace-reading exercise

Predict the outcome

Find where the evidence disappeared

S1 is the standard 30-day return rule and S2 is the custom-product exception. A user asks about a custom-printed product, and each trace below ends with the same wrong answer. For each trace, name the first stage that lost or misused S2 and what you would investigate first, before you reveal the answers.

TraceRetrieval returnedContext sent to the modelAnswerFirst evidence lossInvestigate first
T1S1, S2S1Says the 30-day window applies??
T2S1, S2S1, S2Says the 30-day window applies??
T3S1S1Says the 30-day window applies??

Protect evaluation and telemetry data

Prompts, documents, and tool results can contain private information. Store only what is needed for diagnosis, restrict access, and define retention. Stable IDs and configuration metadata can often support investigation without storing complete content.

A request ID belongs in a trace or log. Using every request ID as a metric label creates extremely high cardinality and can make the metric system expensive or unusable. Aggregate metrics by bounded categories such as outcome and configuration version.

Completion checklist

  • Define a case with observable success conditions.
  • Separate correctness, grounding, and format validity.
  • Calculate success without excluding failed attempts.
  • Read a trace to locate where evidence disappeared.
  • Explain why privacy and metric cardinality affect instrumentation.

Sources

All datasets, answers, traces, measurements, thresholds, and rubrics here are original synthetic teaching material and describe a fictional application. They are not performance claims about a commercial model. Study times and readiness thresholds are editorial estimates. Production metrics and release gates must reflect the intended task and the consequences of failure, and tool-specific telemetry setups should be checked against the selected vendor's current documentation.

Practice the interview question

Answer it in your own words before you look at the reference answer.