Downloads · 30 days
13
17% of all-time downloads
legible-weights/sae-gpt2-small-l6-v0.1
sae-gpt2-small-l6-v0.1 is a machine learning model from legible-weights. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as mit.
A TopK sparse autoencoder for the post-block residual stream of layer 6 in openai-community/gpt2. Trained as one half of a controlled cross- paradigm comparison against legible-weights/sae-mdlm-owt-l6-v0.1 — a matched…
Downloads · 30 days
13
17% of all-time downloads
All-time downloads
75
Public
Repo size
75.6 MB
Likes
0
Public
Click a slice to open those files.
.safetensors75.6 MB · 100%
From the Hugging Face model README
A TopK sparse autoencoder for the post-block residual stream of layer 6
in openai-community/gpt2. Trained as one half of a controlled cross-
paradigm comparison against legible-weights/sae-mdlm-owt-l6-v0.1
— a matched-scale SAE on the MDLM masked-diffusion LM trained on the
same corpus.
The two SAEs were trained with identical hyperparameters on activations from OpenWebText. The only axis of variation is the base model's training objective (causal next-token vs. discrete masked diffusion).
| field | value |
|---|---|
| arch | TopK SAE (Gao et al. 2024) |
| d_in | 768 (GPT-2 small hidden size) |
| d_hidden | 12 288 (16× expansion) |
| k | 32 |
| params | 18.9 M |
| field | value |
|---|---|
| dataset | Skylion007/openwebtext (streamed) |
| n_tokens | 10,000,000 |
| seq_len | 512 |
| exclude_first_n | 4 (skip outlier prefix positions) |
| batch_size | 4,096 |
| optimizer | Adam, lr 5e-4 |
| n_epochs | 4 |
| seed | 0 |
| hardware | 1× RTX 4090 |
| wall time | ~3 min end-to-end |
| metric | value |
|---|---|
| Final MSE | 0.85 |
| Final EV | 0.86 |
| Final L0 | 32 |
On 30k held-out OpenWebText tokens, an activation-correlation alignment with legible-weights/sae-mdlm-owt-l6-v0.1 shows:
which, the)Full writeup, methodology, and reproducible pipeline: github.com/legibleweights/diffusion-vs-ar-saes
import torch
from huggingface_hub import hf_hub_download
from safetensors.torch import load_file
class TopKSAE(torch.nn.Module):
def __init__(self, d_in=768, d_hidden=12288, k=32):
super().__init__()
self.k = k
self.encoder = torch.nn.Linear(d_in, d_hidden, bias=True)
self.decoder = torch.nn.Linear(d_hidden, d_in, bias=False)
self.pre_bias = torch.nn.Parameter(torch.zeros(d_in))
def forward(self, x):
pre = self.encoder(x - self.pre_bias)
vals, idx = pre.topk(self.k, dim=-1)
vals = torch.relu(vals)
acts = torch.zeros_like(pre)
acts.scatter_(-1, idx, vals)
return self.decoder(acts) + self.pre_bias, acts
path = hf_hub_download("legible-weights/sae-gpt2-small-l6-v0.1", "sae.safetensors")
sae = TopKSAE()
sae.load_state_dict(load_file(path))
Hook point: output of model.transformer.h[6].
MIT.