Explainable AI (XAI) Advanced 12 minutes

Concept-based and Mechanistic Interpretability

From "which pixels?" to "which concepts?": TCAV and concept bottleneck models, and a glimpse of mechanistic interpretability.

Your progress in the track0%

From pixels to concepts

A physician does not think about pixel (120, 45), but about “irregular margins” or “microcalcifications”. Concept-based explanation speaks this language.

TCAV

  1. Collect examples of the concept (such as striped images) and random examples.
  2. Extract their activations at layer \(l\).
  3. Train a linear classifier between them; the vector normal to its boundary is \(v_C\).
  4. For each image of class \(k\), compute the directional derivative:

$$S_{C,k}(x) = \nabla h_{l,k}(f_l(x)) \cdot v_C$$

  1. The TCAV score = the proportion of images for which \(S > 0\), with a significance test against random vectors.

Concept bottleneck models

StageOutput
Input → concepts“Irregular margins: yes”, “calcification: no”
Concepts → result“Malignant: 0.82”

The advantage: the physician can correct a wrong concept and the prediction changes. The drawback: it needs concept labels in training, and additional information may leak through the concepts.

Mechanistic interpretability

  • It tries to identify “circuits” inside the network that carry out specific functions, such as curve detectors in convolutional networks or attention heads with particular functions in transformers.
  • Recent tools such as sparse autoencoders extract more interpretable features from the activations of language models.
  • The current state: an active and exciting research field, but its results are partial, and there is not yet an established methodology for using it to assure the safety of critical systems.

Lesson terms

Mechanistic interpretability
An attempt to reverse-engineer the network's internal computations into understandable components and algorithms.
Concept activation vector
A direction in a layer's activation space that separates examples of a concept from random examples.
Concept bottleneck model
A model that first predicts a set of understandable concepts and then uses them alone to predict the outcome.

Abstract

Concept-based explanations ask whether the model uses a human concept such as "striped" or "calcification". TCAV learns the concept vector from concept examples and random examples in activation space, then measures the sensitivity of the class to this direction. Concept bottleneck models predict the concepts first and then the class, allowing human intervention. Mechanistic interpretability tries to understand the computational circuits inside the network; it is an active research field whose tools are not yet mature for critical applications.

Review questions

  1. What is needed to apply TCAV?

    A set of examples representing the concept, random examples, and access to the activations of an internal layer and their gradients.

  2. What is the advantage of concept bottleneck models?

    The expert can see the predicted concepts and correct them, and the final prediction changes accordingly.

Sources and references

  1. Kim et al. (2018) — Interpretability Beyond Feature Attribution: TCAV
  2. Koh et al. (2020) — Concept Bottleneck Models
  3. Olah et al. — Zoom In: An Introduction to Circuits (Distill)

Complete the lesson