# A suite of Vision Sparse Autoencoders 

CLIP-Scope?
===========

Inspired by [Gemma-Scope](https://ai.google.dev/gemma/docs/gemma_scope) We trained 8 Sparse Autoencoders each on 1.2 billion tokens on different layers of a Vision Transformer. These (along with more technical details) can be accessed on [huggingface](https://huggingface.co/lewington/CLIP-ViT-L-scope). We also released a [pypi package](https://pypi.org/project/clipscope/) for ease of use.

We hope that this will allow researchers to experiment with vision transformer interpretability without having to go through the drudgery of training sparse auto encoders from scratch.

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/761927393a546011af72a9b62e51bef8da6e3235c422f0f6.png)

the top 9 activating images in LAION for feature 392 of the SA trained on layer 20

Vital Statistics
----------------

*   Model: [laion/CLIP-ViT-L-14-laion2B-s32B-b82K](https://huggingface.co/laion/CLIP-ViT-L-14-laion2B-s32B-b82K)
*   Number of tokens trained per autoencoder: 1.2 Billion
*   Token type: all 257 image tokens (as opposed to just the CLS token)
*   Number of unique images trained per autoencoder: 4.5 Million
*   Training Dataset: [Laion-2b](https://huggingface.co/datasets/laion/laion2B-multi-joined-translated-to-en)
*   SAE Architecture: topk with k=32
*   Layer Location: always the residual stream
*   Training Checkpoints: every ~100 million tokens
*   Number of features per autoencoder: 65536 (expansion factor 16)

Findings
--------

We have not demonstrated anything to a high degree of rigor, but preliminary analysis seems to point in some interesting directions which we will share now. 

### Monosemanticity Across Layers

Using the Sort Eval Autointerpretability technique [introduced by Anthropic](https://transformer-circuits.pub/2024/august-update/index.html) we found that layer 20 seems to be the most monosemantic layer. In addition its features activate the most frequently across the laion dataset.

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/c7756850cc32ffe4fbf4cbcd539c67ab55ed5f03fb95d4f6.png)

This suggests that layer 20 is a reasonable alternative to layer 22, which is more commonly used in [prior works](https://www.lesswrong.com/posts/bCtbuWraqYTDtuARg/towards-multimodal-interpretability-learning-sparse-2).

### Reconstruction MSE Across Tokens

All layers were trained across all 257 image patches. Below we provide plots demonstrating the reconstruction MSE for each token (other than the CLS token) as training progressed. It seems that throughout training the outer tokens are easier to reconstruct than those in the middle, presumably because these tokens capture more important information (i.e. foreground objects) and are therefore more information rich.

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/c539e949b9d56af4505b064ac8c742d73e89cb0daeabc8b2.png)

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/15258d13d8c640d960d437b8f3af9f9e2ca8ce0c169de868.png)

References
----------

We draw heavily from prior Visual Sparse Autoencoder research work by [Hugo Fry](https://www.lesswrong.com/posts/bCtbuWraqYTDtuARg/towards-multimodal-interpretability-learning-sparse-2) and [Gytis Daujotas](https://www.lesswrong.com/posts/iYFuZo9BMvr6GgMs5/case-study-interpreting-manipulating-and-controlling-clip). We also rely on Autointerpretability research from [Anthropic Circuits Updates](https://transformer-circuits.pub/2024/august-update/index.html), and take the TopKSAE architecture and training methodology from [Scaling and Evaluating Sparse Autoencoders](https://cdn.openai.com/papers/sparse-autoencoders.pdf). We base all our training and inference on data from the [LAION project](https://laion.ai/laion-400-open-dataset/).