Views
No views yet
OhhMoo/sae-rl-qwen05b-strict-activations.results_full.csv. Original MSE/NMSE/dead latent results in results.csv.| Exp | K | Val MSE | NMSE | Dead % | Delta Loss | Frac Rec % |
|---|---|---|---|---|---|---|
| 4x | 220 | 0.0228 | 0.000479 | 12.9% | 0.247 | 92.9% |
| 8x | 220 | 0.0245 | 0.000515 | 20.6% | 0.354 | 90.1% |
| 16x | 220 | 0.0298 | 0.000627 | 33.0% | 0.406 | 88.8% |
| 4x | 128 | 0.0340 | 0.000715 | 18.8% | 0.634 | 83.5% |
| 8x | 128 | 0.0369 | 0.000776 | 31.3% | 0.788 | 80.3% |
| Exp | Threshold | L0 | Val MSE | NMSE | Dead % | Delta Loss | Frac Rec % |
|---|---|---|---|---|---|---|---|
| 4x | 0.5 | 77 | 0.0435 | 0.000915 | 24.0% | 0.813 | 79.8% |
| 8x | 0.5 | 100 | 0.0418 | 0.000880 | 25.5% | 1.001 | 76.2% |
| 4x | 0.1 | 1596 | 0.0007 | 0.000014 | 8.6% | -0.014 | 100.4% |
| 8x | 0.1 | 1962 | 0.0008 | 0.000017 | 18.4% | 0.043 | 98.7% |
1class BatchTopKSAE(nn.Module):
2 def __init__(self, d_in, d_sae, k):
3 super().__init__()
4 self.k = k
5 self.b_pre = nn.Parameter(torch.zeros(d_in))
6 self.encoder = nn.Linear(d_in, d_sae, bias=True)
7 self.decoder = nn.Linear(d_sae, d_in, bias=True)
8
9 def encode(self, x):
10 x_centered = x - self.b_pre
11 pre_acts = self.encoder(x_centered)
12 n_keep = int(pre_acts.numel() * self.k / pre_acts.shape[-1])
13 threshold = pre_acts.reshape(-1).topk(n_keep).values.min()
14 acts = pre_acts * (pre_acts >= threshold).float()
15 return F.relu(acts)
16
17 def decode(self, z):
18 return self.decoder(z) + self.b_pre
19
20 def forward(self, x):
21 z = self.encode(x)
22 recon = self.decode(z)
23 return recon, z1from huggingface_hub import hf_hub_download
2import torch
3
4path = hf_hub_download(
5 repo_id="jakelipner/sae-grid-search-layer12",
6 filename="BatchTopK_exp8x_k220.pt",
7 repo_type="model"
8)
9
10sae = BatchTopKSAE(d_in=896, d_sae=7168, k=220)
11sae.load_state_dict(torch.load(path, map_location="cpu"))
12sae.eval()
13
14x_hat, z = sae(x) # x: (N, 896) float32{Type}_exp{expansion}x_k{K}.pt for BatchTopK and TopK.
JumpReLU_exp{expansion}x_t{threshold}.pt for JumpReLU.results.csv — MSE, NMSE, dead latents (BatchTopK and TopK only)results_full.csv — all metrics including delta loss and frac_rec for all three architecturesOhhMoo/sae-rl-qwen05b-strict-activations instruct_base layer 12