Skip to content

Axiomatic Causal Interventions for Reverse Engineering Relevance Computation in Neural Retrieval Models

Skip →Interp Stage 2 · frontier
main track #10corefrontierpaperrubric 12/122024 · SIGIR 2024 (perspectives paper) · ~50 min

Catherine Chen, Jack Merullo, Carsten Eickhoff

Read first: Towards Best Practices of Activation Patching in Language Models: Metrics and Methods

Status

TL;DR. IR axioms such as TFC1 (“more query-term occurrences, same length, higher score”) already give us minimal pairs of documents. Chen, Merullo and Eickhoff use those pairs as the clean and corrupted inputs of activation patching on TAS-B, a 6-layer, 12-heads-per-layer DistilBERT bi-encoder. They find term-frequency information concentrated in four attention heads: two early duplicate-token heads that link repeated query terms, and two middle-layer heads that spread the signal before it moves to CLS in layers 4–5.

Why it matters now. Most explainable-IR work used probing (does layer 3 encode TF?) or behavioural axioms (does the model obey TFC1?). Neither shows which components cause the score. This paper is the step from IR diagnostics to mechanistic interpretability. It reuses the IR community’s axioms as hypotheses and the interpretability community’s patching as the test. If you know BM25, this is the easiest way into circuits: the “task” is a ranking axiom you already understand.

From axiom to patching pair. TFC1 (Fang et al., 2004): for a one-term query q={w}q=\{w\} and two documents of equal length, the one with more occurrences of ww should score higher. BM25 satisfies it because its TF factor TF(k1+1)TF+K\frac{\mathrm{TF}(k_1+1)}{\mathrm{TF}+K} is increasing in TF at fixed length. Two perturbations turn it into patching data (§3.2):

  • TFC1-I (inject): sample a query term and append it before SEP to make dpd_p. Append a filler token (“a”) to make a length-matched baseline dbd_b. Expected: s(q,dp)>s(q,db)s(q,d_p) > s(q,d_b).
  • TFC1-R (replace): replace every occurrence of a query term with filler to make dpd_p; the original is dbd_b. Expected: s(q,db)>s(q,dp)s(q,d_b) > s(q,d_p).

Patching for ranking (§3.1). In language-model patching the clean run always donates. Here the donor is whichever document should score higher, so the patch always carries “more of the term” into the run on “less of the term”:

  1. Run the higher-expected document and cache all activations.
  2. Run the lower-expected document and record its score.
  3. Rerun the lower document, overwrite one activation (residual stream at a layer and token, attention-layer output, MLP output, or one head) with the cached value, and record the score.

The paper describes the metric as a normalised score difference: 0 means the patch did nothing and 1 means it fully recovered the higher document’s score. In formula form,

effect=spatched−slowshigh−slow,\text{effect} = \frac{s_\text{patched} - s_\text{low}}{s_\text{high} - s_\text{low}},

with ss the TAS-B ranking score (a dot product of pooled CLS vectors). Results are averaged by token type: CLS, the injected term, existing copies of the selected term (qterm+qterm^+), other query terms (qterm−qterm^-), other tokens and SEP (Table 1). This lets documents of different lengths be compared.

Data. MS MARCO dev queries (about 6.8k). For each query, the top 100 documents are perturbed and rescored, and the 100 queries with the largest average score change are kept, separately for TFC1-I and TFC1-R. The selection step makes sure the perturbation actually matters, for example by preferring “Wellesley” over “the”.

