18.4 Model Explainability on Agent Platform
Key Takeaways
- Feature-based explanations on Agent Platform are configured when a model is uploaded or registered, using sampled Shapley, integrated gradients, or XRAI with an explanation specification and metadata.
- Sampled Shapley path count ranges from 1 to 50 (Google suggests 25 if unsure), and integrated gradients step count ranges from 1 to 100 (suggested 50).
- Google suggests adjusting the explanation configuration when the returned approximationError exceeds 0.05.
- Vertex Explainable AI was deprecated on March 16, 2026 and is scheduled to shut down on March 16, 2027, with SHAP and LIME suggested as open-source alternatives.
- Online explanations use the endpoint's explain method, and batch inference can return attributions when generateExplanation is enabled on an explanation-configured model.
The exam guide lists model explainability on Agent Platform (for example, Agent Platform Inference). Section 8.3 covered choosing interpretable techniques. This section covers producing explanations from deployed models and doing it reliably.
Lifecycle Status First
Vertex Explainable AI was deprecated on March 16, 2026. No new features are being added, and the APIs are scheduled to be fully shut down on March 16, 2027. Google suggests open-source libraries such as SHAP (SHapley Additive exPlanations) and LIME (Local Interpretable Model-agnostic Explanations) as alternatives. Know how the built-in feature works, since it's still documented and may appear in scenarios, and plan migrations for long-lived systems.
Feature-Based Explanations
Feature attributions show how much each input feature moved a prediction relative to a baseline. Methods (all Shapley-based):
| Method | Use for | Key parameter |
|---|---|---|
| Sampled Shapley | Non-differentiable models such as tree ensembles, AutoML tabular, and custom models in any container | Path count 1-50. Google suggests 25 if unsure |
| Integrated gradients | Differentiable models (neural networks), large feature spaces, low-contrast images | Step count 1-100. Google suggests 50 |
| XRAI | Region-level saliency for natural images | Step count (builds on integrated gradients) |
Configuring explanations
Explanations are configured when you upload or register the model in Model Registry:
- ExplanationSpec parameters: the method and its path count or step count.
- ExplanationMetadata: the model's input and output names (for TensorFlow models) and optional input baselines. If you don't set baselines, Agent Platform chooses them.
AutoML tabular (classification and regression) and AutoML image classification models have attributions built into the console. BigQuery ML models registered in Model Registry can also be configured for feature-based explanations.
Requesting explanations
| Mode | How |
|---|---|
| Online | Call the endpoint's explain method. It returns predictions plus attributions per instance |
| Batch | Set generateExplanation on a batch inference job for a model configured for explanations, or supply an explanation spec on the job |
Explanation requests add compute and latency. Use them for sampled traffic, audits, or user-facing reason codes rather than every high-volume request unless required.
Endpoint note: AutoML models and explainability are supported on shared public endpoints, not dedicated or private endpoint types (Chapter 14).
Making Explanations Reliable
Attribution methods approximate Shapley values, and each attribution returns an approximationError. If it exceeds 0.05, adjust the configuration:
- Increase the path count (sampled Shapley) or step count (integrated gradients, XRAI).
- Change baselines. Tabular baselines can be median, minimum, maximum, or random values. Image baselines can be black, white, gray, or random images.
- Add baselines. Two baselines (for example, minimum and maximum, or black and white images) often help. Extra baselines add latency for integrated gradients and XRAI, but not for sampled Shapley.
Sanity checks: attributions should roughly sum to the difference between the prediction and the baseline prediction. Top features should make domain sense, and surprising drivers, such as a record ID, point to leakage or bugs.
Example-Based Explanations
Example-based explanations return the most similar training examples by nearest-neighbor search over model embeddings. Uses:
- Debug mistakes: a bird misclassified as a plane whose neighbors are all plane silhouettes suggests you need more bird silhouettes.
- Detect outliers: inputs far from all training data.
- Active learning: pick ambiguous examples for labeling.
They support TensorFlow models that produce embeddings, not tree-based models.
Explanations in Monitoring
Feature attribution drift watches whether the features driving predictions change over time, even when input distributions look stable (Chapter 19). A rising attribution for a feature that shouldn't matter is an early warning of skew, a broken upstream feature, or concept change.
Explainability Without the Deprecated Service
| Model | Alternative |
|---|---|
| BigQuery ML models | ML.EXPLAIN_PREDICT, ML.GLOBAL_EXPLAIN, ML.FEATURE_IMPORTANCE, ML.EXPLAIN_FORECAST (Chapter 8) |
| Tree models (XGBoost, LightGBM) | SHAP TreeExplainer (exact, fast) in batch jobs or a CPR postprocess() |
| Neural networks | SHAP gradient or deep explainers, or integrated gradients implemented in the framework |
| Any model, local explanations | LIME local surrogate models |
| Global model understanding | SHAP summary plots from batch jobs on validation data, stored with the model version |
Design pattern: compute explanations in a batch pipeline for audits and monitoring, and in the serving container only where per-request reason codes are required, caching where possible.
Worked Scenario
A credit card issuer's XGBoost model must return the top three reason codes with each decline. It's currently configured with sampled Shapley on Agent Platform, and the design must last beyond 2027.
- Short term: keep sampled Shapley with a path count of about 25. Check
approximationError, and raise the path count if it exceeds 0.05. - Migration: add SHAP TreeExplainer to the custom prediction routine's
postprocess()to produce reason codes, and compare them with current attributions on a validation set. - Monitoring: compute daily SHAP summaries in a batch pipeline and alert on attribution drift.
- Before March 16, 2027: switch production to the SHAP path.
An explanation for a tabular model returns an approximationError of 0.12. What should the team do first?
A bank plans a new credit model in 2026 that must provide feature attributions for at least five years. What should the architecture account for?
A team wants to understand why an image model misclassified certain birds as planes by viewing similar training images. Which explanation type fits?