diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..bed0738c7eeb449bca98b5d2f33c89a1ee56349a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,60 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.avro filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.lz4 filter=lfs diff=lfs merge=lfs -text +*.mds filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.parquet filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text +# Audio files - uncompressed +*.pcm filter=lfs diff=lfs merge=lfs -text +*.sam filter=lfs diff=lfs merge=lfs -text +*.raw filter=lfs diff=lfs merge=lfs -text +# Audio files - compressed +*.aac filter=lfs diff=lfs merge=lfs -text +*.flac filter=lfs diff=lfs merge=lfs -text +*.mp3 filter=lfs diff=lfs merge=lfs -text +*.ogg filter=lfs diff=lfs merge=lfs -text +*.wav filter=lfs diff=lfs merge=lfs -text +# Image files - uncompressed +*.bmp filter=lfs diff=lfs merge=lfs -text +*.gif filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.tiff filter=lfs diff=lfs merge=lfs -text +# Image files - compressed +*.jpg filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.webp filter=lfs diff=lfs merge=lfs -text +# Video files - compressed +*.mp4 filter=lfs diff=lfs merge=lfs -text +*.webm filter=lfs diff=lfs merge=lfs -text diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..2ef979b7ce354ff5b25a3e751cca8012f37e1eab --- /dev/null +++ b/README.md @@ -0,0 +1,559 @@ +--- +license: cc-by-4.0 +pretty_name: neuron-lens +tags: +- interpretability +- neurons +- attention-heads +- r-lens +- s-lens +- multimodal +configs: +- config_name: qwen3-8b-neurons-acts + data_files: "qwen3-8b/neurons/acts/*.parquet" + default: true +- config_name: qwen3-8b-neurons-drivers + data_files: "qwen3-8b/neurons/drivers/*.parquet" +- config_name: qwen3-8b-neurons-reads + data_files: "qwen3-8b/neurons/reads/*.parquet" +- config_name: qwen3-8b-neurons-legible + data_files: "qwen3-8b/neurons/legible/*.parquet" +- config_name: qwen3-8b-neurons-labels + data_files: "qwen3-8b/neurons/labels/*.parquet" +- config_name: qwen3-8b-heads-acts + data_files: "qwen3-8b/heads/acts.parquet" +- config_name: qwen3-8b-heads-drivers + data_files: "qwen3-8b/heads/drivers.parquet" +- config_name: qwen3-8b-heads-reads + data_files: "qwen3-8b/heads/reads.parquet" +- config_name: qwen3-8b-heads-legible + data_files: "qwen3-8b/heads/legible.parquet" +- config_name: qwen3-8b-heads-labels + data_files: "qwen3-8b/heads/labels.parquet" +- config_name: gemma-4-12b-neurons-acts + data_files: "gemma-4-12b/neurons/acts/*.parquet" +- config_name: gemma-4-12b-neurons-drivers + data_files: "gemma-4-12b/neurons/drivers/*.parquet" +- config_name: gemma-4-12b-neurons-reads + data_files: "gemma-4-12b/neurons/reads/*.parquet" +- config_name: gemma-4-12b-neurons-legible + data_files: "gemma-4-12b/neurons/legible/*.parquet" +- config_name: gemma-4-12b-neurons-labels + data_files: "gemma-4-12b/neurons/labels/*.parquet" +- config_name: gemma-4-12b-neurons-image + data_files: "gemma-4-12b/neurons/image/*.parquet" +- config_name: gemma-4-12b-neurons-audio + data_files: "gemma-4-12b/neurons/audio/*.parquet" +- config_name: gemma-4-12b-neurons-image-optimised + data_files: "gemma-4-12b/neurons/image_optimised.parquet" +- config_name: gemma-4-12b-neurons-audio-optimised + data_files: "gemma-4-12b/neurons/audio_optimised.parquet" +- config_name: gemma-4-12b-heads-acts + data_files: "gemma-4-12b/heads/acts.parquet" +- config_name: gemma-4-12b-heads-drivers + data_files: "gemma-4-12b/heads/drivers.parquet" +- config_name: gemma-4-12b-heads-reads + data_files: "gemma-4-12b/heads/reads.parquet" +- config_name: gemma-4-12b-heads-legible + data_files: "gemma-4-12b/heads/legible.parquet" +- config_name: gemma-4-12b-heads-labels + data_files: "gemma-4-12b/heads/labels.parquet" +- config_name: gemma-4-12b-heads-media + data_files: "gemma-4-12b/heads/media.parquet" +--- + +# neuron-lens: every neuron and attention head of Qwen3-8B and Gemma 4 12B + +A catalog of two models' MLP neurons (two poles each) and attention heads: +[`Qwen/Qwen3-8B`](https://huggingface.co/Qwen/Qwen3-8B) (36 × 12,288 neurons, +36 × 32 heads) and [`google/gemma-4-12B`](https://huggingface.co/google/gemma-4-12B) +(48 × 15,360 neurons, 48 × 16 heads). Each unit is read from three +sides: + +- **from the weights alone,** through two lenses: what a unit writes and what it reads; for a head, what + it copies and what it attends to, token by token; +- **from its activations** over about 15.4M positions of web, Chinese, Python and chat text; +- **from the tokens that drive it** when swept through real contexts. + +Gemma 4 takes images and sound too, so each of its neurons is also read through lenses fitted on images +and sounds, and against 49,694 labelled images and 46,932 +labelled sounds. + +![What neurons and heads do](figures/01_anatomy.png) + +Neurons and heads get the same tables, one row per pole or per head: + +| table | neurons | heads | +|---|---|---| +| `reads` | lens reads of the write and the read direction | lens reads of the OV and QK circuits, per token | +| `acts` | activation statistics and top firings | output-norm statistics, top firings, attention patterns | +| `drivers` | the tokens that drive each pole hardest | the tokens that drive each head, as query and as key | +| `legible` | which reads hold at the pole's top firings | which reads hold at the head's top firings | +| `labels` | Claude Haiku's labels: where it fires, what it writes | where it fires, what it attends to, what it writes | +| `image`, `audio` (Gemma 4) | the patch or sound it reads, its write in media contexts, the images or sounds that drive it, and whether its media label is its text concept too | | +| `media` (Gemma 4) | | how each head attends in image and audio contexts, and which carry what an image or sound shows | + +| config | rows | what | +|---|---|---| +| `qwen3-8b-neurons-acts` | 884,736 | every pole's activation statistics and top firings | +| `qwen3-8b-neurons-drivers` | 884,736 | every pole's 64 token drivers in real contexts | +| `qwen3-8b-neurons-reads` | 884,736 | every pole's weight-only reads through both lenses | +| `qwen3-8b-neurons-legible` | 884,736 | which reads hold at every pole's top firings | +| `qwen3-8b-neurons-labels` | 884,736 | every pole's labels, by Claude Haiku 5.5 | +| `qwen3-8b-heads-acts` | 1,152 | every head's output statistics, top firings and attention patterns | +| `qwen3-8b-heads-drivers` | 1,152 | every head's 64 token drivers, as query and as key | +| `qwen3-8b-heads-reads` | 1,152 | every head's OV and QK circuits read per token | +| `qwen3-8b-heads-legible` | 1,152 | which reads hold at every head's top firings | +| `qwen3-8b-heads-labels` | 1,152 | every head's labels, by Claude Haiku 5.5 | +| `gemma-4-12b-neurons-acts` | 1,474,560 | every pole's activation statistics and top firings | +| `gemma-4-12b-neurons-drivers` | 1,474,560 | every pole's 64 token drivers in real contexts | +| `gemma-4-12b-neurons-reads` | 1,474,560 | every pole's weight-only reads through both lenses | +| `gemma-4-12b-neurons-legible` | 1,474,560 | which reads hold at every pole's top firings | +| `gemma-4-12b-neurons-labels` | 1,474,560 | every pole's labels, by Claude Haiku 5.5 | +| `gemma-4-12b-neurons-image` | 1,474,560 | every pole's image read and write, the images that drive it, and its cross-modal ranks | +| `gemma-4-12b-neurons-audio` | 1,474,560 | every pole's audio read and write, the sounds that drive it, and its cross-modal ranks | +| `gemma-4-12b-neurons-image-optimised` | 1,728 | the patch that most raises each of the best-labelled poles | +| `gemma-4-12b-neurons-audio-optimised` | 1,728 | the 40 ms of sound that most raises each of the best-labelled poles | +| `gemma-4-12b-heads-acts` | 768 | every head's output statistics, top firings and attention patterns | +| `gemma-4-12b-heads-drivers` | 768 | every head's 64 token drivers, as query and as key | +| `gemma-4-12b-heads-reads` | 768 | every head's OV and QK circuits read per token | +| `gemma-4-12b-heads-legible` | 768 | which reads hold at every head's top firings | +| `gemma-4-12b-heads-labels` | 768 | every head's labels, by Claude Haiku 5.5 | +| `gemma-4-12b-heads-media` | 768 | every head in image and audio contexts | + +The lenses are [`stdlogits/rs-lenses`](https://huggingface.co/stdlogits/rs-lenses) at revision `93a9c5ffee`. Code, methods and +findings (cited here as §N) are on [GitHub](https://github.com/stdlogits/neuron-lens). + +## The lenses + +- The **R-lens** reads what a vector makes the model say: `softmax(W_U · norm(J_L x))`, with `J_L` the + averaged Jacobian from layer `L` to the last layer (for Gemma 4, after its final softcap, + `30 · tanh(x / 30)`). +- The **S-lens** reads which input tokens put a vector there: token `v` scores + `c · K_L (W_E[v] − mean(W_E))`, with `K_L` the averaged Jacobian from the embeddings to layer `L`. + +Each is fitted at two points of every layer: `out`, the layer's output, and `mid`, its MLP input (after +attention). `out` reads MLP outputs and attention inputs; `mid` reads MLP inputs and attention outputs. +Gemma 4's image and audio lenses are fitted the same way on images and sounds. + +| what | where it is | R-lens read | S-lens read | Gemma 4: image and audio lenses | +|---|---|---|---|---| +| a neuron's write | layer `L`'s output | `write_R` | `write_S` | `image.write_R`, `audio.write_R` | +| a neuron's read direction `â ± b̂` | layer `L`'s MLP input | `read_R` | `read_S` | `image.read_png`, `audio.read_wave` | +| what a head reads | layer `L − 1`'s output | | the token's footprint (input of `ov_*`, `qk_*`) | | +| what a head writes | layer `L`'s MLP input | `ov_R` | `ov_S` | | + +## Which reads to trust where + +No read works at every depth (§7, §11). For Qwen3-8B (these bands are priors; `legible` says which +reads hold for each unit): + +| layers | what drives a neuron | what a neuron writes | what a head writes | +|---|---|---|---| +| L0-L7 | `read_S` (literal tokens, raw at L0-L4) | `write_S` (early neurons write back what they detect); `write_R` from about L4 | `ov_S` | +| L8 | both | both | `ov_S`, `ov_R` | +| L9-L12, L21-L35 | `read_R`, with `read_S_z` as a concept-level view | `write_R` | `ov_R` | +| L13-L20 | only `drivers` and `acts` | `write_R`, for steering | `ov_R` (weak) | + +![Which reads work at which depth](figures/03_depth_map.png) + +Gemma 4's map has the same shape at its own depths: `read_S` through L13 (falling to under 1% at L9 and rising again at L10-L13), +`write_R` from about L33 (for steering from L11), and a dark middle (§13). + +![Both models by relative depth](figures/18_two_models.png) + +## Conventions + +- **Keys.** Neuron tables: `layer`, `neuron` (coordinate `n` of `down_proj`'s input, 0-indexed), `pole` + (+1 or −1). Both models' gated activations take both signs, so each neuron has two poles with separate + meanings, 24,576 (Qwen3-8B) or 30,720 (Gemma 4) rows a layer, the + poles + first. Head tables: `layer`, `head` (query head) and `kv_head` (the key-value head it reads). `L8 n344 +` + is `layer` 8, `neuron` 344, `pole` 1; `L20h17` is `layer` 20, `head` 17. +- **Token lists.** `_ids` are 64 token ids of the model's tokenizer, `_val` their scores, + `_str` the top 8 decoded and joined by ` | ` (newlines as `⏎`). Signal holds to rank 64 (§7). +- **Kept tokens.** Reads cover the tokens seen 5 or more times in the activation corpora, without + byte-fallback pieces (`token_counts.pt`): 103,830 for Qwen3-8B, 123,774 for Gemma 4. + Undertrained tokens otherwise dominate early reads. +- **`_z`** reads are layer-contrastive: each token's score z-scored across the layer's poles or heads, + which removes the hub tokens that top most raw reads. **`_neg`**: a head read's bottom. +- **Firings.** A unit's firing in a document is its strongest position there; its top firings are the + 24 documents where that is largest. `contexts` show the first 5, the firing token in `⟦ ⟧` and, for + heads, the token it attends to most (past position 0) in `⟪ ⟫`. +- **Tests** (`legible`) score a read on the tokens of the unit's own top firings, as a mean z, against + mismatched pairs: another unit of the layer scored on the same tokens. `_q` is the Benjamini-Hochberg + q-value; a test passes at `q ≤ 0.05`. **Dark:** fires, but no test passes and no single token + dominates its firings. +- **Scale.** A lens read describes a direction, not an effect size; `act_top × w_norm` is a pole's + typical write within this corpus. A write read is the pole's average push, which steering shows; + before about L21 of Qwen3-8B, what one firing does depends on its context (§4). +- **Gemma 4.** A neuron's write is what reaches the residual, `s · γ_post ⊙ W_down[:, n]` (its MLP output + passes a post-feedforward RMSNorm, whose scale the lenses hold constant, and the layer's output is + scaled by `layer_scalar` `s`); `w_norm` is its norm. The read direction is the gate and up rows times + the pre-feedforward norm's weight. Sliding-window layers have 8 key-value heads of size 256; every sixth + layer is global, with one of size 512 whose keys are also its values. A head's write is `W_O` times the + post-attention norm's weight. Every document starts with ``, the attention sink, so activation + statistics start at the first real token and `first_*` is at position 1. The base model has no chat + template: its chat slice is plain `User:` / `Assistant:` turns. + +## Neurons + +### `-neurons-reads`: weight-only reads + +| columns | read | of | +|---|---|---| +| `write_R`, `write_R_z` | the R-lens, `softmax(W_U · norm(J^out_L w))`; `_val` are probabilities (the logit lens at the last layer) | the write `w` (Qwen3-8B: `±W_down[:, n]`) | +| `write_S`, `write_S_z` | the S-lens to the layer's output: tokens whose footprint the write imitates | the write | +| `read_R`, `read_R_z` | the R-lens from the MLP input: what the residual says when it drives the pole | the read direction `â ± b̂` | +| `read_S`, `read_S_z` | the S-lens to the MLP input: input tokens that drive the pole | the read direction | + +`â` and `b̂` are the neuron's gate and up rows times the MLP input norm's weight, normalized: `â ± b̂` +is a heuristic direction for each pole. Also per row: `w_norm`, `cos_ab`, `null_share` (the share of the +write in the bottom 1% of singular directions of `W_U diag(γ)`, where entropy neurons write; Stolfo et +al. 2024) and `vocab_skew`, `vocab_kurt` of `W_U · norm(w)` (Gurnee et al. 2024's prediction and +suppression neurons). + +![Read signal by rank](figures/13_rank_depth.png) + +### `-neurons-acts`: activation statistics + +Over every document of four slices, up to 256 tokens each, in bf16: DCLM held out from the lens +corpus, FineWeb-2 Chinese, codeparrot Python, and UltraChat dialogues (63,990 documents and +15,367,795 positions for Qwen3-8B, 63,992 and 15,409,492 for Gemma 4; `docs.parquet`). + +- `act_top`: the median of the 24 top firings, the pole's typical high activation; `act_max`. +- `rate`: the share of positions past `act_top / 4`, from exact counts on a quarter-octave grid (linear + between its points); `rate_` per slice; `pos_share`: where the pole's sign holds; `q50`-`q999`: + quantiles of the activation times the pole's sign, from the same counts; `mean`, `std`. +- `top_doc`, `top_pos`, `top_val`: the 24 top firings; `peak_tokens` and the first 5 `contexts`. +- `first_max`, `first_tokens`, `first_chat`: the first position (left out above, where the attention + sink forms), where activations depend on the token alone: the largest over every kept token, the 3 + tokens that reach it, and the value on the chat transcript's opening token. Many of Qwen3-8B's L2-L3 + poles do their work there (§2). + +![Activation scale and quiet poles by layer](figures/06_activations.png) + +### `-neurons-drivers`: exact token drivers + +Every kept token at position 24 of 8 real documents (4 web, 2 code, 2 chat), averaged over them, bf16: +`drivers` are the 64 tokens with the largest activation at the token itself, `drivers_sum` summed over +it and the 16 positions after. Values are times the pole's sign. For Qwen3-8B, an fp32 check through L9 +shared 98-99% of a pole's top 20 on average (95-99% for `drivers_sum`; §6). + +![Which reads name the exact drivers](figures/11_drivers.png) + +### `-neurons-legible`: which reads hold + +`write_R` (the write's read promotes the tokens that follow the top firings), `write_S` (it names the +peak tokens), `read_R`, `read_S` (the read direction's reads name the peak tokens), each with `_z` and +`_q`; `silent` (no firing, or `act_top` under 0.05), `cur_mode`, `next_mode` (the share of top firings on +one token, or followed by one), `dark`. Share of each band's poles, Qwen3-8B: + +| band | silent | `write_R` | `write_S` | `read_R` | `read_S` | any test | dark | +|---|---|---|---|---|---|---|---| +| L0-8 | 19% | 0% | 11% | 2% | 35% | 36% | 29% | +| L9-12 | 0% | 1% | 1% | 8% | 3% | 11% | 72% | +| L13-20 | 0% | 0% | 0% | 4% | 1% | 5% | 82% | +| L21-27 | 0% | 12% | 2% | 6% | 5% | 19% | 59% | +| L28-35 | 0% | 29% | 0% | 3% | 1% | 31% | 52% | +| all | 5% | 9% | 3% | 4% | 10% | 22% | 57% | + +![Which reads hold for each pole](figures/12_census.png) + +Gemma 4 12B: + +| band | silent | `write_R` | `write_S` | `read_R` | `read_S` | any test | dark | +|---|---|---|---|---|---|---|---| +| L0-11 | 0% | 0% | 1% | 0% | 35% | 35% | 23% | +| L12-23 | 0% | 0% | 4% | 0% | 6% | 7% | 61% | +| L24-35 | 0% | 8% | 0% | 1% | 4% | 11% | 66% | +| L36-47 | 0% | 20% | 0% | 0% | 3% | 22% | 60% | +| all | 0% | 7% | 1% | 0% | 12% | 19% | 52% | + +![Gemma 4: which reads hold for each pole](figures/20_gemma_census.png) + +### `-neurons-labels`: a label for every pole + +Every pole described by Claude Haiku 5.5 from its reads and top contexts (batch API, effort low, adaptive +thinking; §8): `fires` (where it fires, 12 words or fewer), `writes` (what its write pushes the model +toward when amplified), each with a confidence 0-1, and `note`. Each model has its own prompt +(`scripts/prompts//neurons.md` on GitHub), which says which reads hold at each depth, and its +cards show only those. Qwen3-8B's labels were made from an earlier build of its tables, whose reads +kept byte-fallback pieces; Gemma 4's from this release's, from text alone (its cards show no images or +sounds). + +Qwen3-8B, checked blind on 100 poles: firing labels separate held-out top firings from quiet positions at AUROC +0.82 [0.78, 0.85] (another pole's label: 0.56); a judge picks a pole's write label out of four from +steered text 61% of the time [0.52, 0.69] (chance 25%). Firing labels at confidence 0.7 or more score +0.94. They hold best early (83% of L0-L8's firing labels reach AUROC 0.8, 31% of L21-L27's), and write +labels late (80% picked at L28-L35, 41% at L0-L8). Gemma 4's neuron labels are not checked blind yet. + +![Random poles read blind](figures/14_lens_blind.png) + +### `gemma-4-12b-neurons-image`, `gemma-4-12b-neurons-audio`: images and sound + +Gemma 4 has no vision or audio encoder network: an image is 64 slots of 48 × 48-pixel patches (384 +pixels a side) and a sound 64 slots of 40 ms at 16 kHz, each entering the residual through a few norms +and one linear map. One row per pole, beside the text tables: + +| columns | what | +|---|---| +| `read_S_basis` | the read direction through the modality's S-lens to the MLP input, `c · K^mid_L`: coordinates (fp16) on the S-lens basis | +| `read_png` (image) | the 48 × 48 patch the direction reads: `read_S_basis` through the patch embedder back to pixels, at ±3 standard deviations around grey | +| `read_wave` (audio) | the 40 ms waveform it reads, 640 samples at 16 kHz (fp16) | +| `write_R`, `write_R_z` | the write through the modality's R-lens: what it makes the model say in image or audio contexts | +| `label`, `label_z`, `label_mean`, `labels_str` | its top labels by the z of its mean activation over each label's documents (labels on 8 or more documents: 1,643 for images, 981 for sound) | +| `sig`, `stable`, `auroc_heldout` | the top label past the shuffled-label null's 99th percentile for its layer; in the top 5 of both halves of the documents; chosen on even documents, its AUROC on odd ones | +| `top_docs`, `top_vals` | the 16 documents with its largest mean activation (rows of `media/_docs.parquet`) | +| `text_fire_rank`, `text_read_rank`, `text_write_rank` | for a reliable label, its rank among the modality's labels on the text side (1 first, 0.5 chance): firing on the label's words, the text S-lens read, the text R-lens write | + +A media read sums over a document's 64 slots, so it is one pattern wherever it sits, not a map of +where. Read `read_png` as what the pole's input direction looks like in pixels, a projection: added to +held-out images it raises the pole only at L0-L5 (§14). The exemplars say what fires a pole, and the +optimised reads below are patterns that drive it. + +| modality | band | reliable top label | held-out AUROC (median) | its label holds on all three text tests | +|---|---|---|---|---| +| image | L0-L11 | 34% | 0.96 | 0% of 50,561 scored | +| image | L12-L23 | 26% | 0.97 | 3% of 57,930 scored | +| image | L24-L35 | 39% | 0.97 | 2% of 62,387 scored | +| image | L36-L47 | 32% | 0.97 | 1% of 82,871 scored | +| audio | L0-L11 | 51% | 0.91 | 0% of 44,902 scored | +| audio | L12-L23 | 19% | 0.86 | 1% of 33,966 scored | +| audio | L24-L35 | 28% | 0.83 | 0% of 89,105 scored | +| audio | L36-L47 | 18% | 0.78 | 0% of 64,278 scored | + +![The patch each neuron reads, and the patch that drives it](figures/22_media_gallery.png) + +**One concept in three modalities** (§15). 18 poles pass all three text tests for both their +image and their audio label, of 45,138 scored in both (independent lists would share +1.8): `L14 n8313 +` mosque indoor / Arabic; `L15 n146 +` coral reef / Maori; `L15 n8093 −` mosque indoor / Arabic; `L15 n10091 −` giant panda / Mandarin Chinese; `L18 n645 +` Arabian camel / Arabic; `L20 n13624 +` mosque outdoor / Arabic; `L21 n12154 +` mosque outdoor / Arabic; `L23 n2831 +` Sarees / Gujarati; `L31 n10862 −` tacos / Spanish; `L31 n12007 −` mosque outdoor / Arabic; `L33 n5249 +` tacos / Spanish; `L33 n6099 +` pagoda / Mandarin Chinese; `L36 n585 −` tacos / Spanish; `L36 n14109 +` totem pole / Maori; `L37 n6087 −` Pembroke / Welsh; `L37 n7165 +` giant panda / Mandarin Chinese; `L37 n7926 +` mosque outdoor / Arabic; `L41 n9498 −` mosque indoor / Arabic. + +![One concept in text, images and sound](figures/23_crossmodal.png) + +### `gemma-4-12b-neurons-image-optimised`, `gemma-4-12b-neurons-audio-optimised` + +For the 48 poles a layer (L0-L35) with the strongest reliable label: one slot pattern, the same in all +64 slots, started from the S-lens read and optimised by gradient ascent through the model (24 Adam steps +over 128 images or clips; at most 0.08 of the pixel range, or 0.3 of each frame's RMS). `opt_png` or +`opt_wave` (in units of a frame's RMS), `gain` (the pole's mean activation over the slots of 8 held-out +documents with the pattern added, minus without), `gain_lens` (the same for its S-lens read), +`act_base`. Gains are in the pole's activation units: + +| modality | band | poles | held-out gain, median (its S-lens read) | raises the pole | beats its S-lens read | +|---|---|---|---|---|---| +| image | L0-L11 | 576 | 0.195 (-0.0015) | 95% | 96% | +| image | L12-L23 | 576 | 0.00593 (-0.00066) | 70% | 73% | +| image | L24-L35 | 576 | 0.00102 (-5.4e-05) | 56% | 56% | +| audio | L0-L11 | 576 | 0.361 (0.0061) | 99% | 99% | +| audio | L12-L23 | 576 | 0.017 (0.00017) | 86% | 90% | +| audio | L24-L35 | 576 | 5.57e-05 (-3.4e-05) | 51% | 52% | + +The audio test clips are among the audio S-lens's fitting clips (all of ESC-50), though not the +optimisation's. + +## Heads + +A head reads token `v` as its S-lens footprint at layer `L − 1`'s output (the embedding at L0) and writes +into layer `L`'s MLP input. Its OV circuit maps what it reads to what it writes, and its QK circuit +decides where it reads, both over the whole vocabulary (§11). + +### `-heads-reads`: weight-only reads, per token + +| columns | read | +|---|---| +| `ov_R`, `ov_R_neg` | each token's z in its own column of the OV map read through the R-lens: where `v` ranks in what the head makes the model say when it reads `v`. The tokens it copies most, and suppresses most | +| `ov_S`, `ov_S_neg` | the same through the S-lens: whether the write makes the residual look as if `v` were there (the record through L8) | +| `qk_S`, `qk_S_neg` | each key token's z over the vocabulary under the head's mean query: what it attends to and avoids, whatever the query | +| `qk_self_S` | each token's z in its own row of the QK map: where its own token ranks among the keys it favours as a query | +| `ov_R_copy`, `ov_S_copy` | Elhage et al.'s copying score Σλ/Σ\|λ\| of each OV map: +1 copies what it reads, −1 suppresses it | +| `qk_self` | the median `qk_self_S` z over tokens: duplicate-token heads score high | +| `qk_ctx_rho` | Spearman over tokens between `qk_S` and the attention each token receives in context | +| `qk_ov_rho` | Spearman over tokens between `qk_S` and `ov_R`: does the head attend to what it copies? | + +The QK map is `q̃ᵀ R̄ k̃`, with the q/k norms' true derivative averaged over real positions and RoPE +averaged over the head's own attention offsets, footprints at unit length: it reads which tokens a head +favours, not position-only behaviour such as previous-token or induction attention. + +For Qwen3-8B, `qk_self` finds duplicate-token heads at AUROC 0.96. `qk_S` agrees with the attention tokens receive in context (`qk_ctx_rho` past +0.2) for 36% of L0-L8's heads (another head's read: 14%) and 29% of L28-L35's (4%); 12% of L28-L35's heads attend to what they copy (`qk_ov_rho` past +0.2; another head's OV read: 1%). For Gemma 4, at AUROC 0.95. + +### `-heads-acts`: firings and attention patterns + +Over the same documents, from position 16 (a head with few keys attends sharply): + +- `out_top`, `out_max`, `rate`, `rate_`, `q50`-`q999`, `mean`, `std`: as for neurons, of the norm + of the head's output as it reaches the residual (`‖W_O^h z‖`; for Gemma 4, after its post-attention norm); +- `top_doc`, `top_pos`, `top_val`, `src_pos` (the position each firing attends to most, past the first), + `peak_tokens` (query tokens), `src_tokens` (attended tokens), `contexts`; +- `sink`, `prev`, `self`: the mean attention from queries at 16+ to the first position, to the token + before and to itself; `induction`, `duplicate`: over 64 sequences of 64 random tokens said twice, + attention from the second copy to the token after the first occurrence, and to the occurrence; +- `out_R_z`: the firings' outputs read through the R-lens from the MLP input, each token's logit + z-scored across the layer's firings, averaged over the head's. + +### `-heads-drivers`: exact token drivers + +In the same pass as the neurons': `drivers`, the 64 tokens with the largest output norm at their own +position (the token as the query), and `keys`, the 64 that receive the most attention from the 16 +positions after them (the token as the key). + +### `-heads-legible`: which reads hold + +At each top firing, with the attended token: `ov_R` (its OV column promotes the token after the query), +`ov_copy` (its own `ov_R` z: the head promotes what it reads), `ov_S` (its own `ov_S` z), `qk_S` (its +`qk_S` z: the QK read predicts what the head attends to), each with `_z` and `_q` (Benjamini-Hochberg over +all heads); `cur_mode`, `src_mode`; `pattern` (`prev` or `self` past 0.5, `induction` or `duplicate` past +0.3); `dark`: no test, no mode past a third, no pattern. Share of each band's heads, Qwen3-8B: + +| band | `ov_R` | `ov_copy` | `ov_S` | `qk_S` | pattern | any test | dark | +|---|---|---|---|---|---|---|---| +| L0-8 | 1% | 1% | 0% | 0% | 10% | 2% | 41% | +| L9-12 | 0% | 1% | 0% | 0% | 8% | 1% | 78% | +| L13-20 | 1% | 0% | 0% | 0% | 8% | 2% | 74% | +| L21-27 | 5% | 1% | 0% | 0% | 6% | 5% | 61% | +| L28-35 | 27% | 10% | 0% | 0% | 4% | 27% | 38% | +| all | 7% | 3% | 0% | 0% | 7% | 8% | 56% | + +The S-side tests pass for almost no head. S→S copying and the mean query's favourite keys are shared by a +layer's heads, so at a head's own firings they don't tell it from its neighbours; they remain reads of +what each head does (§12). + +![Which reads hold for each head](figures/17_head_census.png) + +Gemma 4 has 16 heads a layer, so a head's mismatched control has 240 pairs, no p-value falls below +1/241, and BH over its 768 heads passes none. Its table adds `_p`, the uncorrected p-value. Share +of each band's heads at p ≤ 0.05 (5% by chance): + +| band | `ov_R` | `ov_copy` | `ov_S` | `qk_S` | pattern | dark | +|---|---|---|---|---|---|---| +| L0-11 | 4% | 7% | 4% | 9% | 15% | 19% | +| L12-23 | 4% | 10% | 3% | 6% | 9% | 70% | +| L24-35 | 8% | 9% | 4% | 6% | 6% | 70% | +| L36-47 | 21% | 17% | 4% | 14% | 8% | 42% | +| all | 9% | 11% | 4% | 9% | 10% | 50% | + +### `-heads-labels`: a label for every head + +Qwen3-8B: + +Every head described by Claude Haiku 5.5 from its card (batch API, effort low, adaptive thinking): +`fires` (where its output is large), `attends` (what it attends to there) and `writes` (what its +output promotes), each with a confidence 0-1, and `note`. The cards show the head's pattern scores, +output scale, OV and QK reads, drivers and first 5 top contexts; nothing about its other top firings. +The prompt is `scripts/prompts/qwen3-8b/heads.md` on GitHub. + +**Checked blind** on 100 random heads, 20 a band, by Claude Sonnet 5.5: + +- **Firing:** given a head's `fires` and `attends` labels and 8 contexts, 4 of its held-out top firings (ranks 6-24) and 4 of another head of its band, the scorer separates them at AUROC 0.71 [0.65, 0.77]; a third head's labels on the same contexts score 0.51. +- **Writes:** given what the head's firings actually promote in context (`out_R_z`, not on the card), a judge picks its `writes` label out of four from its band 49% of the time [39, 60] (chance 25%). + +| band | firing AUROC | control | writes picked | +|---|---|---|---| +| L0-L8 | 0.74 | 0.50 | 33% | +| L9-L12 | 0.70 | 0.61 | 56% | +| L13-L20 | 0.79 | 0.36 | 25% | +| L21-L27 | 0.60 | 0.56 | 55% | +| L28-L35 | 0.73 | 0.51 | 79% | + +Gemma 4 12B: its write labels are at chance, so read them as guesses. + +Every head described by Claude Haiku 5.5 from its card (batch API, effort low, adaptive thinking): +`fires` (where its output is large), `attends` (what it attends to there) and `writes` (what its +output promotes), each with a confidence 0-1, and `note`. The cards show the head's pattern scores, +output scale, OV and QK reads, drivers and first 5 top contexts; nothing about its other top firings. +The prompt is `scripts/prompts/gemma-4-12b/heads.md` on GitHub. + +**Checked blind** on 80 random heads, 20 a band, by Claude Sonnet 5.5: + +- **Firing:** given a head's `fires` and `attends` labels and 8 contexts, 4 of its held-out top firings (ranks 6-24) and 4 of another head of its band, the scorer separates them at AUROC 0.71 [0.64, 0.79]; a third head's labels on the same contexts score 0.47. +- **Writes:** given what the head's firings actually promote in context (`out_R_z`, not on the card), a judge picks its `writes` label out of four from its band 22% of the time [13, 30] (chance 25%). + +| band | firing AUROC | control | writes picked | +|---|---|---|---| +| L0-L4 | 0.62 | 0.44 | 25% | +| L5-L13 | 0.80 | 0.49 | 15% | +| L14-L32 | 0.75 | 0.52 | 32% | +| L33-L47 | 0.69 | 0.41 | 15% | + +### `gemma-4-12b-heads-media`: heads in image and audio contexts + +64 labelled images (mini-ImageNet) and 64 sounds (ESC-50, the classes in turn), each in the media prompt +and followed by ` a