Model Explainability
The focus here is not on agents that explain themselves. Instead, the focus will be on: 1. Models that are intrinsically explainable, 2. Techniques to make the model's outputs or internals meaningful beyond the mathematical operation, 3. Use Language Models to translate model's behaviour / output to a linguistic explanation.
Explanations were defined and characterised in a previous post.
Explainable AI (XAI) is primarily about explaining the model and its output, although it may include other aspects. Model explainability can be defined as:
The degree to which we can answer questions about the model and its output. The answers are audience and context dependent. The audience, in some cases, may be ourselves.
Some systems may require that we, as operators, understand the decisions (explain to ourselves), or that the system can be explained by an expert to an audience.
As noted in the previous post, the "questions" may be implicit; and it's common that the question, implicit or explicit is a contrastive why-question.
Model explainability includes terms like interpretability and transparency (which look inside the model) but also methods to analyse black-box models. Here is one possible classification:
- Intrinsic vs Extrinsic
- Intrinsic or Transparency: looks at the internal mechanics and roles of layers, neurons, weights; also at the complexity of the model, training process, and so forth.
- Extrinsic or Post Hoc (aka opaque or black box): looks at input-outputs relations.
- Global (valid for all inputs) vs local (for specific inputs)
Note
Explaining and understanding can be mixed up, because the latter also involves some internal conversation or reflection. Here understanding, with or without that monologue, is equated to the cognitive process, prior to any communication. However, it certainly seems more complex.
Trade-offs
In deep learning practice, tradeoffs abound. For example, explainability tends to be harder with more accurate models, since they tend to be more complex.
Moreover, simple explanations can oversimplify its operation, or lack generality.
Explaining by Comparison
This framework is explained separately from methods to expand a bit more, but some of the methods are based on this logic behind.
Will it rain today?
Let's take an imaginary model, , the variable being the proportion of people with an umbrella, the model and the probability of rain.
It reaches low evaluation error and everyone is happy.
However, it is sometimes found that if the people don't take the umbrella it may still rain. Why? There may be different reasons:
- The model is doing correlation / association, but there wasn't correlation data available for such an event, so the predictions bad;
- With a large and diverse possible dataset, most questions may be answerable; but may not generalise out of distribution, restricting discoveries to certain interpolations.
- This is useful and discoveries have been made this way, but it clearly limits them to interpolation, and low success out of distribution.
- The model does not use causal information, like a weather forecast model would (not taking an umbrella doesn't make raining impossible).
- Using causal models may help to overcome the problems highlighted in the previous point. It's a bit like turning it into a law or theory expected to have found some deep structure that generates the data, even the unseen data.
The model is then modified to use causal variables instead (such as pressure and temperature), implicitly turning it into a causal model. But does it have all the causal inputs?
An expert may pick known causes-effects pairs as inputs-outputs to train a model, but others may unknowingly build a correlation model instead.
A subset of causal-variables may do for a good-enough approximation, and likely be robust for generalising out of distribution. In some cases though, it may be enough to have a correlation model, but they should be distinguished.
What if...?
A model that does correlation is more likely to fail out of distribution, because it has not learnt the correlation. Causal models should in principle have less of this issue.
Counterfactuals ask What would happen if this other input (fact) was used instead of the former one, or if one feature is changed slightly? They are also similar to What ifs (as the question shows).
For a model, counterfactuals yet another prediction, but the question is helpful because that is one way humans explain things. In a similar fashion to counterfactuals, we can compare with reference inputs.
Both of these are known techniques listed in the next section.
Higher-Level Aspects of Networks
The recognition of higher level patterns in graph can also span across methods.
These can even be inspired by other networks or graphs; for example, insect colonies can be considered as graphs of insect-nodes and pheromone-edges, and certain nodes have roles and tasks they specialise on. A similar situation can be postulated to happen in human networks, and in neural (biological and artificial) networks, where the node is affected by, and also affects other nodes.
A basic description of graph and networks and how there can be transfer learning between the different areas can be found in [Siemens - Connectivism][connectivism_siemens] and particularly in [Downes - Connectivism][connectivism_downes].
Overview of methods
Within the cognitive process of explanations, model explainability benefits from methods to identify causes or relevant properties.
For all audiences, we can group these methods into more general categories, and then go into specific cases for a certain audience.
Kinds of Methods
The survey Principles and practise of explaining ML models includes a table of method kinds. A modified version of the table is below:
| Kind | Advantages | Disadvantages | Question |
|---|---|---|---|
| Local explanations | Explains the model's behaviour in a local area of interest. Operates on instance-level explanations. | Explanations do not generalize on a global scale. Small perturbations might result in very different explanations. | How do small perturbations affect the output / prediction? |
| Examples | Representative items for each class provide insights about the model's internal reasoning. | Examples require human selection. They do not explicitly state what parts of the example influence the model. | How do inputs from different classes compare? And same? |
| Feature relevance | They operate on an instance level (some can operate globally). | Methods may make assumptions which do not hold (e.g. feature independence, linearity). | Which input features are most important? |
| Simplification | Simple surrogate models explain opaque ones. | Surrogate models may not approximate original models well. | Can we get local insights by using a simpler model? |
| Visualizations | Easier to communicate to non-technical audiences. Most approaches are intuitive and not hard to implement. | There is an upper bound on how many features can be considered at once. Humans must inspect plots to derive explanations. | Class boundaries? |
A method not listed there are text explanations, which can be generated from an RNN or a language model, reading the model's internal state (for example, this can generate captions).
We should remember that:
Relying on only one technique will only give us a partial picture of the whole story, possibly missing out important information. Hence, combining multiple approaches together provides for a more cautious way to explain a model. (...) At this point we would like to note that there is no established way of combining techniques (in a pipeline fashion),
In the next posts, we focus on methods that aid causal attribution (or cognitive process) with a scientific audience in mind.
Map of XAI
An interesting map of XAI is given in the survey Principles and practice of explainable ML (2021).
Most classic ML models are in the dashed area under Model types column.
Classic ML models are usually transparent (intrinsically explainable) but may benefit from post-hoc (post training) explanations, such as visualising it. When transparency is key and the predictions are accurate enough, these may be preferred over DL models.
To the visual explanations, t-SNE, PCA and other dimensionality reduction techniques can be added.
The focus here though, is explaining deep learning models. These are usually opaque ("black-box") models, and their accuracy is usually higher than classic ML models.
Sources
- The Mythos of Model Interpretability (2018), excellent and easy-to-read. They consider two interpretability strategies:
- Transparency (intrinsic explainability), divided into 3 levels
1.simulatability or simplicity,2.decomposability or part-role mapping, and3.algorithmic training which focuses on error, loss, convergence.); - Post hoc interpretability (black box / extrinsic explainability): breaks down techniques such as textual explanations using RNNs, visual explanations, local, by example and so forth.
- Transparency (intrinsic explainability), divided into 3 levels
- A Unified Approach to Interpreting Model Predictions (2017): paper proposing SHAP, that is, showing Shapley values as the best coefficients in linear combination of features, given 3 requirements (local accuracy, missingness and consistency),
- Explaining Explanations: An Overview of Interpretability of Machine Learning (2018),
- Producing radiologist-quality reports for interpretable artificial intelligence (2018): a "case study",
- The Book of Why (2018): The introduction and first chapter were read in detail, only the part of interest for XAI (to my judgement) is discussed here, comparison and counterfactuals. It's interesting but may be more useful in other areas (like medical sciences, economics etc.)
- The perils and pitfalls of explainable AI: Strategies for explaining algorithmic decision-making (2021): emphasis on socio-political aspects,
- Interpretable and Explainable Machine Learning for Materials Science and Chemistry (2022),
- Principles and practice of explainable machine-learning (2021, 25 pages): Sections 8–11 are a useful review of explainability methods.
- A Perspective on Explainable Artificial Intelligence Methods: SHAP and LIME (2024).