ML Interpretability: feature visualization, adversarial example, interp. for language models
TL;DR. A YouTube lecture by Umar Jamil (May 20, 2024), made in collaboration with Leap Labs. It reviews deep learning and backprop, then uses gradients with respect to the input for three tasks: fooling an image classifier, visualising what a class or feature responds to, and generating prompts that make a language model predict a chosen concept. The last task asks questions such as “What does my language model think of women?”. Slides are in the linked repository.
Key idea
Section titled “Key idea”Training changes the weights to fit the data. Interpretability by input optimisation does the reverse: freeze the weights and change the input to maximise a chosen output. With a small change from a real input, you get an adversarial example. Starting from noise with a natural-image prior, you get a feature visualisation. With a prompt, you get a probe of what concepts the model associates with what.
Chapters (from the video’s chapter markers):
| Time | Chapter |
|---|---|
| 0:00 | Introduction to interpretability |
| 1:37 | Why model transparency matters |
| 5:35 | Deep learning and backprop |
| 14:06 | Tricking a classifier |
| 22:04 | Using an interpretability engine |
| 32:56 | Feature visualization techniques |
| 39:58 | Regularization for natural inputs |
| 46:42 | Interpretability in language models |
Where it fits. This is the classical, input-attribution side of interpretability, closer to integrated gradients than to circuits. For an IR reader, the language-model chapter is the useful part: optimising a query so that a ranker scores a target document highly is the same idea, and it is how adversarial retrieval attacks are built.
Connections
Section titled “Connections”- Integrated gradients is the principled version of gradient-with-respect-to-input attribution.
- Activation patching is the internal, causal alternative to input-space explanations.
- Nanda’s guide is the next step once you move from input-level to mechanistic questions.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Derive / compute
Feature visualisation and adversarial examples both optimise the input with backprop. Write the two objectives and say which parameters are frozen, what is updated, and why the two give such different-looking images.
What a strong answer covers
- Both freeze the model weights and take gradients of an objective with respect to the input pixels.
- Adversarial example: start from a real image and maximise the score (or log-probability) of a wrong target class, keeping the change small, e.g. within a norm bound.
- Feature visualisation: start from noise and maximise a class logit or a neuron activation, with no requirement to stay near a real image.
- Without constraints both exploit high-frequency, non-natural directions; adversarial images look unchanged to us, while visualisations look like noise unless regularised.
- Mechanism
The video's regularisation chapter targets natural-looking inputs. Explain why unregularised feature visualisation produces noise and how common regularisers fix it.
What a strong answer covers
- The gradient is dominated by high-frequency patterns that strongly drive the logit but are not natural image structure.
- Penalties such as total variation or an L2 norm on pixels discourage noise and extreme values.
- Transformation robustness (jitter, rotation, scaling between steps) keeps only features that survive small changes.
- Blurring or a frequency-domain parameterisation biases the optimisation toward smooth, natural-looking images.
- Connect
The final chapter optimises a prompt so the model's next token is a chosen concept, to probe bias. Contrast this input-space method with activation patching as a tool for explaining a model.
What a strong answer covers
- Prompt optimisation searches over discrete tokens (or relaxed embeddings) to maximise a target next-token likelihood; it shows which inputs elicit an output, not how the model computes it.
- Discrete tokens make gradients only approximate, so methods relax to embeddings or rank token swaps by gradient.
- Activation patching keeps the input fixed and intervenes on internal components to locate where a behaviour is computed.
- The two complement each other: optimised prompts can supply the clean and corrupted pairs that patching needs.