Interpretability

Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 10

32 cards

Introduction

  1. What is (mechanistic) interpretability?
    Research into methods for understanding how language models do what they do: uncovering their internal representations (what meanings they encode) and their reasoning paths, e.g. describing specific “circuits”.

10.1 Contextual embeddings

  1. How do contextual embeddings differ from static embeddings like word2vec?
    Static embeddings give one vector per word type; contextual embeddings give a different vector each time a word appears in a different context.
  2. Where do contextual embeddings come from in a transformer?
    The output of each component (attention heads, feedforward network) added to the residual stream, at every layer and every token, is a contextual embedding. Commonly the final layer’s \(h^L_i\) is used as the meaning of token \(x_i\) in context.
  3. How are BERT contextual embeddings for a token often computed?
    By mean- or max-pooling the token’s output vectors from the last four layers, rather than using the final layer alone.
  4. Static embeddings represent word types; what do contextual embeddings represent?
    Word instances: a particular occurrence of a word type in a particular context.
  5. What does it mean that a word is polysemous? Give examples.
    It has multiple senses: mouse (rodent / cursor device), bank (financial institution / sloping mound).
  6. What is a word sense, and where are senses listed?
    A discrete representation of one aspect of a word’s meaning (bank¹, bank²), listed in thesauruses like WordNet, which exists for many languages.
  7. How is the term polysemy sometimes used more narrowly, and what is homonymy?
    Sometimes polysemy means only senses related in a structured way (“structured polysemy”), with homonymy for ambiguity between unrelated senses. The book uses polysemy for any sense ambiguity.
  8. What do 2-d projections of many BERT embeddings of the word die show?
    Instances cluster by meaning: separate clusters for die as singular of dice, the verb to die, and the German article die.
  9. How does the view of word meaning from embeddings differ from WordNet’s?
    WordNet gives discrete lists of senses; embeddings offer a continuous high-dimensional model of meaning that can be clustered but doesn’t divide into fully discrete senses.
  10. What is word sense disambiguation (WSD)?
    Selecting the correct sense of a word in context, given a fixed inventory of possible senses (e.g. from WordNet).
  11. What is the “one sense per discourse” rule?
    A word tends to be used in roughly the same sense throughout a discourse.
  12. Describe the best-performing simple WSD algorithm.
    1-nearest-neighbor with contextual embeddings: for each sense in a sense-labeled corpus (e.g. SemCor), average the contextual embeddings of its tokens into a sense embedding \(v_s\). At test time, embed the target token \(t\) and choose \(\arg\max_s \cos(t, v_s)\).
    find¹ (locate)find⁵find⁴ (verdict)find⁹ (perceive)“found” in “I found the jar empty”
    Pick the sense whose averaged embedding is closest.
  13. How is word similarity in context measured with contextual embeddings?
    By the cosine between the contextual embeddings of the two word instances (after some transformation of the embeddings).
  14. What is anisotropy in contextual embeddings, and why is it a problem?
    All vectors tend to point in the same direction, so even random word pairs have cosines close to 1 (anisotropy = the expected cosine between random pairs). This makes raw cosines uninformative.
  15. What causes anisotropy, and how can it be reduced?
    A few “rogue dimensions” with very large magnitudes and variance dominate the cosine. Standardizing (z-scoring) each dimension over a corpus, \(z = \frac{x - \mu}{\sigma}\), makes embeddings more isotropic.
  16. What problem with cosine similarity of contextual embeddings remains after standardization?
    Cosine tends to underestimate human similarity judgments for very frequent words.

10.2 Probing

  1. What is probing?
    Testing whether a representation encodes some information (e.g. that a word is a noun, or the tense of sublet) by training a simple classifier (logistic regression or a small MLP) on embeddings from a chosen position and layer to predict that property.
    subletlayer kprobepast?yes .91LLM frozen;only the probe trains
  2. What have probing studies suggested about where information lives across transformer layers?
    Grammatical information about tokens seems encoded at lower layers, semantic information at middle layers, and discourse information like coreference higher still (Tenney et al., 2019).
  3. What are the steps of training a probe?
    (1) Choose a property; (2) create train and test sets of embeddings from the position/layer of interest, labeled with the property; (3) pass the sentences through the LLM and extract activations; (4) freeze the LLM and train only the classifier.
  4. What controls and constraints does good probing need?
    Comparison to control conditions (e.g. probing with random labels), and a probe that isn’t too powerful, so it doesn’t succeed by learning the information itself rather than reading it from the representation.
  5. What can’t a successful probe tell you?
    That the model uses the information: the property may be correlated with the embedding without having any causal effect on the model’s behavior.

10.3 The logit lens

  1. What is the logit lens?
    A visualization trick: take a vector from any intermediate layer, pretend it is the final embedding, multiply it by the unembedding matrix and apply softmax, to see which words it might represent.
  2. Why doesn’t the logit lens always work well?
    The network wasn’t trained to make internal layers interpretable this way; it implicitly assumes earlier layers live in the same embedding space as the final layer.
  3. What is the Jacobian lens (J-lens), and how does it differ from the logit lens?
    A variant that uses the derivatives of the final layer’s output with respect to an intermediate layer: how a small change there would alter the final output, averaged over many contexts. It acts like a translator through an approximation of the rest of the network, and works better at earlier layers.
  4. What have lens analyses suggested about how models reason internally?
    A kind of layer-by-layer workspace: for “the color of the planet fourth from the sun”, layers first encode color, then resolve Mars, then red. For multilingual prompts, meanings seem represented mostly in English and translated into the output language only in later layers.

10.6 In-context learning and induction heads

  1. What is in-context learning?
    Language models learning to do new tasks, predicting tokens better, or generally reducing their loss during the forward pass at inference time, from the prompt alone, without any gradient updates to their parameters (term from Brown et al., 2020).
  2. Why can prompting even without demonstrations be seen as learning?
    The further a model gets into a prompt, the better it tends to predict upcoming tokens: information in the context gives it more predictive power.
  3. What is a circuit in interpretability?
    An abstract functional component of a network, such as the induction head.
  4. What does an induction head do?
    It predicts repeated sequences: seeing AB … A, it predicts B (the rule AB…A → B). A prefix-matching attention component finds an earlier occurrence of the current token A, and a copying mechanism raises the probability of the token B that followed it.
    vintagecars…vintagecars?1. find the earlier “vintage”; attend to what followed2. copy “cars” as the prediction
  5. How might induction heads explain in-context learning?
    Olsson et al. (2022) propose that a fuzzy generalization, A*B* … A → B where A* ≈ A and B* ≈ B semantically, implements in-context learning from patterns in the prompt.
  6. What is ablation, and what evidence did ablating induction heads give?
    Removing (knocking out) a hypothesized cause to test whether its effect disappears. Zeroing the outputs of induction heads made models much worse at in-context learning from demonstrations (Crosbie & Shutova).

Source