Instructions to use analist/SAE-Phi-3-mini-4k-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- SAELens
How to use analist/SAE-Phi-3-mini-4k-instruct with SAELens:
# pip install sae-lens from sae_lens import SAE sae, cfg_dict, sparsity = SAE.from_pretrained( release = "RELEASE_ID", # e.g., "gpt2-small-res-jb". See other options in https://github.com/jbloomAus/SAELens/blob/main/sae_lens/pretrained_saes.yaml sae_id = "SAE_ID", # e.g., "blocks.8.hook_resid_pre". Won't always be a hook point ) - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files- README.md +36 -0
- layer_21/cfg.json +18 -0
- layer_21/sae_weights.safetensors +3 -0
- layer_22/cfg.json +18 -0
- layer_22/sae_weights.safetensors +3 -0
- layer_23/cfg.json +18 -0
- layer_23/sae_weights.safetensors +3 -0
README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- sae
|
| 4 |
+
- saelens
|
| 5 |
+
- phi-3
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
# Sparse Autoencoders for Phi-3-mini-4k-instruct
|
| 9 |
+
|
| 10 |
+
These are trained Sparse Autoencoders (SAEs) for the `microsoft/Phi-3-mini-4k-instruct` model, compatible with the `sae_lens` library.
|
| 11 |
+
|
| 12 |
+
## Model Details
|
| 13 |
+
* **Model**: `microsoft/Phi-3-mini-4k-instruct`
|
| 14 |
+
* **Layers**: [21, 22, 23]
|
| 15 |
+
* **Architecture**: Standard (ReLU) with pre-encoder centring (`b_dec` applied to input).
|
| 16 |
+
* **Expansion Factor**: 16x (49152 features)
|
| 17 |
+
* **Tokens Trained**: ~550M
|
| 18 |
+
|
| 19 |
+
## Datasets
|
| 20 |
+
* NuminaMath-CoT: 40%
|
| 21 |
+
* HH-RLHF: 20%
|
| 22 |
+
* FineWeb: 20%
|
| 23 |
+
* JBB/HarmBench/AdvBench: 20%
|
| 24 |
+
|
| 25 |
+
## Usage with SAELens
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
from sae_lens import SAE
|
| 29 |
+
|
| 30 |
+
# Load the SAE for a specific layer, e.g., layer 21
|
| 31 |
+
sae, cfg_dict, sparsity = SAE.from_pretrained(
|
| 32 |
+
release="analist/SAE-Phi-3-mini-4k-instruct",
|
| 33 |
+
sae_id="layer_21",
|
| 34 |
+
device="cuda"
|
| 35 |
+
)
|
| 36 |
+
```
|
layer_21/cfg.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architecture": "standard",
|
| 3 |
+
"d_in": 3072,
|
| 4 |
+
"d_sae": 49152,
|
| 5 |
+
"activation_fn_str": "relu",
|
| 6 |
+
"apply_b_dec_to_input": true,
|
| 7 |
+
"finetuning_scaling_factor": false,
|
| 8 |
+
"context_size": 1024,
|
| 9 |
+
"model_name": "microsoft/Phi-3-mini-4k-instruct",
|
| 10 |
+
"hook_name": "blocks.21.hook_resid_post",
|
| 11 |
+
"hook_layer": 21,
|
| 12 |
+
"hook_head_index": null,
|
| 13 |
+
"prepend_bos": true,
|
| 14 |
+
"dataset_path": "mixed-datasets",
|
| 15 |
+
"dataset_trust_remote_code": true,
|
| 16 |
+
"normalize_activations": "none",
|
| 17 |
+
"dtype": "bfloat16"
|
| 18 |
+
}
|
layer_21/sae_weights.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2b24d2e2331fb7eb66008fa8a7ee7ae768817b62be6a69fd30257aeeea40e074
|
| 3 |
+
size 604477848
|
layer_22/cfg.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architecture": "standard",
|
| 3 |
+
"d_in": 3072,
|
| 4 |
+
"d_sae": 49152,
|
| 5 |
+
"activation_fn_str": "relu",
|
| 6 |
+
"apply_b_dec_to_input": true,
|
| 7 |
+
"finetuning_scaling_factor": false,
|
| 8 |
+
"context_size": 1024,
|
| 9 |
+
"model_name": "microsoft/Phi-3-mini-4k-instruct",
|
| 10 |
+
"hook_name": "blocks.22.hook_resid_post",
|
| 11 |
+
"hook_layer": 22,
|
| 12 |
+
"hook_head_index": null,
|
| 13 |
+
"prepend_bos": true,
|
| 14 |
+
"dataset_path": "mixed-datasets",
|
| 15 |
+
"dataset_trust_remote_code": true,
|
| 16 |
+
"normalize_activations": "none",
|
| 17 |
+
"dtype": "bfloat16"
|
| 18 |
+
}
|
layer_22/sae_weights.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e63d6872a342300c59ca25a16b593c67a73e6dc8e62b401daa7e8bcc38396cbf
|
| 3 |
+
size 604477848
|
layer_23/cfg.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architecture": "standard",
|
| 3 |
+
"d_in": 3072,
|
| 4 |
+
"d_sae": 49152,
|
| 5 |
+
"activation_fn_str": "relu",
|
| 6 |
+
"apply_b_dec_to_input": true,
|
| 7 |
+
"finetuning_scaling_factor": false,
|
| 8 |
+
"context_size": 1024,
|
| 9 |
+
"model_name": "microsoft/Phi-3-mini-4k-instruct",
|
| 10 |
+
"hook_name": "blocks.23.hook_resid_post",
|
| 11 |
+
"hook_layer": 23,
|
| 12 |
+
"hook_head_index": null,
|
| 13 |
+
"prepend_bos": true,
|
| 14 |
+
"dataset_path": "mixed-datasets",
|
| 15 |
+
"dataset_trust_remote_code": true,
|
| 16 |
+
"normalize_activations": "none",
|
| 17 |
+
"dtype": "bfloat16"
|
| 18 |
+
}
|
layer_23/sae_weights.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8158d8832404c76e0747d3eedcc9ceada04c9081a53f7e8f5c19e7ef3a751fad
|
| 3 |
+
size 604477848
|