Update model card with comprehensive documentation
Browse files
README.md
CHANGED
|
@@ -1,75 +1,187 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
base_model: Qwen/Qwen2.5-VL-7B
|
| 4 |
-
|
| 5 |
-
- circuit-discovery
|
| 6 |
-
- transcoders
|
| 7 |
-
- interpretability
|
| 8 |
-
- sparse-autoencoders
|
| 9 |
-
- qwen2.5-vl
|
| 10 |
-
library_name: pytorch
|
| 11 |
---
|
| 12 |
|
| 13 |
# Qwen2.5-VL-7B Circuit-Level Transcoders (CLT)
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
- **Type**: Circuit-Level Transcoders (CLT)
|
| 21 |
-
- **Layers**: 27 transcoders (L0-L26)
|
| 22 |
-
- **Sparsity**: 12% L0 (TopK)
|
| 23 |
-
- **File Size**: ~113MB per layer (~3GB total)
|
| 24 |
-
- **Training**: Each layer trained for 5000 steps
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
-
- `transcoder_L0.pt` through `transcoder_L26.pt`
|
| 30 |
|
| 31 |
-
|
| 32 |
|
| 33 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
```python
|
| 36 |
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
layer_num = 12
|
| 40 |
-
transcoder = torch.load(f'transcoder_L{layer_num}.pt')
|
| 41 |
|
| 42 |
-
# The transcoder can be used for circuit discovery and suppression
|
| 43 |
-
# in conjunction with the Qwen2.5-VL-7B model
|
| 44 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
## Training Details
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
- **Optimizer**: AdamW
|
| 49 |
-
- **
|
| 50 |
-
- **
|
| 51 |
-
- **
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
|
| 61 |
|
| 62 |
-
```bibtex
|
| 63 |
-
@misc{qwen2p5vl-7b-clt,
|
| 64 |
-
title={Circuit-Level Transcoders for Qwen2.5-VL-7B},
|
| 65 |
-
author={KokosDev},
|
| 66 |
-
year={2025},
|
| 67 |
-
publisher={HuggingFace},
|
| 68 |
-
howpublished={\url{https://huggingface.co/KokosDev/qwen2p5vl-7b-clt}}
|
| 69 |
-
}
|
| 70 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
##
|
| 73 |
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
library_name: pytorch
|
| 3 |
+
tags:
|
| 4 |
+
- circuit-discovery
|
| 5 |
+
- transcoders
|
| 6 |
+
- interpretability
|
| 7 |
+
- sparse-autoencoders
|
| 8 |
+
- qwen2.5-vl
|
| 9 |
+
- vision-language
|
| 10 |
+
- mechanistic-interpretability
|
| 11 |
+
- clt
|
| 12 |
license: apache-2.0
|
| 13 |
+
language:
|
| 14 |
+
- en
|
| 15 |
+
- zh
|
| 16 |
+
metrics:
|
| 17 |
+
- reconstruction_loss
|
| 18 |
+
- l0_sparsity
|
| 19 |
base_model: Qwen/Qwen2.5-VL-7B
|
| 20 |
+
pipeline_tag: feature-extraction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
---
|
| 22 |
|
| 23 |
# Qwen2.5-VL-7B Circuit-Level Transcoders (CLT)
|
| 24 |
|
| 25 |
+
High-quality Circuit-Level Transcoders for **Qwen2.5-VL-7B**, trained with TopK sparsity for optimal interpretability and circuit discovery.
|
| 26 |
+
|
| 27 |
+
## π― Key Features
|
| 28 |
|
| 29 |
+
- β
**27 layers** (L0 β L26)
|
| 30 |
+
- β
**Fixed 12% L0 sparsity**: Consistent activation patterns across all layers
|
| 31 |
+
- β
**TopK activation**: Deterministic feature selection for reproducibility
|
| 32 |
+
- β
**Large feature space**: 8192 features per layer (2.29x expansion)
|
| 33 |
+
- β
**Excellent reconstruction**: Validation loss 10.3-19.1
|
| 34 |
|
| 35 |
+
## π Training Quality
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
| Layer Range | Val Loss | L0 Sparsity | Status |
|
| 38 |
+
|-------------|----------|-------------|--------|
|
| 39 |
+
| L0-L6 | 12.6-19.1 | 12.0% | β
Excellent |
|
| 40 |
+
| L7-L13 | 11.8-15.2 | 12.0% | β
Excellent |
|
| 41 |
+
| L14-L20 | 10.9-13.8 | 12.0% | β
Excellent |
|
| 42 |
+
| L21-L26 | 10.3-12.2 | 12.0% | β
Excellent |
|
| 43 |
|
| 44 |
+
All layers maintain consistent 12% L0 sparsity with strong reconstruction quality.
|
|
|
|
| 45 |
|
| 46 |
+
## π Quick Start
|
| 47 |
|
| 48 |
+
### Installation
|
| 49 |
+
|
| 50 |
+
```bash
|
| 51 |
+
pip install torch huggingface-hub
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
### Loading Transcoders
|
| 55 |
|
| 56 |
```python
|
| 57 |
import torch
|
| 58 |
+
from huggingface_hub import hf_hub_download
|
| 59 |
+
|
| 60 |
+
# Download a specific layer
|
| 61 |
+
layer_idx = 12
|
| 62 |
+
transcoder_path = hf_hub_download(
|
| 63 |
+
repo_id="KokosDev/qwen2p5vl-7b-clt",
|
| 64 |
+
filename=f"transcoder_L{layer_idx}.pt"
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
# Load the transcoder
|
| 68 |
+
transcoder = torch.load(transcoder_path, map_location="cpu")
|
| 69 |
+
print(f"Transcoder keys: {transcoder.keys()}")
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
### Using for Circuit Discovery
|
| 73 |
+
|
| 74 |
+
```python
|
| 75 |
+
import torch
|
| 76 |
+
import torch.nn.functional as F
|
| 77 |
+
|
| 78 |
+
# Load transcoder
|
| 79 |
+
transcoder = torch.load("transcoder_L12.pt")
|
| 80 |
+
encoder = transcoder['encoder']
|
| 81 |
+
decoder = transcoder['decoder']
|
| 82 |
+
|
| 83 |
+
# Encode activations to sparse features
|
| 84 |
+
activations = torch.randn(1, 128, 3584) # [batch, seq, hidden_dim]
|
| 85 |
+
features = F.relu(encoder(activations)) # [batch, seq, 8192]
|
| 86 |
+
|
| 87 |
+
# TopK sparsification (12% = ~983 features)
|
| 88 |
+
k = int(0.12 * features.shape[-1])
|
| 89 |
+
topk_values, topk_indices = torch.topk(features, k, dim=-1)
|
| 90 |
+
sparse_features = torch.zeros_like(features)
|
| 91 |
+
sparse_features.scatter_(-1, topk_indices, topk_values)
|
| 92 |
+
|
| 93 |
+
# Reconstruct
|
| 94 |
+
reconstructed = decoder(sparse_features) # [batch, seq, 3584]
|
| 95 |
+
```
|
| 96 |
|
| 97 |
+
## π Model Architecture
|
|
|
|
|
|
|
| 98 |
|
|
|
|
|
|
|
| 99 |
```
|
| 100 |
+
Input (3584) β Encoder β ReLU β TopK(12%) β Features (8192) β Decoder β Output (3584)
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
- **Hidden dim**: 3584 (Qwen2.5-VL-7B residual stream)
|
| 104 |
+
- **Feature dim**: 8192 (sparse features, 2.29x expansion)
|
| 105 |
+
- **Activation**: ReLU + TopK
|
| 106 |
+
- **Sparsity**: Fixed 12% L0 (~983 active features per token)
|
| 107 |
+
- **Architecture**: Linear encoder/decoder with bias
|
| 108 |
|
| 109 |
+
## π¬ Training Details
|
| 110 |
|
| 111 |
+
### Dataset
|
| 112 |
+
- **Source**: Multimodal vision-language data
|
| 113 |
+
- **Preprocessing**: Cached activations from Qwen2.5-VL-7B
|
| 114 |
+
- **Validation**: Held-out samples for quality monitoring
|
| 115 |
+
|
| 116 |
+
### Hyperparameters
|
| 117 |
+
- **Steps**: 5,000 per layer
|
| 118 |
+
- **Learning rate**: 3e-4 with cosine schedule
|
| 119 |
- **Optimizer**: AdamW
|
| 120 |
+
- **Sparsity**: TopK with k = 12% of features
|
| 121 |
+
- **Validation interval**: 200 steps
|
| 122 |
+
- **Batch size**: Optimized for GPU memory
|
| 123 |
+
|
| 124 |
+
### Training Infrastructure
|
| 125 |
+
- **GPU**: NVIDIA A100/H100
|
| 126 |
+
- **Framework**: PyTorch 2.0+ with mixed precision
|
| 127 |
+
- **Total layers**: 27 (L0-L26)
|
| 128 |
+
|
| 129 |
+
## π― CLT vs Traditional SAEs
|
| 130 |
+
|
| 131 |
+
Circuit-Level Transcoders (CLTs) offer several advantages:
|
| 132 |
+
|
| 133 |
+
1. **Deterministic sparsity**: TopK ensures exactly 12% features active
|
| 134 |
+
2. **Reproducible**: Same input always activates same features
|
| 135 |
+
3. **Interpretable**: Fixed sparsity makes feature analysis consistent
|
| 136 |
+
4. **Efficient**: TopK is faster than L1 regularization during inference
|
| 137 |
+
|
| 138 |
+
## π Use Cases
|
| 139 |
|
| 140 |
+
- **Circuit discovery**: Identify which features activate for specific inputs
|
| 141 |
+
- **Mechanistic interpretability**: Understand vision-language model internals
|
| 142 |
+
- **Feature analysis**: Study what concepts are encoded at each layer
|
| 143 |
+
- **Ablation studies**: Remove specific features to test causal relationships
|
| 144 |
+
- **Activation steering**: Modify feature activations to control model behavior
|
| 145 |
|
| 146 |
+
## π Related Resources
|
| 147 |
|
| 148 |
+
- [Qwen2.5-VL-7B Model](https://huggingface.co/Qwen/Qwen2.5-VL-7B)
|
| 149 |
+
- [PLT Transcoders](https://huggingface.co/KokosDev/qwen2p5vl-7b-plt) - Paired Linear Transcoders for the same model
|
| 150 |
+
- [Sparse Autoencoders Research](https://transformer-circuits.pub/2023/monosemantic-features)
|
| 151 |
|
| 152 |
+
## π File Structure
|
| 153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
```
|
| 155 |
+
qwen2p5vl-7b-clt/
|
| 156 |
+
βββ README.md
|
| 157 |
+
βββ .gitattributes
|
| 158 |
+
βββ transcoder_L0.pt (113 MB)
|
| 159 |
+
βββ transcoder_L1.pt (113 MB)
|
| 160 |
+
βββ ...
|
| 161 |
+
βββ transcoder_L26.pt (113 MB)
|
| 162 |
+
```
|
| 163 |
+
|
| 164 |
+
Each `.pt` file contains:
|
| 165 |
+
- `encoder`: Linear layer (3584 β 8192)
|
| 166 |
+
- `decoder`: Linear layer (8192 β 3584)
|
| 167 |
+
- Training metadata and hyperparameters
|
| 168 |
+
|
| 169 |
+
## π License
|
| 170 |
+
|
| 171 |
+
Apache 2.0 - Same as Qwen2.5-VL-7B base model
|
| 172 |
|
| 173 |
+
## π Acknowledgments
|
| 174 |
|
| 175 |
+
- Qwen team for the excellent Qwen2.5-VL-7B vision-language model
|
| 176 |
+
- Anthropic for pioneering sparse autoencoder research
|
| 177 |
+
- The mechanistic interpretability community
|
| 178 |
+
|
| 179 |
+
## π§ Contact
|
| 180 |
+
|
| 181 |
+
For questions, issues, or collaboration opportunities, please open an issue in this repository.
|
| 182 |
+
|
| 183 |
+
---
|
| 184 |
|
| 185 |
+
**Model Version**: v1.0
|
| 186 |
+
**Last Updated**: October 2025
|
| 187 |
+
**Total Size**: ~3.2 GB (27 layers Γ 113 MB)
|