Axiomatic activation patching in TAS-B Left: a TFC1-Inject pair for the query "average snowfall nyc". The perturbed document appends the query term snowfall; the baseline appends the filler token a, so both have the same length. Middle: both documents pass through the six-layer TAS-B document encoder. Activations from the perturbed run, which should score higher, are cached and patched into the baseline run at one location. Right: the patched score is normalised between the baseline and perturbed scores. Heads 0.9 and 1.6 attend between duplicate copies of the term; heads 2.3 and 3.8 spread the signal; in layers 4 and 5 it moves to CLS, which is pooled for the dot-product score. 1. Axiom → minimal pair q = "average snowfall nyc" perturbed d_p … doc text … snowfall [SEP] baseline d_b … doc text … a [SEP] TFC1: same length, one more query term ⇒ s(q, d_p) should exceed s(q, d_b) 2. Patch high → low run TAS-B doc encoder (6 layers × 12 heads) L0 L1 L2 L3 L4 L5 run on d_p: cache run on d_b with one activation from d_p patch What patching finds 0.9, 1.6: duplicate-token heads 2.3, 3.8: spread the TF signal L4–L5: signal moves to CLS 3. Normalised effect (s_patch − s_low) / (s_high − s_low) 0 = no effect 1 = full recovery > 1 = overshoot TFC1-R flips the roles: remove the term, so the baseline is the donor score = CLS(q) · CLS(d)
Original sketch. A TFC1-I pair: the perturbed document has one extra copy of a query term, the baseline a filler token. Activations from the higher-scoring run are patched into the lower one, layer by layer and then head by head, inside TAS-B's document encoder.
  • Where the signal lives (§5.1, Fig. 4). Residual-stream patching shows the effect on the selected-term tokens in early layers, then a shift to CLS in layers 4 and 5. For TFC1-I, existing copies of the term (qterm+qterm^+) matter as much as the injected one. Injecting at the start of the document moves the importance fully to the injected token (Fig. 5), so TF information seems to collect on the first occurrence. Attention scores later show it is shared across all copies (§6.2).
  • Four heads (§5.2, Fig. 6). Patching single heads for TFC1-I finds 0.9 (layer 0, head 9), 1.6, 2.3 and 3.8. Patched in, these heads fully recover the perturbed score and sometimes exceed it. The heads mostly matter for the top 10% most relevant documents per query, not the bottom 10%: they appear to amplify existing relevance rather than create it.
  • Two kinds of head (§5.3, §6.2). In 0.9 and 1.6 the injected token attends to other copies of the same term: duplicate-token heads that can count. 2.3 and 3.8 do not attend to duplicates, and their effect is spread over several token types (Fig. 10). The authors hypothesise that early heads write a TF signal that middle “relevance composition” heads build on. This matches Zhan et al.’s earlier hypothesis for BERT rankers.
  • SEP as a no-op (§6.2). In early layers, unimportant tokens attend heavily to SEP while repeated relevant tokens do not. SEP works as a “no-op” for unimportant tokens, which lets the heads focus on repeated relevant terms.
  • Dataset design matters (§6.1). Scores depend on where a term is inserted: for some queries, inserting near the start gives higher scores, possibly because MS MARCO prepends titles (Fig. 9). Random term choice (as in TFC1-A) can pick low-IDF terms that barely change the score. The authors recommend choosing the perturbation location on purpose and filtering for large effects.
  • One model, one axiom. Only TAS-B and TFC1. Whether other bi-encoders, cross-encoders or LLM rerankers use the same heads is left open. The cross-encoder BM25 paper is the first answer for a cross-encoder.
  • Document tower only. TAS-B encodes query and document separately, so the study cannot see query–document interaction.
  • Unnatural inputs. Appending a lone query term or “a” creates text unlike the training data. The authors report no big qualitative difference with more natural insertion, but this is not quantified.
  • Single-head patches. Interactions between heads (patching several together, path patching) and direct vs indirect effects are left to future work.
  • The perspectives paper suggests uses beyond diagnosis: testing adversarial “trigger words”, editing heads or weights (as ROME does for facts), and finding biases.
  • Activation patching: the method in general, including why metric and corruption choice matter. Here the corruption is an axiom-defined edit, which is close to symmetric token replacement.
  • Cross-encoders as semantic BM25 extends this to four BM25 axioms and path patching on a cross-encoder, and finds a full scoring circuit.
  • ABNIRML is the behavioural, black-box predecessor: same document-pair idea, no look inside.
  • MechIR packages this patching setup for bi- and cross-encoders.
  • ColBERT and SPARSEUP make term matching explicit in the architecture. This paper finds a learned version of it inside a single-vector model.

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.

  1. Derive / compute

    In BM25 the term-frequency factor for one query term is TF·(k₁+1)/(TF + k₁·(1 − b + b·|d|/avgdl)). Show that TFC1 holds for BM25 (more occurrences at equal length give a higher score), then explain why the TFC1-I construction must add a filler token to the baseline document.

    What a strong answer covers
    • At fixed |d| the denominator constant K = k₁(1 − b + b|d|/avgdl) > 0, and f(TF) = TF(k₁+1)/(TF + K) has derivative (k₁+1)K/(TF + K)² > 0, so f increases with TF and the IDF-weighted sum does too.
    • TFC1 is stated for documents of equal length; injecting one query term also raises |d|, which in BM25 lowers the score through the length term.
    • Adding a filler token (e.g. "a") to the baseline keeps |d_b| = |d_p|, so the only difference between the pair is one more occurrence of the selected query term.
    • Without the filler, any patching effect would mix a term-frequency signal with a length signal, and the experiment would no longer isolate TFC1.
  2. Mechanism

    Describe the three runs of the paper's retrieval patching setup for TFC1-I and TFC1-R. Why does the direction of patching flip between the two perturbations, and what does a normalised score of 1 mean?

    What a strong answer covers
    • Each perturbation gives a query with a baseline and a perturbed document; the run on the document expected to score higher is cached, the other run is recorded, and the patched run runs the lower-scoring document with one activation overwritten from the higher one.
    • TFC1-I injects the query term, so the perturbed document should score higher: patch perturbed → baseline. TFC1-R removes all occurrences, so the baseline scores higher: patch baseline → perturbed.
    • In both cases the model runs on the document with fewer occurrences of the term and receives activations from the one with more, so the experiment always asks which components carry the extra term-frequency signal.
    • The normalised difference in ranking scores is 0 when the patch has no effect and 1 when it fully recovers the higher document's score; values above 1 mean the patch overshoots.
  3. Mechanism

    The paper finds that heads 0.9 and 1.6 attend from the injected term to earlier copies of the same term, while heads 2.3 and 3.8 do not attend to duplicates but still restore the score. Propose a mechanistic story connecting these two groups and the CLS-based score.

    What a strong answer covers
    • Early duplicate-token heads let each occurrence of the term see the others, writing a "this term occurs k times" signal into the residual stream at those positions, i.e. a learned TF counter.
    • Middle-layer heads read that signal and spread it across the document representation (they are sensitive to several token types, including CLS), composing it with other relevance evidence.
    • In layers 4 and 5 the signal moves into the CLS position, which TAS-B pools for the dot-product score, so later individual heads matter less.
    • The authors call this a hypothesis: it would be confirmed by path patching from the early heads to the middle heads, which the paper does not do.
  4. Critique

    The four heads restore the score mostly for the top 10% most relevant documents per query, not the bottom 10%. Give two explanations for this, and say which experiment would tell them apart.

    What a strong answer covers
    • Amplifier explanation (the authors'): the heads scale up an existing relevance signal, so with little other evidence one more occurrence barely moves the score.
    • Saturation or metric explanation: for low-scoring documents the baseline–perturbed gap is small or noisy, so the normalised score is unstable and a small absolute change looks like no effect.
    • Test: build pairs for low-relevance documents where the perturbation still produces a large absolute score gap, and compare raw score differences as well as normalised ones.
    • Also check that the selection rule (the 100 queries with the largest average score change) does not over-represent high-relevance documents.
  5. Design

    Design an axiomatic patching study for a different axiom on a dense retriever you care about, for example LNC1 (adding non-relevant text should not raise the score) or a proximity axiom. Specify the pair construction, the patching direction, the metric and one validity check.

    What a strong answer covers
    • Write the axiom formally, then a perturbation that changes only that property (e.g. LNC1: append k non-relevant sentences vs a length-matched neutral filler).
    • Patch from the document the axiom says should score higher into the run on the lower one, over residual stream positions, then attention vs MLP outputs, then single heads.
    • Use a normalised score difference (dot product for a bi-encoder), averaged over pairs, grouped by token type (query terms, injected tokens, CLS, SEP, other).
    • Validity: keep only pairs where the perturbation changes the score substantially, choose informative terms (not stopwords), and vary the perturbation position, since TAS-B scores depend on where text is inserted.
  6. Research idea

    TAS-B encodes queries and documents separately, so this study only examines the document tower. Propose a research question about relevance mechanisms that this design cannot answer, and an experiment that could.

    What a strong answer covers
    • A bi-encoder has no query–document attention, so patching the document tower cannot show how a query term is matched; it only shows how term frequency is written into the document vector.
    • Question: does the score depend on a few dimensions of the pooled CLS vector that align with query-term identity, or on a distributed code?
    • Experiment: patch in the query tower too, and decompose the dot product into per-dimension or per-direction contributions (e.g. with an SAE on embeddings) to see which features the TF heads write to.
    • Or compare with a cross-encoder, where query–document interaction happens inside attention (see the cross-encoder BM25 page).

Done with this page?

Status