Update README.md
Browse files
README.md
CHANGED
@@ -8,18 +8,22 @@ If you want to use them, do
|
|
8 |
|
9 |
```
|
10 |
import torch
|
|
|
11 |
|
12 |
-
def load_feat_acts(fname):
|
13 |
-
|
|
|
14 |
|
15 |
# The matrices are stored in space-efficient formats that're incompatible with torch's sparse csr tensor.
|
16 |
# Convert them back before constructing the matrix.
|
17 |
csr_kwargs['crow_indices'] = csr_kwargs['crow_indices'].int()
|
18 |
-
csr_kwargs['col_indices'] = csr_kwargs['
|
19 |
-
csr_kwargs['values'] = csr_kwargs['values'].float()/255
|
20 |
|
21 |
feat_acts = torch.sparse_csr_tensor(**csr_kwargs)
|
22 |
return feat_acts
|
|
|
|
|
23 |
```
|
24 |
|
25 |
The activations are for the train split in https://huggingface.co/datasets/noanabeshima/TinyModelTokIds
|
|
|
8 |
|
9 |
```
|
10 |
import torch
|
11 |
+
from huggingface_hub import hf_hub_download
|
12 |
|
13 |
+
def load_feat_acts(fname, only_active_docs=False):
|
14 |
+
local_path = hf_hub_download(repo_id="noanabeshima/tiny_model_cached_acts", filename=fname)
|
15 |
+
csr_kwargs = torch.load(local_path)
|
16 |
|
17 |
# The matrices are stored in space-efficient formats that're incompatible with torch's sparse csr tensor.
|
18 |
# Convert them back before constructing the matrix.
|
19 |
csr_kwargs['crow_indices'] = csr_kwargs['crow_indices'].int()
|
20 |
+
csr_kwargs['col_indices'] = csr_kwargs['col_indices'].int()
|
21 |
+
csr_kwargs['values'] = (csr_kwargs['values'].float()/255)
|
22 |
|
23 |
feat_acts = torch.sparse_csr_tensor(**csr_kwargs)
|
24 |
return feat_acts
|
25 |
+
|
26 |
+
feat_acts = load_feat_acts(f"mlp_map_test/M2_S-2_R1_P0/{300}.pt").to_dense()
|
27 |
```
|
28 |
|
29 |
The activations are for the train split in https://huggingface.co/datasets/noanabeshima/TinyModelTokIds
|