sparse-autoencoder-training

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

5|2|Updated Aug 10, 2026
One-click install
npx skills add https://github.com/MedTiLab/Auto-meta-analysis --skill sparse-autoencoder-training-medtilab
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sparse-autoencoder-training
Source: https://github.com/MedTiLab/Auto-meta-analysis/tree/main/skills/mechanistic-interpretability/saelens
Command: npx skills add https://github.com/MedTiLab/Auto-meta-analysis --skill sparse-autoencoder-training-medtilab

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, jumprelu), L1 coefficient, warm-up steps, and ghost grads, then monitor L0, CE loss recovery, and dead feature ratios. - Feature Steering and Attribution: Compute per-feature logit contributions, steer generation by adding decoder directions to the residual stream, 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, finds features that consistently activate for France-related prompts, and steers generation by amplifying a specific feature direction. ## Quick Start Load a pre-trained SAE for GPT-2 small layer 8 and show me the top activating features for each token in 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, L1 coefficient, and training tokens, 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?▼

Use 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 then encode model activations from TransformerLens into sparse features and decode them back for reconstruction checks.

What L1 coefficient should I use for SAE training?▼

Typical values range from 5e-5 to 1e-4. Higher values produce sparser, more interpretable features but worse reconstruction; lower values improve CE loss recovery. Target an L0 of 50-200 active features per token.

Why does my SAE have many dead features?▼

Dead features usually result from applying full L1 penalty too early. Set l1_warm_up_steps to 500-2000 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 add the scaled direction to the residual stream via a TransformerLens forward hook during generation. Increasing the strength parameter amplifies the steered concept in output.

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