sparse-autoencoder-training

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

2|Updated Aug 15, 2026
One-click install
npx skills add https://github.com/Jensen-Yao/agents-skills --skill sparse-autoencoder-training-jensen-yao
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sparse-autoencoder-training
Source: https://github.com/Jensen-Yao/agents-skills/tree/main/skills/saelens
Command: npx skills add https://github.com/Jensen-Yao/agents-skills --skill sparse-autoencoder-training-jensen-yao

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 for many unrelated concepts 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 inspect top-activating features per token. - Custom SAE Training: Configure LanguageModelSAERunnerConfig with architecture (standard, gated, topk), L1 coefficient, warm-up steps, and ghost gradients, then monitor L0, CE loss recovery, and dead feature ratios. - Feature Steering and Attribution: Add decoder feature directions to the residual stream for steering, compute per-feature logit contributions, and ablate features to test causal importance. - Use Case: A mechanistic interpretability researcher wants to find which features in GPT-2 layer 8 drive the prediction of " Paris". They load the pre-trained SAE, compute feature contributions via W_dec @ W_U, then steer generation by amplifying the top feature direction. ## Quick Start Load the gpt2-small-res-jb pre-trained SAE for layer 8 and show me the top five features activating on each token of the prompt "The capital of France is Paris".

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 LanguageModelSAERunnerConfig with your model name, hook point, d_sae expansion factor, and l1_coefficient, then run SAETrainingRunner. Enable l1_warm_up_steps and use_ghost_grads to prevent dead features during training.

How to load pre-trained SAEs with SAELens?▼

Call SAE.from_pretrained with a release name like gpt2-small-res-jb and a sae_id such as blocks.8.hook_resid_pre. It returns the SAE, config dict, and sparsity, ready to encode activations from a HookedTransformer.

What is the difference between standard, gated, and topk SAE architectures?▼

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

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

Dead features usually result from applying the full L1 penalty too early. Set l1_warm_up_steps to around 1000 to ramp the penalty gradually and enable use_ghost_grads to revive features that stop activating.

Can I use SAE features to steer model generation?▼

Yes. Extract a feature direction from sae.W_dec, then register a forward hook on the target residual stream that adds the scaled direction during generation. Higher strength values produce stronger steering effects.

When should I use TransformerLens directly instead of SAELens?▼

Use TransformerLens directly for basic activation analysis or causal intervention experiments that do not require sparse feature decomposition. SAELens is specifically for discovering interpretable monosemantic features and feature-based steering.