Skill 2.3.4: Explain model outputs
Question 1 - SageMaker Clarify for Global vs Local Explainability
A financial services company has deployed a credit risk classification model on Amazon SageMaker AI. The compliance team requires two types of explanations for the model's predictions: (1) a dashboard showing overall feature importance across all predictions, and (2) per-application explanations that show which specific features most influenced an individual applicant's credit decision.
The ML engineering team must implement these explanation capabilities with minimal operational overhead and without writing custom interpretability code from scratch.
Which ONE approach should the team use to satisfy both requirements?
A) Use Amazon SageMaker Clarify in offline mode to compute global SHAP values for the dashboard, and run Clarify in online mode with the model endpoint to produce per-prediction feature attributions for individual applicants.
B) Use Amazon SageMaker Model Monitor to capture data quality metrics for the dashboard, and implement a custom SHAP library in an AWS Lambda function to generate individual explanations.
C) Use Amazon Bedrock Guardrails to inspect model inputs and generate global feature importance reports, and enable CloudWatch Logs insights queries to retrieve per-prediction explanations.
D) Deploy the model to Amazon SageMaker Serverless Inference and enable automatic explanation generation in the endpoint configuration, which produces both global and local feature attribution dashboards natively.
E) Use Amazon SageMaker Feature Store to track feature metadata for global reporting, and configure Amazon OpenSearch Service to index prediction explanations for individual queries.
Click to reveal Answer & Explanation
Correct Answer: A
Correct Options Analysis
- A is Correct: Amazon SageMaker Clarify natively supports both global and local model explainability. Offline Clarify jobs compute aggregate global SHAP values for feature importance dashboards, while online Clarify (attached as a processing step to a deployed endpoint) generates real-time per-prediction feature attributions. This satisfies both requirements without custom code.
Distractor Analysis
- B is Incorrect: SageMaker Model Monitor detects data drift and model quality issues—it does not produce feature attribution explanations. Implementing custom SHAP in Lambda introduces significant operational overhead and bypasses SageMaker's managed explainability.
- C is Incorrect: Bedrock Guardrails handles content filtering, PII redaction, and prompt safety for generative AI—it does not perform traditional ML model explainability. CloudWatch Logs insights cannot derive SHAP value explanations from model outputs.
- D is Incorrect: SageMaker Serverless Inference is a compute model for cost-efficient intermittent traffic; it does not natively produce global/local feature attribution dashboards as part of endpoint configuration.
- E is Incorrect: SageMaker Feature Store manages feature ingestion, storage, and retrieval—not model explainability. OpenSearch indexes data for search and analytics, not for computing feature attributions.
Key Takeaway: SageMaker Clarify is the core AWS service for model explainability—use offline mode for global SHAP analysis and online mode for real-time per-prediction explanations.
Question 2 - RAG Response Source Attribution
A legal technology firm operates a retrieval-augmented generation (RAG) system built with Amazon Bedrock Knowledge Bases and Amazon OpenSearch Serverless. The system generates case law summaries by retrieving relevant legal passages and feeding them as context to a large language model.
A regulatory compliance audit requires that every generated response includes citations to the source documents that informed the answer. Additionally, the firm needs to monitor whether the retrieved passages actually contain the facts stated in the generated responses.
Which TWO steps should the team implement to meet these requirements? (Select TWO)
A) Configure Amazon Bedrock Knowledge Bases to return source attribution metadata with each response by enabling retrieval with citations, and log the retrieved chunk identifiers alongside the generated output.
B) Compute faithfulness metrics by comparing the generated response against the retrieved context chunks, and monitor these metrics using Amazon Bedrock Evaluations.
C) Use Amazon Comprehend to extract entities from the generated response and map them back to source documents using a custom entity resolution pipeline.
D) Configure AWS X-Ray tracing on the Bedrock invocation to automatically generate source document citations in the response output.
E) Replace OpenSearch Serverless with Amazon Redshift so the retrieval step can use SQL joins to attach source document metadata to generated responses.
Click to reveal Answer & Explanation
Correct Answers: A and B
Correct Options Analysis
- A is Correct: Amazon Bedrock Knowledge Bases supports retrieval with citations, which returns source chunk metadata including document identifiers, text spans, and S3 locations alongside the LLM response. This provides auditable attribution without custom pipeline code.
- B is Correct: Faithfulness evaluation measures whether the generated response is factually consistent with the retrieved context. Running Bedrock Evaluations against the RAG system allows the team to detect halluciinations or omitted facts from the source passages.
Distractor Analysis
- C is Incorrect: Amazon Comprehend performs entity recognition, sentiment analysis, and topic modeling, but it does not automatically link generated text back to RAG retrieval chunks. Building a custom entity resolution pipeline introduces unnecessary complexity.
- D is Incorrect: AWS X-Ray is a distributed tracing service for debugging application performance—it tracks request flows and latencies, not semantic source attribution or citation generation.
- E is Incorrect: Replacing OpenSearch with Redshift is architecturally inappropriate: Redshift is an analytical data warehouse designed for SQL aggregation over tabular data, not vector similarity search for semantic retrieval.
Key Takeaway: For RAG explainability, enable source citations in Bedrock Knowledge Bases and evaluate faithfulness separately—response quality and source attribution are distinct evaluation dimensions.
Question 3 - Explaining a Generated Answer vs. a Retrieved Passage
A healthcare AI startup uses a RAG architecture with Amazon Bedrock Knowledge Bases to answer clinical guideline questions. A clinician asks the system: "What is the recommended dosage for medication X in patients over 65?"
The system returns a fluent, confident answer. The clinician needs to understand why this particular answer was generated.
Which ONE of the following statements correctly describes how the team should explain the output to the clinician?
A) The team should retrieve the passage chunks that were fed as context to the model and show the clinician exactly which retrieved documents supported each claim in the generated answer.
B) The team should present the model's internal activation maps for the layers most involved in token generation, showing how the model reasoned through the query.
C) The team should run Amazon Bedrock Evaluations with an LLM-as-a-judge to score the answer's coherence, and provide that score as the explanation to the clinician.
D) The team should provide the clinician with the model version ID, the training dataset statistics, and the token count of the response as the complete explanation.
E) The team should implement Amazon SageMaker Clarify to compute SHAP values for each input token, explaining each word's contribution to the generated answer.
Click to reveal Answer & Explanation
Correct Answer: A
Correct Options Analysis
- A is Correct: A retrieval-augmented system can point to its evidence sources. The retrieved passage chunks serve as the model's grounding context, and presenting these source documents to the clinician provides transparency into what information informed the generated answer. This is a key advantage of RAG over black-box customized models.
Distractor Analysis
- B is Incorrect: Internal activation maps (like attention weights or saliency maps) are not accessible or interpretable at a clinical level for general-purpose LLM tokens on Bedrock, and they do not constitute a practical explanation for end-users.
- C is Incorrect: An LLM-as-a-judge evaluation score (e.g., "coherence = 4.⅖") tells how good the answer appears, not why the answer contains specific claims. A score is an evaluation metric, not an explanation.
- D is Incorrect: Model version IDs, training statistics, and token counts are metadata—they do not explain why specific clinical content appeared in the response.
- E is Incorrect: SageMaker Clarify SHAP values are designed for traditional tabular ML model feature attribution (e.g., credit scoring), not for token-level explainability of LLM-generated text. Implementing token-level SHAP for an LLM would be methodologically inappropriate and computationally impractical.
Key Takeaway: RAG systems provide source-based explanation by design—show the retrieved passages that grounded the response. Custom-trained LLMs cannot do this, which is a core architectural trade-off.
Question 4 - Debugging Convergence: Oscillating Loss
An ML engineer is training a deep neural network for image classification using Amazon SageMaker AI. During training, the engineer observes that the training loss oscillates wildly between epochs and never settles to a stable minimum. The validation loss follows the same oscillating pattern.
The engineer wants to diagnose the issue efficiently. Which TWO actions should the engineer take FIRST? (Select TWO)
A) Reduce the learning rate or implement a learning rate decay scheduler.
B) Increase the learning rate to push through the oscillation and reach a lower minimum faster.
C) Inspect the training logs in Amazon CloudWatch Logs to confirm that data shuffling is not causing batch-level variance.
D) Increase the model's capacity by adding more layers and parameters.
E) Immediately switch from stochastic gradient descent to full-batch gradient descent.
Click to reveal Answer & Explanation
Correct Answers: A and C
Correct Options Analysis
- A is Correct: Oscillating loss that never settles is the classic signature of a learning rate that is set too high. Weight updates repeatedly overshoot the local minimum, preventing convergence. Reducing the learning rate or applying a decay schedule stabilizes gradient descent.
- C is Correct: Checking CloudWatch Logs for the training run allows the engineer to verify whether data loading and shuffling are functioning correctly, and whether the loss oscillation pattern correlates with batch boundaries. This is a low-cost diagnostic step before making model changes.
Distractor Analysis
- B is Incorrect: Increasing the learning rate when loss already oscillates would amplify the overshooting problem, making convergence even more unstable.
- D is Incorrect: Adding model capacity (more layers or parameters) does not address a learning rate issue and may introduce overfitting if the model already has sufficient capacity for the task.
- E is Incorrect: Switching to full-batch gradient descent is computationally prohibitive for large datasets and does not address the root cause of an oversized learning rate.
Key Takeaway: Oscillating loss = learning rate too high (overshooting minima). Barely moving loss = learning rate too low. Training improving while validation worsens = overfitting. These three patterns should be your first debugging hypotheses.
Question 5 - Shadow Testing for Production Comparison
A retail company has a product recommendation model running on Amazon SageMaker AI. The team has trained a new candidate model using a different neural network architecture and wants to validate it against the current production model using live traffic without any risk to customer experience.
The requirements are:
- Production responses must continue to be served to callers.
- The candidate must receive real-world request patterns, not synthetic or stored data.
- The comparison must track both prediction quality and endpoint latency metrics.
Which TWO actions should the ML engineer perform to meet these requirements? (Select TWO)
A) Deploy the candidate as a shadow variant on the same SageMaker AI endpoint as the production variant, and configure traffic mirroring so a copy of live requests is routed to both.
B) Create an Amazon Bedrock evaluation job with a curated prompt dataset to score the candidate model against the production model offline.
C) Log both production and shadow variant responses, latencies, and error rates in Amazon CloudWatch for offline comparison and analysis.
D) Route 50% of live traffic to the candidate model and 50% to the production model using endpoint routing weights, then compare the responses.
E) Disable logging on the production variant to avoid any impact on live request processing latency.
Click to reveal Answer & Explanation
Correct Answers: A and C
Correct Options Analysis
- A is Correct: SageMaker AI shadow testing deploys a candidate (shadow) variant alongside the production variant on the same endpoint. Live traffic is mirrored so both variants receive the same requests, but only the production variant responds to callers. This satisfies all requirements: live traffic, zero caller impact, and real request patterns.
- C is Correct: Logging responses, latency metrics, and error rates from both the production and shadow variants to CloudWatch enables offline comparison of prediction quality (e.g., via a separate analysis job) and operational metrics (e.g., p50/p95 latency).
Distractor Analysis
- B is Incorrect: An offline Bedrock evaluation job uses a static, pre-compiled dataset—not live traffic. This violates the requirement that the candidate must receive real-world request patterns.
- D is Incorrect: Routing 50% of live traffic to the candidate endpoint is an A/B test, not a shadow test. Callers would receive responses from the candidate model, violating the requirement that production responses must continue to be served.
- E is Incorrect: Disabling logging on the production variant would make comparison with the shadow variant impossible, as there would be no production baseline data for offline analysis.
Key Takeaway: Shadow testing isolates the candidate from the caller (only production responds) while still testing against live traffic. A/B testing exposes some callers to the candidate—a fundamentally different risk profile.
Question 6 - Bedrock Evaluation Modes
A marketing analytics company uses Amazon Bedrock to generate product descriptions and ad copy. The content team needs to evaluate the quality of generated text across three dimensions:
- Factual consistency of the generated copy against the product attributes provided in the prompt context.
- Subjective preference ratings from specialized human copywriters on which phrasing is more persuasive.
- Automated comparison against reference texts from previous successful campaigns.
The company must implement this evaluation with minimal operational overhead.
Which THREE approaches should the team use for the respective dimensions? (Select THREE)
A) Use an Amazon Bedrock Evaluations programmatic job with a metric like BERTScore or ROUGE to compare generated copy against reference texts.
B) Use an Amazon Bedrock Evaluations human-based evaluation job where copywriters rate the outputs on persuasiveness and preference.
C) Use Amazon Bedrock Evaluations with an LLM-as-a-judge model to assess factual consistency between generated copy and the product attributes provided in the input context.
D) Build a custom evaluation pipeline using AWS Lambda functions that call the Bedrock API, parse responses with regex, and compute evaluation scores manually.
E) Use Amazon SageMaker Model Monitor to automatically detect when the generated content quality drops below a threshold, without requiring any evaluation job configuration.
Click to reveal Answer & Explanation
Correct Answers: A, B, and C
Correct Options Analysis
- A is Correct: Bedrock Evaluations supports programmatic jobs that compute automated NLP metrics like BLEU, ROUGE, and BERTScore against reference text. This is the appropriate mode for dimension 3 (reference-based comparison).
- B is Correct: Bedrock Evaluations supports human-based evaluation jobs where a workforce (internal teams, SMEs, or AWS-managed workers) rates outputs on custom criteria like persuasiveness. This is the appropriate mode for dimension 2 (subjective human preference).
- C is Correct: Bedrock Evaluations supports LLM-as-a-judge evaluations where a separate model scores each output on dimensions like factual consistency (faithfulness). This is the appropriate mode for dimension 1 (factual consistency against context).
Distractor Analysis
- D is Incorrect: Building a custom Lambda-based evaluation pipeline introduces unnecessary operational overhead when Bedrock Evaluations natively provides programmatic, judge-based, and human-based evaluation modes.
- E is Incorrect: SageMaker Model Monitor detects data drift, model quality issues, and bias in tabular ML endpoints—it does not evaluate generative text quality and cannot perform the multi-dimensional evaluation described.
Key Takeaway: Bedrock Evaluations provides three evaluation modes: programmatic (NLP metrics), LLM-as-a-judge (model-scored quality), and human-based (subjective ratings). Match the mode to the evaluation dimension.
Question 7 - Overfitting vs. Convergence Issue
A data science team is training a text classification model using a transformer architecture on Amazon SageMaker AI. After 10 epochs, the following pattern emerges:
- Training loss: Steadily decreasing (0.45 → 0.08)
- Training accuracy: Increasing (82% → 97%)
- Validation loss: Increasing (0.40 → 0.85)
- Validation accuracy: Decreasing (81% → 68%)
The team is confused about whether the model has a convergence problem or an overfitting problem. Which ONE conclusion is most accurate, and what action should the team take?
A) The model is overfitting to the training data. The team should apply regularization techniques (e.g., dropout, weight decay), early stopping, or increase the training dataset size.
B) The model has a convergence problem caused by a learning rate that is too high. The team should reduce the learning rate and retrain.
C) The model has a convergence problem caused by an inadequate model architecture. The team should switch to a larger model with more parameters.
D) The model is converging normally and the validation degradation is expected noise. The team should continue training for more epochs.
E) The model has an unstable optimization problem caused by poor data quality. The team should re-clean the dataset and redo feature engineering.
Click to reveal Answer & Explanation
Correct Answer: A
Correct Options Analysis
- A is Correct: The classic overfitting signature is when training metrics continue to improve while validation metrics degrade. The model is memorizing the training data instead of learning generalizable patterns. Regularization, early stopping, more training data, or simpler model architectures are standard remedies.
Distractor Analysis
- B is Incorrect: A learning-rate-too-high problem manifests as oscillating or diverging loss in both training and validation, not a steady decrease in training loss with a simultaneous validation degradation.
- C is Incorrect: Switching to a larger model with more parameters will likely worsen overfitting, not fix it. Larger models have more capacity to memorize training data.
- D is Incorrect: Validation accuracy decreasing by 13 percentage points while validation loss nearly doubles is not normal noise—it is a clear overfitting pattern that requires intervention.
- E is Incorrect: Poor data quality or label noise typically causes poor performance across both training and validation sets from the start, not a divergence where training improves while validation worsens.
Key Takeaway: Training improving + validation worsening = overfitting. Both training and validation poor = underfitting or data quality issues. Oscillating loss = learning rate too high.
Question 8 - Monitoring Retrieval Accuracy Separately from Generation Quality
A customer support chatbot uses a RAG architecture with Amazon Bedrock Knowledge Bases and Amazon OpenSearch Serverless. After deployment, the support team notices that some answers are fluent and confident but factually incorrect or incomplete compared to the knowledge base contents.
The ML engineering team needs to determine whether the root cause is:
- The retriever failing to surface the correct passages from OpenSearch.
- The LLM generator failing to use the retrieved passages correctly.
Which TWO evaluation metrics should the team compute to isolate the cause? (Select TWO)
A) Context Recall — measuring whether the retrieved passages contain the facts necessary to answer the query correctly.
B) Faithfulness — measuring whether the generated response is factually consistent with the retrieved context passages.
C) ROUGE Score — measuring the n-gram overlap between the generated response and a reference answer from a stored dataset.
D) Token Count — measuring the number of tokens in the generated response as an indicator of answer quality.
E) Endpoint Latency — measuring the time from request to response to determine if retrieval is too slow.
Click to reveal Answer & Explanation
Correct Answers: A and B
Correct Options Analysis
- A is Correct: Context Recall evaluates the retrieval step in isolation by checking whether the retrieved passages contain all the facts needed to answer the query. A low Context Recall score indicates a retrieval failure.
- B is Correct: Faithfulness evaluates the generation step in isolation by checking whether the LLM's response is factually consistent with the context it was given. A low Faithfulness score indicates the LLM is hallucinating or ignoring the retrieved context.
Distractor Analysis
- C is Incorrect: ROUGE compares the generated response against a reference answer, not against the retrieved context. It measures end-to-end response quality but cannot isolate whether failures originate in retrieval or generation.
- D is Incorrect: Token count measures output length, not factual accuracy or completeness. A longer answer is not necessarily more correct or faithful to the source material.
- E is Incorrect: Endpoint latency measures operational performance—how fast the system responds—but does not indicate whether the retrieved content or generated response is semantically correct or factually grounded.
Key Takeaway: In RAG systems, always evaluate retrieval separately from generation. Context Recall = "did the retriever find the right stuff?" Faithfulness = "did the LLM use the right stuff correctly?"
Question 9 - Model Output Explanations for Auditors vs. Stakeholders
A healthcare insurance company uses an ML model to flag claims for manual review. The model outputs a risk score (0–1) and the company must provide explanations to two audiences:
- Healthcare auditors who need to understand, for any given flagged claim, which specific input features most influenced the risk score.
- Executive stakeholders who want a monthly report showing which input features are generally most impactful across all predictions.
The company is evaluating explanation approaches. Which TWO statements accurately describe the appropriate explanation strategy? (Select TWO)
A) For individual claim explanations, generate local feature attributions using Amazon SageMaker Clarify online mode, which shows per-prediction feature importance.
B) For the monthly executive report, compute global feature importance using an offline SageMaker Clarify job to aggregate SHAP values across the evaluation dataset.
C) For individual claim explanations, provide the raw model logits and activation values, which are easily interpretable by auditors.
D) For the executive report, use Amazon CloudWatch to display a time-series graph of the model's prediction scores over the month.
E) For both audiences, simply provide the model's F1 score and accuracy metrics from the latest evaluation run—these are sufficient for all explanation needs.
Click to reveal Answer & Explanation
Correct Answers: A and B
Correct Options Analysis
- A is Correct: Local feature attributions (SHAP or similar) are computed per-prediction. SageMaker Clarify's online mode attaches to a deployed endpoint and generates real-time explanations for each inference request, showing which features contributed most to that specific prediction.
- B is Correct: Global feature importance aggregates feature attribution across many predictions. SageMaker Clarify's offline mode computes global SHAP values over a dataset, producing a ranked list of overall feature importance suitable for executive reporting.
Distractor Analysis
- C is Incorrect: Raw logits and activation values are not interpretable to healthcare auditors. Auditors need human-readable feature attribution (e.g., "claim amount contributed 0.42 to the risk score"), not intermediate neural network outputs.
- D is Incorrect: A CloudWatch time-series of prediction scores shows what the model predicted over time, but not which features influenced those predictions. This does not satisfy the executive requirement for feature importance reporting.
- E is Incorrect: F1 score and accuracy are aggregate performance metrics that indicate how well the model performs, not why individual predictions were made or which features matter. They do not provide explainability.
Key Takeaway: Global explainability = which features matter overall (for reports/dashboards). Local explainability = which features matter for a specific prediction (for individual cases). SageMaker Clarify provides both.
Question 10 - Bedrock Prompt Management for Reproducible Prompt Evaluation
A startup building a conversational AI assistant using Amazon Bedrock has observed that small wording changes in their prompts significantly affect the quality of generated responses. Different team members have been modifying prompts informally, causing unreproducible results.
The team needs to:
- Store prompts with version history so changes are tracked.
- Compare two versions of a prompt systematically against the same evaluation dataset.
- Understand which version produced better quality responses before promoting it to production.
Which ONE approach satisfies these requirements with minimal operational overhead?
A) Store prompts in Amazon Bedrock Prompt Management, create versions, and use Amazon Bedrock Evaluations to compare responses from different prompt variants against a shared dataset.
B) Store prompt templates in an Amazon S3 bucket, track changes with Git, and build a custom evaluation script using AWS Lambda to compare responses.
C) Embed prompts directly in the application code and use Amazon CloudWatch Logs to review the prompt text each time it is executed.
D) Store prompts in Amazon DynamoDB and implement manual evaluation by having team members read and rate responses in a shared spreadsheet.
E) Use Amazon CodeGuru to review and optimize prompt code automatically, eliminating the need for version tracking.
Click to reveal Answer & Explanation
Correct Answer: A
Correct Options Analysis
- A is Correct: Amazon Bedrock Prompt Management natively supports prompt storage with versioning, template variables, and side-by-side variant comparison. Bedrock Evaluations can then run the same evaluation dataset through different prompt versions to compute quality metrics, making prompt changes reproducible and measurable.
Distractor Analysis
- B is Incorrect: While storing prompts in S3 with Git provides version control, building a custom Lambda-based evaluation script introduces unnecessary operational overhead compared to Bedrock Prompt Management's built-in versioning and comparison features.
- C is Incorrect: Embedding prompts in application code makes them resistant to systematic version tracking (especially across deployments), and CloudWatch Logs only records what was executed—it does not provide structured version comparison or evaluation.
- D is Incorrect: DynamoDB storage still requires building a custom comparison and evaluation framework. Manual spreadsheet-based rating is not a scalable or reproducible evaluation strategy.
- E is Incorrect: Amazon CodeGuru is a code review and security analysis service for software development—it does not manage or evaluate prompt versions for generative AI applications.
Key Takeaway: Prompt Management + Bedrock Evaluations = reproducible prompt experiments. Track prompt versions systematically and evaluate them against the same dataset to make wording changes measurable.