File size: 3,312 Bytes
2109cc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
license: mit
pretty_name: LLM Modularity — per-task neuron attribution scores
tags:
  - interpretability
  - attribution-patching
  - mechanistic-interpretability
size_categories:
  - 1B<n<10B
---

# Per-task neuron attribution scores for *Modular Cognitive Architecture Emerges in Large Language Models*

Code and analysis pipeline: <https://github.com/Pengrui-Han/LLM_Modularity>

This dataset contains the raw attribution-patching tensors that the GitHub
release omits (they are ~6 GB). With these files you can run every
overlap / ablation / statistics script in the repo without re-running
attribution patching on a GPU.

## Layout

```
results/<model>/<domain>/<task>/
    neuron_attribution.pt          float32 tensor, shape [num_layers, intermediate_size]
    sorted_indices_positive.npy    int array, shape [n_positive, 2]  (layer, unit), best first
    attribution_meta.json          {"total_units", "num_layers", "num_units"}
    baselines.json                 clean / corrupted baselines, both-correct accuracy, example indices
```

`<model>` is the HuggingFace id with `/` and `.` replaced by `_` and `-`
(e.g. `Qwen_Qwen2-5-32B-Instruct`). `<domain>` is one of `Lan`, `MD`,
`ToM`, `phys`.

Models: Qwen2.5-32B-Instruct, Qwen2.5-72B-Instruct, OLMo-2-0325-32B-Instruct,
Llama-3.1-70B-Instruct, Mistral-Large-Instruct-2407,
Mistral-Small-24B-Instruct-2501 (the six models in the paper's main analysis).

Only tasks that passed the 60% both-correct inclusion filter have a
`neuron_attribution.pt` for a given model, so the task set differs slightly
per model (35–46 tasks). The task set is exactly the one in the GitHub
release (every task that has an `attribution_meta.json` there).

## What the numbers are

For each MLP neuron *i* (the input to `mlp.down_proj`, i.e. the
post-activation hidden of size `intermediate_size`), evaluated at the final
prompt token with full-sequence teacher forcing:

```
attribution_i = (clean_act_i − corrupted_act_i) · ∂ metric / ∂ act_i
```

where the gradient is taken on the corrupted-prompt forward pass and the
metric is the normalized log-probability of the correct answer
(1 = clean baseline, 0 = corrupted baseline). Positive values mean that
restoring the clean activation moves the model toward its clean behaviour.
Scores are summed over the both-correct examples of a task.

## Selecting a task circuit

The paper uses the top 0.1% positively attributed neurons:

```python
import torch, numpy as np
attr = torch.load("results/<model>/<domain>/<task>/neuron_attribution.pt").numpy()
L, U = attr.shape
k = max(1, int(L * U * 0.1 / 100))          # 0.1 % ; use 1.0 for 1 %
idx = np.load("results/<model>/<domain>/<task>/sorted_indices_positive.npy")[:k]  # (layer, unit) pairs
```

Equivalently, flatten `attr`, keep entries `> 0`, sort descending, take the
first `k`. `sorted_indices_positive.npy` is just that ordering precomputed.

## Download

```python
from huggingface_hub import snapshot_download
snapshot_download("barryhpr/LLM_Modularity_attribution", repo_type="dataset",
                  local_dir="LLM_Modularity")        # drops files into results/…
```

Or a single model: add `allow_patterns=["results/allenai_OLMo-2-0325-32B-Instruct/**"]`.

## Citation

See the GitHub repository; citation will be added upon publication.