Skill 2.3.4: Explain model outputs
| Question | Answer & Explanation |
|---|---|
| ### Question 1 - Explaining Traditional ML Predictions A financial services company is using an XGBoost model deployed on Amazon SageMaker AI to predict loan defaults. Regulatory compliance mandates that the bank must be able to explain to an auditor exactly why a specific customer's loan application was rejected, based on the input features provided. The solution must provide per-instance feature attribution with the least operational overhead. Which approach should the ML engineer use to fulfill this requirement? (Select ONE) - A) Compute the global feature importance of the XGBoost model using the built-in tree summary and provide it to the auditor. - B) Use Amazon SageMaker Clarify to generate SHAP values for the specific customer's inference request to show how each feature contributed to the rejection. - C) Run an A/B test deploying a shadow variant against the production model to compare feature distributions. - D) Deploy a SageMaker Debugger hook to capture the gradients during the inference request and log them to Amazon S3. |
Correct Answer: B Correct Answer Analysis: - B is Correct: SageMaker Clarify uses SHAP (SHapley Additive exPlanations) to provide per-instance feature attribution. This allows the engineer to explain exactly how much each input feature (e.g., credit score, income) contributed to the specific prediction for an individual customer, satisfying the auditor's requirement with managed AWS tooling. Distractor Analysis: - A is Incorrect: Global feature importance only tells which features are important across the entire dataset on average, not why a specific local prediction was made for a single customer. - C is Incorrect: A/B testing or shadow testing is used to evaluate and compare the performance of two model variants against live traffic, not to explain the output of a specific prediction. - D is Incorrect: SageMaker Debugger is used to debug training issues (like convergence or gradients) during model training, not to explain inference outputs on deployed models. Exam Tip / AWS Best Practice: Use SageMaker Clarify and SHAP values for local, per-instance explainability to answer "why did this specific prediction happen?" for stakeholders and regulators. |
| ### Question 2 - RAG vs Fine-Tuned Model Explainability A healthcare technology company is building an AI assistant to answer doctors' queries about patient symptoms. The engineering team is deciding between fine-tuning a foundation model on historical medical records versus implementing a Retrieval-Augmented Generation (RAG) architecture using Amazon Bedrock Knowledge Bases. The compliance team mandates that the AI's response must clearly indicate the exact source medical literature used to formulate the answer. The solution must use native AWS services and minimize custom code. Which approach should the team choose to meet the explainability requirement? (Select ONE) - A) Fine-tune an Amazon Titan model using Amazon SageMaker JumpStart, and generate a SageMaker Model Card to explain the training data. - B) Use Amazon Bedrock Knowledge Bases to retrieve relevant medical text chunks and generate a response that natively includes source citations pointing to the retrieved passages. - C) Deploy a custom Hugging Face model on SageMaker endpoints and use SageMaker Clarify to compute token-level SHAP values for the generated response. - D) Use Amazon Comprehend Medical to extract medical entities, and ask a fine-tuned LLM to infer where it learned the information. |
Correct Answer: B Correct Answer Analysis: - B is Correct: A retrieval approach (RAG) using Amazon Bedrock Knowledge Bases can point directly to its source. It natively returns the retrieved passages alongside the generated response, providing built-in source attribution that satisfies the explainability and compliance requirement with minimal operational overhead. Distractor Analysis: - A is Incorrect: A customized (fine-tuned) model cannot point at the specific source document for a given output. A model card only documents the overall training dataset and model characteristics, not the source of individual generated facts. - C is Incorrect: While token-level SHAP can explain which input tokens influenced an output, it does not provide factual source citations to external medical literature. It also requires custom code and high operational overhead. - D is Incorrect: Amazon Comprehend Medical extracts entities from text but does not generate answers or provide attribution for a generative model's output. Exam Tip / AWS Best Practice: A retrieval approach (RAG) can point at its source (citations), whereas a customized (fine-tuned) model cannot inherently explain where it learned a specific fact. |
| ### Question 3 - Evaluation vs. Explanation A data science team presents a report to business stakeholders about a newly deployed fraud detection model. The stakeholders ask: "Why did the model output a 90% fraud probability for this specific transaction?" The data science team currently has a dashboard displaying the overall F1 score, ROC-AUC, and a confusion matrix of the model. The stakeholders require a direct answer to their specific question. Which action should the ML engineer take to provide the required information? (Select ONE) - A) Provide the global ROC-AUC score to prove the model is highly accurate overall. - B) Generate a SHAP explanation for the specific transaction's prediction to show how individual features shifted the probability to 90%. - C) Show the confusion matrix to demonstrate that the model has a low false-positive rate. - D) Set up a shadow test to see how a previous model would have scored the transaction. |
Correct Answer: B Correct Answer Analysis: - B is Correct: A score (like F1 or AUC) says how well the system did overall, but an explanation says why this particular answer came out the way it did. Generating a SHAP explanation for the specific instance provides the local feature attributions that answer the stakeholder's question directly. Distractor Analysis: - A is Incorrect: The ROC-AUC score is an evaluation metric representing model performance across all predictions, not an explanation for a single prediction. - C is Incorrect: A confusion matrix aggregates evaluation results across a dataset; it does not explain the driving factors behind a single transaction's probability score. - D is Incorrect: Shadow testing is used to compare a candidate model against a production model using live traffic. It does not explain the internal feature contributions of a specific prediction. Exam Tip / AWS Best Practice: Do not confuse evaluation (measuring performance with metrics like accuracy or BLEU) with explanation (identifying the inputs that caused a specific output). |
| ### Question 4 - NLP Text Classification Explainability A marketing team is using a transformer-based model deployed on Amazon SageMaker AI to classify customer reviews as positive, neutral, or negative. After a misclassification incident where a negative review was labeled as positive, the engineering team needs to explain to the marketing lead which specific words in the review contributed most to the incorrect "positive" classification. The solution must use an appropriate explainability technique for NLP. Which approach should the team use? (Select ONE) - A) Compute the BLEU score of the review against a reference positive review. - B) Use SageMaker Clarify to generate token-level explainability (such as SHAP or Integrated Gradients) to show the contribution of each word. - C) Calculate the ROUGE-L score to measure the lexical overlap with known positive reviews. - D) Deploy an A/B test to compare the current transformer model against a baseline logistic regression model. |
Correct Answer: B Correct Answer Analysis: - B is Correct: SageMaker Clarify supports explainability for computer vision and NLP tasks. For text classification, it can use techniques like SHAP or Integrated Gradients to provide token-level feature attributions, showing exactly which words in the input sequence drove the model's classification decision. Distractor Analysis: - A is Incorrect: BLEU is an evaluation metric for machine translation, measuring n-gram overlap with reference text. It does not explain model predictions. - C is Incorrect: ROUGE is an evaluation metric for text summarization, measuring recall of n-grams. It does not provide token-level explainability for classification models. - D is Incorrect: A/B testing compares the performance of two models against live traffic; it does not provide explainability for the internal token contributions of a specific misclassification. Exam Tip / AWS Best Practice: For NLP and CV models, SageMaker Clarify provides local explainability at the token or pixel level to understand which parts of the input drove the prediction. |
| ### Question 5 - Asynchronous Explainability for Batch Predictions A retail company runs a daily batch job using Amazon SageMaker AI Batch Transform to predict customer lifetime value (CLV). The legal department requires that each prediction in the batch output file must include a breakdown of the top three contributing features for that specific customer's prediction. The team must generate these explanations without modifying the existing inference container code. The solution must use the least operational overhead. Which AWS service should the team use to achieve this? (Select ONE) - A) Amazon SageMaker Clarify - B) Amazon SageMaker Debugger - C) Amazon Bedrock Evaluations - D) Amazon CloudWatch Logs Insights |
Correct Answer: A Correct Answer Analysis: - A is Correct: SageMaker Clarify can be run as an asynchronous processing job to analyze datasets and generate SHAP values for model predictions. It can be configured to output the top contributing features for each instance without requiring modifications to the original model's inference container code. Distractor Analysis: - B is Incorrect: SageMaker Debugger is used to debug training jobs in real-time (e.g., monitoring gradients, tensors, and loss), not to generate post-hoc explanations for batch inference outputs. - C is Incorrect: Amazon Bedrock Evaluations is used to evaluate the performance of foundation models and RAG systems (e.g., using LLM-as-a-judge or human raters), not for explaining traditional ML batch predictions. - D is Incorrect: CloudWatch Logs Insights queries log data but does not compute mathematical feature attributions like SHAP values. Exam Tip / AWS Best Practice: Use SageMaker Clarify Processing jobs to generate SHAP feature attributions asynchronously for batch datasets when you cannot modify the model's inference container. |
| ### Question 6 - Explaining LLM Outputs via Prompt Engineering A legal firm uses an Amazon Bedrock LLM (Anthropic Claude) to generate summaries of complex legal contracts. The legal team wants the model to explain its reasoning alongside the summary so that lawyers can trace how the model arrived at its conclusions. The solution must use the simplest method to make the model explain its output without altering the model weights or using complex post-hoc explainability libraries. Which approach should the firm implement? (Select ONE) - A) Fine-tune the Claude model with historical legal summaries and model cards. - B) Use a chain-of-thought (CoT) prompt template in Amazon Bedrock, instructing the model to output its step-by-step reasoning before the final summary. - C) Deploy the model on a SageMaker endpoint and use SageMaker Clarify to compute token-level SHAP values for the prompt and response. - D) Implement a shadow test on the Bedrock endpoint to compare the generated summary with a human-generated summary. |
Correct Answer: B Correct Answer Analysis: - B is Correct: For generative AI and LLMs, a simple and effective way to explain the output is to instruct the model to show its work. Using chain-of-thought (CoT) prompting in Amazon Bedrock forces the model to generate its reasoning steps before arriving at the final answer, providing transparency without requiring post-hoc libraries. Distractor Analysis: - A is Incorrect: Fine-tuning a model alters its weights but does not inherently make it explain its reasoning for specific prompts. Model cards document training data, not individual inferences. - C is Incorrect: Computing token-level SHAP values for large language models is computationally expensive, highly complex, and not supported natively by SageMaker Clarify for models hosted on Bedrock. - D is Incorrect: Shadow testing compares model variants against live traffic; it does not explain the reasoning behind a specific generated summary. Exam Tip / AWS Best Practice: For LLMs, using prompt engineering techniques like chain-of-thought (CoT) to ask the model to "think out loud" is a practical way to provide reasoning and traceability for outputs. |
| ### Question 7 - Inherent Interpretability vs. Post-Hoc Explanation An insurance company needs to deploy a model to automatically approve or deny claims. The compliance department mandates that the model's decision-making process must be fully transparent and globally interpretable, rather than relying on a black-box model with post-hoc explanation libraries. The team must choose a modeling approach that natively explains its outputs and violates no compliance rules. Which modeling approach satisfies this requirement? (Select ONE) - A) Train a deep neural network and use SageMaker Clarify SHAP values to approximate feature importance. - B) Train a gradient-boosted tree (XGBoost) model and use LIME for local approximations. - C) Train a linear regression or decision tree model and extract the exact feature coefficients or decision paths. - D) Fine-tune a large language model and ask it to explain its decision in natural language. |
Correct Answer: C Correct Answer Analysis: - C is Correct: Linear regression and decision trees are inherently interpretable (white-box) models. Their decision processes can be exactly mapped by extracting feature coefficients or following the tree's decision paths, fulfilling the compliance requirement for full transparency without needing post-hoc approximations. Distractor Analysis: - A is Incorrect: Deep neural networks are black-box models. SHAP provides post-hoc approximations of feature importance, not full transparency of the internal decision process, which may violate strict compliance rules. - B is Incorrect: XGBoost is often considered a black-box model. LIME (Local Interpretable Model-agnostic Explanations) provides local approximations, not inherent global transparency. - D is Incorrect: LLMs are massive black-box models. Asking it to explain its decision in natural language does not guarantee factual accuracy of its internal state and does not constitute mathematically transparent decision-making. Exam Tip / AWS Best Practice: When compliance demands full transparency, use inherently interpretable models (like linear models or decision trees). Use post-hoc tools (Clarify, SHAP) only when forced to use black-box models. |
| ### Question 8 - Explaining RAG Outputs via Bedrock Knowledge Bases A software company is building a customer support chatbot using Amazon Bedrock Knowledge Bases. The support agent needs the chatbot to provide an answer to the user and also display the exact source documents that were used to generate that answer, so the user can click a link to verify the information. The solution must minimize operational overhead and custom code. Which feature of Amazon Bedrock Knowledge Bases should the developer utilize to meet this requirement? (Select ONE) - A) Use SageMaker Clarify to compute SHAP values for the retrieved context chunks. - B) Enable the returnRetrieveResults parameter in the Bedrock Knowledge Bases API response to return source citations natively.- C) Implement a custom AWS Lambda function to manually parse the OpenSearch Serverless logs and attach them to the LLM response. - D) Use Amazon Bedrock Guardrails to filter out any responses that do not natively include source URLs. |
Correct Answer: B Correct Answer Analysis: - B is Correct: Amazon Bedrock Knowledge Bases natively supports retrieving and returning the source passages alongside the generated response. By configuring the retrieval to return the source chunks (metadata and text), the chatbot can display the exact source citations to the user, fulfilling the explainability requirement with zero custom code. Distractor Analysis: - A is Incorrect: SageMaker Clarify and SHAP values are used for traditional ML feature attribution, not for providing document source citations in a RAG architecture. - C is Incorrect: Writing custom Lambda functions to parse OpenSearch logs introduces unnecessary operational overhead and complex custom code, whereas Bedrock provides this natively. - D is Incorrect: Bedrock Guardrails are used for content filtering, PII redaction, and safety, not for generating or ensuring the presence of source document citations. Exam Tip / AWS Best Practice: Leverage Amazon Bedrock Knowledge Bases' native ability to return retrieved source chunks to provide citations and explain where a generated response originated. |
| ### Question 9 - Explaining Computer Vision Model Outputs An autonomous vehicle startup has deployed an image classification model on Amazon SageMaker AI to detect stop signs in real-time. After a misclassification incident where a stop sign was not detected, the engineering team needs to explain to the safety board which specific pixels in the image led the model to ignore the stop sign. The solution must use an appropriate AWS tool for computer vision explainability. Which technique should the team use? (Select ONE) - A) Compute the BERTScore between the input image and the training dataset. - B) Use SageMaker Clarify to generate computer vision explainability outputs (such as Grad-CAM or Integrated Gradients) highlighting pixel importance. - C) Run a SageMaker Debugger hook to capture the loss function during inference. - D) Generate a confusion matrix of all object classes evaluated by the model. |
Correct Answer: B Correct Answer Analysis: - B is Correct: SageMaker Clarify supports explainability for computer vision models. It can generate visual explanations (like saliency maps using Grad-CAM or Integrated Gradients) that highlight which pixels in an image contributed most to the model's prediction, answering why the stop sign was ignored. Distractor Analysis: - A is Incorrect: BERTScore is an NLP evaluation metric based on embeddings; it cannot be used for image data or computer vision explainability. - C is Incorrect: SageMaker Debugger monitors training metrics and tensors (like gradients or weights) during the training phase, not pixel attributions during inference. - D is Incorrect: A confusion matrix is an evaluation tool that aggregates correct and incorrect predictions across classes; it does not provide local pixel-level explanations for a single misclassification. Exam Tip / AWS Best Practice: For computer vision models, use SageMaker Clarify to generate saliency maps or pixel-level attributions to visually explain which parts of an image influenced the model's output. |
| ### Question 10 - SageMaker Model Cards for Documentation A machine learning team is preparing to deploy a credit scoring model for a bank. The bank's internal audit team requires comprehensive documentation that explains the model's intended use, training data, evaluation metrics, and overall performance to ensure compliance with fair lending laws. The team wants to create a single, centralized report that brings together this explainability and evaluation information with the least operational overhead. Which AWS service should the team use to automatically generate this documentation? (Select ONE) - A) Amazon Bedrock Evaluations - B) Amazon SageMaker Model Cards - C) AWS Artifact - D) Amazon SageMaker Model Monitor |
Correct Answer: B Correct Answer Analysis: - B is Correct: Amazon SageMaker Model Cards is a feature that allows data scientists to create centralized, immutable documentation for their models. It captures details about the model's intended use, training dataset, evaluation results, and performance, satisfying the audit and compliance requirements natively within SageMaker. Distractor Analysis: - A is Incorrect: Amazon Bedrock Evaluations is used to run evaluation jobs (programmatic, LLM-as-a-judge, or human) on foundation models and prompts, not to generate compliance documentation for traditional ML models. - C is Incorrect: AWS Artifact is a service for on-demand access to AWS security and compliance reports (like SOC 2 or ISO 27001), not for documenting a specific custom ML model. - D is Incorrect: SageMaker Model Monitor is used to detect data drift and model quality degradation in production; it does not generate static compliance documentation like Model Cards. Exam Tip / AWS Best Practice: Use Amazon SageMaker Model Cards to provide a single source of truth for model documentation, explaining its purpose, data, and performance to auditors and regulators. |