sparse-autoencoder-training

Train and analyze Sparse Autoencoders with SAELens to decompose neural network activations into interpretable features.

Updated Jun 7, 2026
One-click install
npx skills add https://github.com/Chensihakniroth/ANAKOT-AGENT --skill sparse-autoencoder-training-chensihakniroth
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sparse-autoencoder-training
Source: https://github.com/Chensihakniroth/ANAKOT-AGENT/tree/main/optional-skills/mlops/saelens
Command: npx skills add https://github.com/Chensihakniroth/ANAKOT-AGENT --skill sparse-autoencoder-training-chensihakniroth

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires sae-lens, transformer-lens, torch, and includes references (resource) components.

What problem does it solve? Neural network neurons are polysemantic, activating in multiple unrelated contexts due to superposition, which makes model internals hard to interpret. This Skill guides training and analyzing Sparse Autoencoders (SAEs) with SAELens to decompose dense activations into sparse, monosemantic features. ## Core Features & Use Cases - Pre-trained SAE Analysis: Load SAEs from releases like gpt2-small-res-jb, encode activations into sparse features, and identify top-activating features per token. - Custom SAE Training: Configure and train Standard, Gated, TopK, or JumpReLU SAEs with tunable L1 sparsity penalties, warm-up steps, and ghost gradients to prevent dead features. - Feature Steering and Attribution: Add decoder feature directions to residual streams for steering, compute per-feature logit contributions, and ablate features to test causal importance. - Use Case: A researcher studying what GPT-2 has learned loads a pre-trained SAE on layer 8, encodes activations from test prompts, and discovers interpretable features corresponding to legal language or code syntax, then steers generation by amplifying a chosen feature. ## Quick Start Ask the agent to load the gpt2-small-res-jb pre-trained SAE and show which features activate most strongly on a given prompt.

Frequently Asked Questions about sparse-autoencoder-training

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I train a Sparse Autoencoder on language model activations?▼

Configure a LanguageModelSAERunnerConfig with your model name, hook point, expansion factor, and L1 coefficient, then run SAETrainingRunner. Training uses MSE reconstruction loss plus an L1 sparsity penalty on features.

How to load pre-trained SAEs with SAELens?▼

Call SAE.from_pretrained with a release name like gpt2-small-res-jb and an sae_id such as blocks.8.hook_resid_pre. You can also load from HuggingFace repos or local disk with SAE.load_from_disk.

What is the difference between Standard, Gated, and TopK SAE architectures?▼

Standard SAEs use ReLU with an L1 penalty for general purposes. Gated SAEs add a learned gating mechanism for better sparsity control, while TopK keeps exactly K features active per input for consistent sparsity.

Why does my SAE have a high dead feature ratio?▼

Dead features usually result from applying the full L1 penalty too early. Enable l1_warm_up_steps around 1000 and set use_ghost_grads to true so gradients revive features that stop activating.

Can SAELens features be used to steer model generation?▼

Yes, extract a feature direction from sae.W_dec and add it to the residual stream via a forward hook during generation. Scaling the direction controls steering strength at the target layer.

When should I use TransformerLens instead of SAELens?▼

Use TransformerLens directly for basic activation analysis or causal intervention experiments without feature decomposition. SAELens is specifically for discovering sparse interpretable features and studying superposition.