AIP-C01 · D5 · 11%

Testing, Validation, and Troubleshooting

Build representative evaluation systems, diagnose cross-layer failures, compare releases, and turn incidents and feedback into reproducible improvements.

Provider facts checked 2026-08-03

Objective coverage

Objective 5.1 · high

Build evaluation systems

Define datasets, rubrics, deterministic and model-based metrics, human review, baselines, thresholds, experiments, and regression gates.

Lesson
d5-lesson
Practice pool
d5-questions
Application
aip-l03, aip-l06
Objective 5.2 · high

Troubleshoot GenAI applications

Isolate failures across prompts, context, retrieval, model invocation, tools, permissions, quotas, data, deployment, and observability.

Lesson
d5-lesson
Practice pool
d5-questions
Application
aip-l07, aip-l08

Decision frame

GenAI testing must evaluate distributions of behavior, not one deterministic output. Define what must remain invariant—authorization, schema, prohibited actions, privacy, critical factual support—and what may vary within a rubric. Use representative, adversarial, boundary, and regression cases. Keep release decisions reproducible by versioning the dataset, rubric, model, prompt, retrieval, tools, guardrails, code, and scoring configuration.

Troubleshoot from observable symptoms through layers. Do not change the model first merely because the user sees a bad answer.

Objective map

ObjectiveRequired judgmentProof
5.1 Build evaluation systemsSelect datasets, deterministic checks, rubrics, model-based metrics, human review, thresholds, baselines, and experimentsThe same versioned inputs reproduce a release decision and expose critical failures
5.2 Troubleshoot GenAI applicationsIsolate prompt, context, retrieval, model, tool, identity, quota, data, deployment, or telemetry failuresA layer-level hypothesis is tested before configuration changes are promoted

Design the evaluation system

Start with the real task and harm model. Build cases from normal workflows, difficult examples, rare but costly failures, known incidents, user feedback, supported languages and modalities, authorization boundaries, malformed input, prompt injection, stale data, missing evidence, tool failure, and required abstention. Use synthetic data where production data is sensitive, but verify that the synthetic set still represents the important decisions.

Separate development, tuning, and release sets. If prompt authors repeatedly inspect the release answers, the gate becomes a tuning set and overstates generalization. Version cases and expected properties. Preserve a rationale for why each case exists and which requirement or risk it covers.

Use deterministic checks where possible: JSON schema, required fields, allowed values, exact identifiers, citation presence, permission decision, tool parameters, latency, cost, and prohibited strings. Use rubrics and human review for context-dependent quality, relevance, completeness, tone, or harm. Model-based judges can scale review but may share model biases, be sensitive to prompt wording, or prefer verbose answers. Calibrate them against human-reviewed examples and do not let a judge override a hard deterministic failure.

Metrics must match the layer. Retrieval evaluation can measure whether required evidence is found and ranked. Generation evaluation can measure support, completeness, correctness, and citation quality. Safety evaluation measures defined harmful or prohibited behavior and false positives. Operational evaluation measures latency, throughput, errors, quotas, and cost. Business evaluation measures task completion and escalation. A single aggregate score can hide a catastrophic failure, so define hard thresholds and slice results by critical scenario, language, tenant, or user group where relevant.

Release evaluation

Compare candidate and baseline on the same versioned set. Record confidence intervals or sample limitations when the set is small. Require improvement or non-regression according to the change goal. A candidate with higher average quality must still fail if it violates authorization, leaks data, performs a prohibited action, or crosses another hard safety boundary.

Use offline evaluation before deployment, integration tests against real service boundaries, and limited online evaluation with approved traffic and monitoring. Shadow testing can compare behavior without returning candidate output, but it still processes data and needs privacy approval. A/B testing is appropriate only when exposure and metrics are ethically and operationally acceptable. Keep rollback inputs ready.

Troubleshooting by layer

  1. Request: Is the authenticated user, input, locale, and task classification correct?
  2. Prompt and context: Is the correct version loaded? Is input truncated, misplaced, or allowed to override instructions?
  3. Retrieval: Did ingestion complete? Are embeddings, index, filters, tenant, top-k, reranking, freshness, and permissions correct?
  4. Model invocation: Is the intended model, Region, API, parameter set, quota, token budget, and guardrail used?
  5. Tools and workflow: Did the schema validate, authorization pass, state remain current, retry remain idempotent, and result return in bounds?
  6. Output: Did parsing, safety, grounding, citation, and business validation behave correctly?
  7. Deployment: Are code, prompt, model, data, index, tool, and environment versions aligned?
  8. Observability: Is telemetry missing, sampled, redacted, delayed, or correlated incorrectly?

Reproduce with the smallest safe case. Compare the failed trace to a successful baseline. Change one controlled variable. Record hypothesis, evidence, result, and remediation. Do not repair production by making an unversioned prompt edit.

Failure patterns

SymptomLikely layersHigh-value test
Fluent unsupported answerRetrieval, prompt, grounding, abstentionInspect retrieved evidence and run a no-support case
Correct source not retrievedChunking, embedding, filter, index, queryCheck gold-passage recall before generation
Cross-tenant resultAuthorization, metadata, cache, memoryAttempt known adversarial tenant queries
Intermittent malformed JSONPrompt, model behavior, streaming, parserCapture raw bounded output and enforce schema retry policy
Tool action duplicatedTimeout, retry, idempotency, stateReplay with the same idempotency key
Quality drops after releaseModel, prompt, corpus, router, user driftCompare exact release inputs by dataset slice
Latency spikesRetrieval, model queue, tool, concurrency, quotaTrace time by layer and correlate saturation

Decision patterns

  • Invariant before preference: authorization, privacy, schema, prohibited actions, and required support are hard gates; style and average quality are comparative measures.
  • Representative slices before aggregate scores: expose rare, high-impact, language, tenant, and boundary failures that a mean can conceal.
  • Layer evidence before configuration changes: isolate request, context, retrieval, model, tool, output, deployment, and telemetry hypotheses one controlled variable at a time.
  • Reproducibility before release: version every input that can change the result and preserve the exact candidate-to-baseline comparison.
  • Regression case before closure: convert a confirmed defect into a durable test and rerun the affected safety and quality slices.

Scenario drill

A candidate release improves average answer relevance from the current benchmark, but occasionally cites a document the user cannot access and doubles p95 latency.

  1. Treat unauthorized citation as a hard release failure regardless of the average score.
  2. Reproduce the access case and inspect retrieval authorization, filters, cache keys, and source metadata.
  3. Separate retrieval relevance from generation citation behavior.
  4. Trace latency across retrieval, reranking, model, and validation.
  5. Fix and rerun the same versioned cases plus new regression cases.
  6. Compare against the baseline and document the decision; do not tune only to the failed example.

Common traps

  • Using a handful of demo prompts as a release benchmark.
  • Tuning repeatedly on the final evaluation set.
  • Letting an average score hide data leakage or prohibited actions.
  • Using only a model judge with no calibration or human sample.
  • Evaluating generated answers without evaluating retrieval.
  • Changing model, prompt, and chunking simultaneously during troubleshooting.
  • Treating production user feedback as safe training data without permission and privacy review.

Self-check

  1. Define deterministic, rubric, human, and operational checks for one task.
  2. Design a dataset split that reduces evaluation leakage.
  3. Explain why a model judge cannot override a hard authorization failure.
  4. Troubleshoot one grounded-answer failure from request through output.
  5. List the version identifiers required to reproduce a candidate evaluation.

Primary references