[Proposal] Several positions per example in interchange interventions
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- machine-learning
Direzione di ricerca
Start with the interchange tools in tools.analysis.interchange and the existing interchange_interventions.md documentation. The proposal specifies aligned [batch, k] positions and mean pooled spans, including padding with -1; add unit coverage for both modes and padding, plus an integration test reproducing the GPT-2 result. Done means both modes work with existing interventions and fit_das, and the docs explain when pooling differs from alignment.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Proposal
Let the interchange tools in tools.analysis.interchange intervene on several positions per example, in two modes:
- Aligned positions.
positions(andfit_das'sbase_positions/source_positions) may be[batch, k]as well as[batch]. Base positionjtakes the source's activation at source
positionj, as with pyvene's(batch, k)unit locations. - Pooled spans. With
pool="mean", each row names a span instead. The intervention acts on
the span's mean, and base and source spans may differ in length.
[batch] positions keep working exactly as they do now.
Motivation
The tools intervene on one position per example, but a variable is often spread over several, and
then a one-position interchange underestimates it. On GPT-2 small, with subject number in
"The key(s) near the cabinet", patching the whole residual stream after block 4 at the subject
alone flips 37% of held-out pairs, and at the preposition alone 27%. Patching both together flips
100%. A one-position analysis would conclude that the variable is mostly gone from both positions
at that layer, when the two positions carry it jointly.
The same holds for speech. Whisper's encoder emits a frame every 20 ms, so one word spans many
positions, and the number differs by speaker and speaking rate. Probing work on speech compares
single frames, quarter-segment spans and mean-pooled word segments (Pasad et al., 2024). The causal
counterpart needs both aligned positions and pooled spans.
Pitch
Aligned mode. Interventions keep their contract of mapping [n, d_model] base rows and
source rows to new base rows. Each (example, position) pair is one row:
collect_activationsreturns[batch, k, d_model];run_with_interventionflattens the selected positions into rows, applies the intervention and
writes them back.
So SubspaceInterchange, NormMatchedPlacebo, every basis and fit_das work unchanged, with one
basis shared by the k positions. -1 pads shorter rows, so pairs in a batch can have different
k; base and source pad the same slots.
Pooled mode. Rows of positions name a span per example (padded with -1), and
collect_activations returns the span means, [batch, d_model]. The intervention maps the base's
span mean and the source's to a new mean. Every base position in the span then moves by the same
amount: the new mean minus the base's mean. For SubspaceInterchange, this gives the span's mean
the source's coordinates inside the subspace, and each position keeps its own offset from the
mean. No alignment is needed, so base and source spans can differ in length.
Docs: a "Several positions" section in interchange_interventions.md with the example below.
Tests: unit tests for both modes and the padding, and an integration test reproducing the GPT-2
result.
Alternatives
- Separate calls per position. They can't express a joint intervention, because each call
patches one position, and the hook must fire once per pass. - A concatenated basis. By default, pyvene's rotation (DAS) intervention flattens
(batch, k, d)into(batch, k·d)(unlesskeep_last_dimis set), so the learned subspace
spans the concatenated positions. The basis then grows with k, k must be fixed, and the
difference-in-means, probe and neuron bases and their placebos no longer apply. A basis shared
across positions keeps all of them. - Boolean masks instead of indices. A mask can't say which base position takes which source
position, so it suits pooling but not alignment.
Additional context
The GPT-2 numbers come from 16 nouns, 4 sentence frames, and 12 splits that fit on one frame and
evaluate 32 pairs in another. Each entry is the mean interchange accuracy over the splits, with
the range below. "Whole" patches the whole residual, the ceiling. "DiM" uses a rank-1
difference-in-means basis fit on the fit frame, shared by both positions in the aligned mode.
| layer | basis | subject | preposition | both, aligned | both, pooled |
|---|---|---|---|---|---|
| 3 | whole | 0.96 | 0.00 | 1.00 | 0.98 |
| 4 | whole | 0.37 (0.19–0.69) | 0.27 (0.00–0.44) | 1.00 (1.00–1.00) | 0.99 |
| 4 | DiM | 0.31 | 0.13 | 0.95 (0.91–0.97) | 0.92 |
| 5 | whole | 0.32 (0.19–0.59) | 0.08 | 1.00 (1.00–1.00) | 0.92 |
| 6 | whole | 0.27 | 0.01 | 0.94 | 0.86 |
Pooling is a different intervention, not a cheaper version of alignment. At layer 2, where the
variable sits on the subject alone, pooling over both positions halves the subject's shift and
reaches 0.62 against 1.00. The docs would say so.
References:
Wu, Geiger, Arora, Huang, Wang, Goodman, Manning and Potts (2024), "pyvene: A Library for Understanding and Improving PyTorch Models via Interventions", NAACL (System Demonstrations);
Pasad, Chien, Settle and Livescu (2024), "What Do Self-Supervised Speech Models Know About Words?", TACL 12;
Geiger, Wu, Potts, Icard and Goodman (2024), "Finding Alignments Between Interpretable Causal Variables and Distributed Neural Representations", CLeaR.
Checklist
- I have checked that there is no similar issue in the repo (required)
- Lingua principale
- Python
- Stelle
- 3.9k
- Fork
- 708
- Merge medio
- 2g 3h
- PR unite (30g)
- 88
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TransformerLensOrg/TransformerLens
-
[Bug Report] `boot_transformers(hf_model=...)` without `device=` can record the wrong `cfg.device`Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 56/100
TransformerLensOrg/TransformerLens#1945 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Proposal] Whisper adapter for TransformerBridgeForse già presa @dipo101 l’ha presa 2 giorni fa. Apertacomplexity-moderate new-architecture TransformerBridge
TransformerLensOrg/TransformerLens#1938 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug Report] Granite MoE Hybrid grouped experts produce incorrect or unstable outputs on MPSForse già presa @janmenjayap l’ha presa 13 giorni fa. Apertabug complexity-simple TransformerBridge
TransformerLensOrg/TransformerLens#1886 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Community Feedback Requested Research Reproduction seen_by_maintainers TransformerBridge
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
TransformerLensOrg/TransformerLens#1884 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[Proposal] Contextual Decomposition: Nonlinear Source Attribution and Dataset-Wide Ranking on GPT-2ApertaCommunity Feedback Requested Research Reproduction seen_by_maintainers
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
TransformerLensOrg/TransformerLens#1883 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TransformerLensOrg/TransformerLens
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
GoogleCloudPlatform/gce-rescue#195 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
intake mcp-intake needs-ac needs-human-review priority:medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
Ikalus1988/MisakaNet#3848 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
521xueweihan/HelloGitHub#4105 ·
-
bug size:XS
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno