# Workshop 8: Trust in AI - Transparency, Explainability, and Interpretability

> A model that cannot explain itself cannot be trusted, audited, or held accountable. This workshop separates three ideas that are often confused, transparency, interpretability, and explainability, surveys the methods that make black-box models legible, and confronts the uncomfortable finding that an explanation is not automatically trustworthy: explanations themselves can be attacked.

## Overview

As AI systems move into consequential settings, a correct prediction is no longer enough. Users, auditors, regulators, and the people affected by a decision increasingly need to know *why* a model produced the output it did. That need is what "trust in AI" is really about, and it rests on three related but distinct properties: transparency (how open and inspectable the system is), interpretability (how far a human can follow the model's own mechanism), and explainability (whether we can produce a faithful account of a specific decision after the fact). These terms are often used interchangeably; this workshop keeps them apart because they call for different techniques and offer different guarantees.

The session works through three connected questions. First, what does it mean to understand a model, and when does understanding come for free (intrinsically interpretable models) versus having to be reconstructed after training (post-hoc explanation)? Second, how do the dominant explanation methods actually work, LIME and SHAP for feature attribution, and gradient- and activation-based maps such as saliency, Class Activation Mapping, and Integrated Gradients for vision models? Third, and this is the workshop's distinctive point, how far can we trust an explanation? A central result of recent security research is that explanations are fragile and can be manipulated: tiny input changes can rewrite them, and an adversary can build a biased model that still produces innocuous-looking explanations. The hands-on lab makes the security angle concrete by implementing interpretation methods on an image classifier and using them to inspect adversarial inputs.

The framing throughout, echoing the guest lecture, is that explainability is a security property, not just a usability feature. An explanation you cannot verify is worth little, and explanation robustness belongs in the threat model alongside the robustness of the prediction itself.

**Prerequisites:** Complete [Workshop 1](../Workshop01/Introduction_and_Fundamentals_in_AI.md) first. This session also connects directly to the adversarial attacks of [Workshop 3](../Workshop03/Adversarial_Attacks_-_White-Box_Attacks.md): the same small, targeted perturbations that fool a classifier can be aimed at its explanations, so familiarity with adversarial examples will make the vulnerabilities discussed here concrete.

## Workshop Video

This session shares its recorded lecture with Workshop 11: the same video continues into the secure deployment and operation talk. Watch the recording below, then read the material below and work through the companion notebook.

<div class="video-embed">
  <iframe src="https://www.youtube.com/embed/1M7CZDINg1c" title="Workshop 8: Trust, Explainability, and Interpretability, guest lecture" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>

### Guest Speaker

<div style="margin-bottom: 40px; overflow: auto;">
  <img src="../assets/images/Eldor_Abdukhamidov.png" alt="Eldor Abdukhamidov" align="left" width="250" height="250" style="float: left; width: 250px; height: 250px; object-fit: cover; border-radius: 50%; margin: 10px 30px 10px 0;">
  <h4 style="margin-top: 0;">Eldor Abdukhamidov</h4>
  <p><strong>Sungkyunkwan University</strong> | South Korea</p>
  <p>Eldor Abdukhamidov received his B.S. from Inha University in Tashkent and pursued his Master's and Ph.D. degrees in Computer Science and Engineering at Sungkyunkwan University, South Korea. His research interests include image processing, machine learning, and information security. His guest lecture, "Weaknesses in Current Interpretation Methods of Deep Learning Systems," examines the vulnerabilities of the explanation techniques we trust and illustrates them through concrete attack examples.</p>
</div>

## Learning Objectives

After completing this workshop, you will be able to:

- Distinguish transparency, interpretability, and explainability, stating what each one describes and why they are not synonyms.
- Contrast intrinsically interpretable models (linear models, decision trees, rule lists) with post-hoc methods applied to black boxes, and explain the trade-off each represents.
- Explain how LIME produces a locally faithful, model-agnostic explanation by perturbing an input and fitting a sparse linear surrogate to the black box's responses.
- Explain how SHAP attributes a prediction to features using Shapley values, and state the properties (local accuracy, missingness, consistency) that make its attribution unique.
- Describe gradient- and activation-based explanation signals for neural networks, saliency maps, Class Activation Mapping, and Integrated Gradients, and note where each is faithful and where it misleads.
- Explain why explanations are not automatically trustworthy: that they can be unstable under tiny input changes, and that explanation methods themselves can be fooled by an adversary.
- Connect explanation attacks to the adversarial perturbations of Workshop 3, and argue why explanation robustness is a design requirement for trustworthy AI systems.

## Theoretical Background

### Three Words That Are Not Synonyms

Discussions of trustworthy AI move quickly between "transparent," "interpretable," and "explainable," and treating them as one idea causes real confusion. They describe different things.

**Transparency** is the degree to which a system's workings are open and inspectable. It is a property of the *process and its documentation* as much as of the model: what data was used, how the model was trained, what its known limitations are, who is accountable, and whether outsiders can examine any of this. A fully documented pipeline around an opaque model can still be transparent in this sense, even if the model's internal computation is not itself legible.

**Interpretability** is the extent to which a human can understand the model's *mechanism*, the actual mapping from inputs to outputs. It is often an intrinsic property of the model class. A linear model is interpretable because its coefficients directly state how each feature moves the prediction; a short decision tree is interpretable because you can read the decision path; a rule list is interpretable because the rules are the model. Interpretability is understanding *how the model works*.

**Explainability** is the ability to produce a faithful account of *why an otherwise opaque model made a particular decision*, usually after the fact. When the model is a deep network whose mechanism no human can follow directly, we reconstruct a post-hoc explanation, an attribution over features, a heatmap over pixels, that approximates the reason for a specific output. Explainability is understanding *why a decision was made*, without necessarily understanding the mechanism that made it.

The three are related, better transparency and interpretability generally make trustworthy explanation easier, but they are not equivalent, and a system can have one without the others.

### Intrinsic Interpretability vs. Post-hoc Explanation

There are two broad routes to a legible model, and the choice between them is one of the central design decisions in this area.

**Intrinsically interpretable models** are transparent by construction. Linear and logistic regression, decision trees, and rule lists can be read directly: the model *is* its own explanation. When the stakes are high and the data permits, preferring such a model is often the most defensible choice, because there is no gap between the explanation and the mechanism.

**Post-hoc methods** take an already-trained black box, a deep network, a gradient-boosted ensemble, and construct explanations around it. They are what make otherwise opaque, high-performing models usable in settings that demand accountability. The catch, which the rest of this workshop develops, is that a post-hoc explanation is an *approximation* of the model's reasoning, not the reasoning itself, and the quality and honesty of that approximation cannot be assumed.

The methods below fall into two families by *scope*: **local** methods explain a single prediction (why *this* input got *this* label), while **global** methods describe overall model behavior across a dataset.

### LIME: Local, Model-Agnostic Surrogates

LIME, Local Interpretable Model-agnostic Explanations (Ribeiro, Singh & Guestrin, 2016), explains one prediction at a time and treats the underlying model as a black box it can only query. To explain a single instance, LIME perturbs that input many times, feeds each perturbed version to the black box, records the outputs, and then fits a simple, interpretable surrogate, typically a sparse linear model, to those local input-output pairs, weighting each sample by how close it is to the original instance. The surrogate is not meant to be globally accurate; it only has to be *locally faithful*, capturing the black box's behavior in the neighborhood of the instance being explained.

Formally, LIME chooses the explanation $g$ that balances local fidelity against simplicity:

$$
\text{explanation}(x) = \arg\min_{g \in G} \; \mathcal{L}(f, g, \pi_x) + \Omega(g)
$$

where $f$ is the original model, $g$ is the interpretable surrogate drawn from a class $G$ (for example, sparse linear models), $\pi_x$ weights samples by proximity to $x$, $\mathcal{L}$ measures how unfaithful $g$ is to $f$ in that neighborhood, and $\Omega(g)$ penalizes complexity so the explanation stays readable. Because it only needs to query outputs, LIME works with any model and any modality, images, text, or tabular data. Its weaknesses follow from the same design: the explanation depends on how the perturbations are drawn, and two similar inputs can yield noticeably different explanations, a fragility that becomes a security problem later in this workshop.

### SHAP: Attribution with Game-Theoretic Guarantees

SHAP, SHapley Additive exPlanations (Lundberg & Lee, 2017), also attributes a prediction to its features, but grounds the attribution in cooperative game theory. Treat the features as players in a game whose payoff is the model's output; the **Shapley value** of a feature is its average marginal contribution across all possible orderings in which features are added to the coalition. SHAP assigns each feature its Shapley value, producing an *additive* explanation in which the feature contributions sum to the difference between the prediction and a baseline.

$$
\phi_i = \sum_{S \subseteq F \setminus \{i\}} \frac{|S|!\,(|F| - |S| - 1)!}{|F|!} \left[ f\big(S \cup \{i\}\big) - f(S) \right]
$$

Here $\phi_i$ is the attribution for feature $i$, $F$ is the full feature set, $S$ ranges over subsets that exclude $i$, and $f(S)$ is the model's output using only the features in $S$. What distinguishes SHAP is that Shapley values are the *unique* attribution satisfying three properties simultaneously: **local accuracy** (the attributions add up to the actual prediction), **missingness** (a feature that is absent gets zero credit), and **consistency** (if a model changes so that a feature contributes more, its attribution does not decrease). That uniqueness is SHAP's strength; its cost is computational, since exact Shapley values require evaluating exponentially many feature subsets, and practical implementations rely on approximations and a chosen background distribution.

### Explanation Signals for Neural Networks

For image models in particular, several methods explain a decision by pointing at the input regions responsible for it.

- **Saliency (gradient) maps** take the gradient of the class score with respect to the input pixels: pixels with large gradients are the ones whose change would most affect the score. They are fast and high-resolution, but often noisy and prone to saturation.
- **Class Activation Mapping (CAM)** produces a heatmap by combining the final convolutional feature maps with the classifier weights for a target class, localizing the regions that drove the prediction. It is intuitive and cheap but limited to architectures with global pooling.
- **Integrated Gradients** accumulates gradients along a straight path from a baseline input to the actual input, which satisfies a *completeness* axiom: the attributions sum exactly to the difference between the model's output on the input and on the baseline, so no contribution is lost or double-counted.
- **Attention weights** in transformer models are sometimes read as explanations, but attention is an imperfect signal: high attention does not reliably mean high importance, so it should be treated as suggestive rather than authoritative.

Every method in this section is an *approximation* of the model's reasoning. That gap between the explanation and the true mechanism is exactly what an adversary exploits.

### The Security Angle: Explanations Can Be Attacked

This is the part that sets a security-focused treatment of interpretability apart from a purely usability-focused one. It is tempting to treat an explanation as ground truth, if the heatmap highlights the dog's face, the model must be looking at the dog. That inference is not safe. Explanations have their own attack surface, and a growing body of work shows they can be manipulated independently of the prediction.

**Explanations are unstable.** Ghorbani, Abid & Zou (2019), "Interpretation of Neural Networks is Fragile," showed that a perturbation too small to change a network's prediction, or even to be perceptible, can nonetheless produce a completely different explanation. The feature-importance map is not a robust function of the input, so two visually identical images can be assigned very different "reasons," which undermines any auditor who relies on the map's stability.

**Explanation methods can be fooled by design.** Slack, Hilgard, Jia, Singh & Lakkaraju (2020), "Fooling LIME and SHAP," went further: an adversary can *construct* a model that is blatantly biased on real inputs yet returns innocuous, unbiased-looking explanations from LIME and SHAP. The trick exploits the very mechanism these methods depend on, they probe the model with *perturbed, out-of-distribution* samples. The adversarial model learns to detect whether an input is a genuine instance or one of these synthetic probes, behaving discriminatorily on real data while switching to a benign surrogate whenever it senses it is being explained. The explanation looks clean precisely because the model games the explainer. Manipulated saliency maps are the visual analogue: an image can be perturbed so the model is fooled while its saliency map still looks perfectly reasonable, so the explanation reassures the user about a decision that is in fact compromised.

The lesson is blunt: **an explanation is not automatically trustworthy.** These attacks are close cousins of the adversarial perturbations from [Workshop 3](../Workshop03/Adversarial_Attacks_-_White-Box_Attacks.md), small, targeted input changes exploiting the sensitivity of a learned function, aimed here at the explanation rather than (or in addition to) the label. Explanation *robustness*, the stability and faithfulness of an explanation under adversarial pressure, therefore belongs in the threat model, and it should be tested rather than assumed.

### Trust as a System Property

Because explanations can be gamed, trust in an AI system cannot rest on explanation alone; it is a property of the whole sociotechnical system. Several dimensions matter together:

- **User acceptance:** people adopt a system they believe behaves safely and can be questioned, and explanations tailored to the audience support that belief, when the explanations are faithful.
- **Organizational adoption:** institutions need assurance that a system meets operational and compliance standards, which increasingly requires documented, auditable explanations.
- **Accountability:** clear ownership of decisions and their consequences, which transparency and honest explanation make possible.
- **Transparency by design:** building interpretability and documentation in from the start, preferring intrinsically interpretable models where they suffice, and validating explanations for fidelity and robustness rather than shipping them as unverified reassurance.

These themes connect the workshop outward: the fairness auditing of [Workshop 7](../Workshop07/Ethics_in_AI_-_Bias_and_Fairness.md) depends on the explanation tools introduced here, and the accountability such tools enable is exactly what the regulation and standards of Workshop 10 increasingly require.

## Hands-on Lab

The activity is implemented in **PyTorch** with **torchvision**, using a pre-trained **ResNet-18** classifier on **ImageNet** images, and image handling via OpenCV, scikit-image, PIL, NumPy, and Matplotlib. Rather than calling a packaged explainer, the notebook builds the interpretation methods from first principles: it implements **Class Activation Mapping (CAM)** by registering a forward hook on the last convolutional block and combining the captured feature maps with the classifier weights, and it implements **Integrated Gradients** by accumulating gradients along a path from a baseline to the input. It then turns these tools toward security, using CAM to inspect adversarial inputs and show how interpretation exposes the "focus displacement" a successful attack produces. The notebook also includes a taxonomy that situates LIME, SHAP, Grad-CAM, saliency maps, and attention against CAM and Integrated Gradients, so the conceptual methods from the theory section are mapped onto what the code actually runs.

### Activity 01: Model Interpreters

Generate and compare local explanations for an image classifier's predictions, implementing CAM and Integrated Gradients on a pre-trained ResNet-18, then use the resulting heatmaps to examine how an adversarial input shifts the model's apparent focus.

- Open on GitHub: [SecAI_Workshop08_Activity01_Interpreters.ipynb](https://github.com/SecureAI-luc/SecureAI-Lab/blob/main/Workshop08/SecAI_Workshop08_Activity01_Interpreters.ipynb) | Open in Colab: [SecAI_Workshop08_Activity01_Interpreters.ipynb](https://colab.research.google.com/github/SecureAI-luc/SecureAI-Lab/blob/main/Workshop08/SecAI_Workshop08_Activity01_Interpreters.ipynb?authuser=1)

To run the activity, open its Colab link and use **File → Save a copy in Drive** to get your own editable copy, then execute it there.

<div class="video-embed">
  <iframe src="https://www.youtube.com/embed/zZne4pUp9S8" title="Workshop 8: Trust and Transparency in AI, lab walkthrough" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>

## Key Takeaways

- Transparency, interpretability, and explainability are distinct: transparency is openness of the system and its documentation, interpretability is understanding the model's mechanism (often intrinsic), and explainability is a faithful post-hoc account of a specific decision. They are related but not synonyms.
- Intrinsically interpretable models (linear, tree, rule-based) explain themselves; post-hoc methods reconstruct explanations around a black box and are only approximations of its reasoning.
- LIME explains one prediction by perturbing the input and fitting a locally faithful, sparse linear surrogate to the black box's responses; it is model-agnostic but sensitive to how perturbations are drawn.
- SHAP attributes a prediction using Shapley values, the unique additive attribution satisfying local accuracy, missingness, and consistency, at a high computational cost.
- Saliency maps, CAM, and Integrated Gradients explain vision models via gradients and activations; each is useful but imperfect, and attention weights are only a weak proxy for importance.
- Explanations can be attacked. They are unstable under tiny, prediction-preserving perturbations (Ghorbani et al. 2019), and methods like LIME and SHAP can be deliberately fooled by a model that detects their out-of-distribution probes (Slack et al. 2020). An explanation is not automatically trustworthy.
- Explanation robustness belongs in the threat model, alongside the adversarial robustness of Workshop 3. Trust is a system property built from faithful, auditable explanations plus transparency by design, not from explanations taken on faith.

## Additional Resources

- **Ribeiro, Singh & Guestrin (2016), "Why Should I Trust You? Explaining the Predictions of Any Classifier" (LIME):** [arXiv:1602.04938](https://arxiv.org/abs/1602.04938) - introduces LIME's local, model-agnostic surrogate explanations.
- **Lundberg & Lee (2017), "A Unified Approach to Interpreting Model Predictions" (SHAP):** [arXiv:1705.07874](https://arxiv.org/abs/1705.07874) - the Shapley-value framework for additive feature attribution.
- **Slack, Hilgard, Jia, Singh & Lakkaraju (2020), "Fooling LIME and SHAP: Adversarial Attacks on Post hoc Explanation Methods":** [arXiv:1911.02508](https://arxiv.org/abs/1911.02508) - shows how a biased model can hide behind innocuous LIME/SHAP explanations by exploiting their perturbation sampling.
- **Ghorbani, Abid & Zou (2019), "Interpretation of Neural Networks is Fragile":** [arXiv:1710.10547](https://arxiv.org/abs/1710.10547) - demonstrates that tiny, prediction-preserving perturbations can drastically change an explanation.
- **Sundararajan, Taly & Yan (2017), "Axiomatic Attribution for Deep Networks" (Integrated Gradients):** [arXiv:1703.01365](https://arxiv.org/abs/1703.01365) - the attribution method implemented in the lab, with its completeness axiom.
- **Zhou, Khosla, Lapedriza, Oliva & Torralba (2016), "Learning Deep Features for Discriminative Localization" (CAM):** [arXiv:1512.04150](https://arxiv.org/abs/1512.04150) - the Class Activation Mapping method the lab implements.
- **PyTorch and torchvision:** [pytorch.org](https://pytorch.org) - the deep-learning framework and pre-trained ResNet-18 model the lab uses.
- **[Program Resource Library](../resources.md)** - shared papers, tools, and datasets for the full workshop series.

## Next Steps

Continue to [Workshop 9: AI Development and Security](../Workshop09/AI_Development_and_Security.md), which turns from understanding and trusting individual model decisions to securing the development lifecycle that produces and deploys those models.
