sae_token_programs / README.md
AmiriHayes's picture
Upload folder using huggingface_hub
cfd4eec verified
|
Raw History Blame Contribute Delete
2.38 kB
---
license: mit
task_categories: [feature-extraction]
tags: [interpretability, sparse-autoencoder, gpt2, program-synthesis]
---
# Programs for GPT-2 SAE features
A readable Python program for each of **301,090 SAE features** of GPT-2 small —
all 13 `gpt2-small-res-jb` checkpoints (`blocks.0-11.hook_resid_pre` plus
`blocks.11.hook_resid_post`), 24,576 features each.
Each program is an ordinary function that takes the tokens seen so far and
returns whether that feature fires:
```python
def prog_L06F08045(input_tokens):
"""3 token families, 4 surface forms (train F1 of the uncapped optimum: 0.958)."""
fire = {
' George', 'George', # george (3,592 firings)
' Osama', # osama (214 firings)
'ORGE', # orge (28 firings)
}
return ('george-family', 1) if input_tokens[-1] in fire else ('no match', 0)
```
Fitted on **289,658 OpenWebText sequences** (36,786,566 read positions), scored
on a structurally disjoint 10,000-sequence test split. No LLM was used to write
these — the token sets are chosen by greedy marginal F1.
## Layout
| path | what |
|---|---|
| `programs/layer{00..12}/` | the programs, **100 per file**, in thousand-blocks |
| `scores/layer{00..12}.csv` | per-feature test F1, precision, recall, token count |
| `synthesis_attempt_1/` | 387 LLM-written layer-6 programs — an earlier attempt, kept for comparison |
| `activation_value_program/` | one program that predicts the activation **value**, not just whether it fires |
## Results
Median test F1 by layer, and the single best program in each:
| | L0 | L1 | L2 | L3 | L4 | L5 | L6 | L7 | L8 | L9 | L10 | L11 | L12 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| median | .98 | .86 | .80 | .73 | .65 | .55 | .41 | .30 | .23 | .19 | .17 | .14 | .13 |
| best | 1.00 | 1.00 | 1.00 | 1.00 | .98 | .99 | .97 | .96 | .95 | .95 | .94 | .93 | .90 |
The median falls steeply with depth while the best barely moves. Depth doesn't
cap what a token-only rule can reach — it changes how many features are
reachable by one.
## Caveats
- `scores/` reports test F1; the docstring inside each program reports the
*train* optimum. They are different numbers.
- Layers 0–3 have fewer than 24,576 programs because some features fire only at
position 0 (attention-sink features) and are excluded from fitting.