sparse-autoencoder-training

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

1|Updated Mar 5, 2026
One-click install
npx skills add https://github.com/Clay-HHK/claude-skills --skill sparse-autoencoder-training-clay-hhk
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sparse-autoencoder-training
Source: https://github.com/Clay-HHK/claude-skills/tree/main/saelens
Command: npx skills add https://github.com/Clay-HHK/claude-skills --skill sparse-autoencoder-training-clay-hhk

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 expansion factor, L1 coefficient, warm-up steps, and ghost gradients, then train with SAETrainingRunner while monitoring 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 researcher studying what GPT-2 learned about geography loads a pre-trained SAE on layer 8, finds features contributing to the 'Paris' prediction, and steers generation by amplifying the top feature. ## Quick Start Ask the assistant to load the gpt2-small-res-jb pre-trained SAE and show which sparse features activate on a sample 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 with SAELens?▼

Configure LanguageModelSAERunnerConfig with your model name, hook point, d_sae expansion factor, L1 coefficient, and training tokens, then pass it to SAETrainingRunner and call run(). Enable l1_warm_up_steps and use_ghost_grads to prevent dead features during early training.

How do I load a pre-trained SAE for GPT-2?▼

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

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

Standard SAEs use ReLU with an L1 penalty for general-purpose training. 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 many dead features during training?▼

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

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 interpretable sparse features, studying superposition, and feature-based steering.