This repository provides a TopK Sparse Autoencoder (SAE) trained on the
residual stream of Qwen2.5-VL-3B-Instruct. The SAE is attached to a single
hidden layer and reconstructs the residual-stream activations after that layer.
We trained this SAE on 498,000 samples from the LLaVA-NeXT-Data dataset.
Sparse Autoencoders can be used to analyze model internals by mapping dense
hidden states into sparse feature activations. This checkpoint is intended for
mechanistic interpretability, feature analysis, and residual-stream
reconstruction experiments.
The file inference_sae_qwen25_vl.py is a minimal end-to-end demo. It loads
the base Qwen2.5-VL model, hooks the residual stream at layer 34, extracts SAE
TopK feature activations, and prints active features for the prompt.
The script does not use command-line parsing. Edit the constants at the top of
the file:
python
1BASE_MODEL ="Qwen/Qwen2.5-VL-3B-Instruct"2SAE_PATH ="BeEnough/SAE-Res-Qwen2.5-VL-3B-Instruct-W64K-L34-K100"3PROMPT ="Explain sparse autoencoders in one paragraph."4IMAGE_PATH =None# or Path("/path/to/image.jpg")5DEVICE ="cuda"6RUN_GENERATION_WITH_SAE =True
Hook model.model.language_model.layers.34 in Qwen2.5-VL to collect the
residual stream, then pass it into encode_topk.
If you only want feature activations and do not want generation with SAE
reconstruction, set:
RUN_GENERATION_WITH_SAE = False
Evaluation Snapshot
The following numbers are a 128-sample evaluation snapshot on LLaVA-NeXT-Data. They are intended as a quick release sanity check, not as a comprehensive benchmark.
Metric
Value
Mean FVU
0.0617
Mean R²
0.9383
Mean relative L2
0.1750
Mean token cosine
0.9726
Bias-only FVU
1.9868
Logit KL after SAE reconstruction
0.00085
Top-1 agreement after SAE reconstruction
1.0000
Used latents in sample
57345 / 65536
Effective latents in sample
13749
These numbers indicate strong reconstruction quality on the sampled data.
However, latent usage is long-tailed: many latents fire rarely, while some
latents are highly active. Users should re-evaluate on their own data before
drawing conclusions about interpretability.