skillfed

sae-lens

Training and Analyzing Sparse Autoencoders (SAEs)

sae-lens v6.49.1 81.7K downloads/30d#14,210 on PyPI1,503
Permissive license MIT Active released

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-lens

uv

uv add sae-lens

poetry

poetry add sae-lens

Installing 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

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/Engineering :: Artificial Intelligence

Tags

sparse autoencoder trainingmechanistic interpretabilityneural network feature analysisSAE analysis toolsinterpretability research frameworktransformer activation analysisdictionary learning PyTorch
interpretabilitymechanistic-interpretabilityresearch

More Artificial Intelligence packages

litellm

LiteLLM provides a unified Python interface to…

permissive · top 100 on PyPI

huggingface-hub

Client library and CLI tool for downloading,…

permissive · top 100 on PyPI

langchain

LangChain provides a framework for building…

permissive · top 1,000 on PyPI

hf-xet

hf-xet provides chunk-based deduplication and…

permissive · top 1,000 on PyPI

tokenizers

Tokenizers converts raw text into token…

permissive · top 1,000 on PyPI

transformers

Transformers provides a unified framework for…

permissive · top 1,000 on PyPI

captum

Captum provides model interpretability…

permissive · top 15,000 on PyPI

transformer-lens

TransformerLens loads and inspects the internal…

permissive · top 15,000 on PyPI

icevision

IceVision provides a unified framework for…

permissive · top 15,000 on PyPI

segmentation-models-pytorch

Provides PyTorch-based neural network models…

permissive · top 15,000 on PyPI

spacy-transformers

Integrates pretrained transformer models (BERT,…

permissive · top 15,000 on PyPI

llama-index-embeddings-huggingface

Integrates Hugging Face embedding models with…

permissive · top 15,000 on PyPI

model-compression-toolkit

Compresses and optimizes neural networks…

permissive · top 15,000 on PyPI

pytorchcv

Provides a collection of pretrained computer…

unclear · top 15,000 on PyPI

face_recognition_models

Provides pre-trained deep learning models for…

permissive · top 15,000 on PyPI

torchxrayvision

TorchXRayVision provides pre-trained deep…

permissive · top 15,000 on PyPI