sae-lens
Training and Analyzing Sparse Autoencoders (SAEs)
What it is and what it does
SAE Lens is a research library for training and analyzing sparse autoencoders (SAEs), a technique used to decompose neural network activations into interpretable features. It provides tools to train SAEs from scratch, load pre-trained models, and generate feature analysis dashboards. The library works with any PyTorch-based model but offers deep integration with TransformerLens and Hugging Face Transformers, allowing researchers to extract activations and pass them through the SAE's encode and decode methods.
The package is designed for mechanistic interpretability research—understanding how neural networks work internally—with a focus on generating insights that support AI safety and alignment. It includes tutorials for loading pre-trained SAEs, analyzing features, and training on synthetic data, plus integration with visualization tools like SAE-Vis. The codebase is actively maintained and part of a broader ecosystem of interpretability projects.
Use it for:
- Train sparse autoencoders on transformer model activations to discover interpretable features.
- Load and analyze pre-trained SAEs to understand what features a model has learned.
- Generate feature dashboards and visualizations using SAE-Vis for mechanistic interpretability research.
- Extract and study activation patterns from Hugging Face or custom PyTorch models using SAE inference.
- Benchmark SAE architectures on synthetic data to evaluate design choices.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
SAE Lens trains and analyzes sparse autoencoders for mechanistic interpretability research, with built-in support for PyTorch models and deep integration with TransformerLens and Hugging Face Transformers.
Yes, if you are doing mechanistic interpretability research or need to train and analyze sparse autoencoders. The library is actively maintained, has low install friction, carries a permissive license, and integrates well with standard ML frameworks. Not relevant for general-purpose ML tasks or applications that don't require feature-level interpretability analysis.
Install
sae-lens on PyPI
pip
pip install sae-lensuv
uv add sae-lenspoetry
poetry add sae-lensInstalling sae-lens
Before you install
Low friction installation with a pure-Python wheel. Active maintenance—released 4 days ago with 1503 repository stars. Requires 13 runtime dependencies including transformers, transformer-lens, and datasets; all are standard ML packages.
License in practice
MIT license (permissive) places no restrictions on commercial or private use, modification, or redistribution.
Quickstart
pip install sae-lens
from sae_lens import SAE
from transformers import AutoModel
# Load a pre-trained SAE and use it with a model
sae = SAE.from_pretrained("gpt2-small-sae")
model = AutoModel.from_pretrained("gpt2")
Requires Python 3.10 or later. PyTorch and transformers must be installed; SAE Lens handles this via dependencies.
Verify before relying
- Whether pre-trained SAEs cover the specific models or architectures you need to analyze.
- Performance characteristics and memory requirements for training SAEs on large models.
- Compatibility with custom or non-standard model architectures beyond the documented integrations.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 13 — babe, datasets, nltk, plotly, plotly-express, python-dotenv, pyyaml, safetensors, simple-parsing, tenacity, transformer-lens, transformers, typing-extensions |
| Maintenance | actively maintained — 4 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 81,669/month — #14,210 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sae_lens-6.49.1-py3-none-any.whl
Keywords: deep-learning, sparse-autoencoders, mechanistic-interpretability, PyTorch
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
captumCaptum provides model interpretability…
permissive · top 15,000 on PyPI
transformer-lensTransformerLens loads and inspects the internal…
permissive · top 15,000 on PyPI
icevisionIceVision provides a unified framework for…
permissive · top 15,000 on PyPI
segmentation-models-pytorchProvides PyTorch-based neural network models…
permissive · top 15,000 on PyPI
spacy-transformersIntegrates pretrained transformer models (BERT,…
permissive · top 15,000 on PyPI
llama-index-embeddings-huggingfaceIntegrates Hugging Face embedding models with…
permissive · top 15,000 on PyPI
model-compression-toolkitCompresses and optimizes neural networks…
permissive · top 15,000 on PyPI
pytorchcvProvides a collection of pretrained computer…
unclear · top 15,000 on PyPI
face_recognition_modelsProvides pre-trained deep learning models for…
permissive · top 15,000 on PyPI
torchxrayvisionTorchXRayVision provides pre-trained deep…
permissive · top 15,000 on PyPI