sparse-autoencoder-training

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

14|5|Updated Apr 9, 2026
One-click install
npx skills add https://github.com/MLT-OSS/hermes-agent-go --skill sparse-autoencoder-training-mlt-oss
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sparse-autoencoder-training
Source: https://github.com/MLT-OSS/hermes-agent-go/tree/main/optional-skills/mlops/saelens
Command: npx skills add https://github.com/MLT-OSS/hermes-agent-go --skill sparse-autoencoder-training-mlt-oss

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 identify top-activating features per token. - Custom SAE Training: Configure LanguageModelSAERunnerConfig with architecture (standard, gated, topk, jumprelu), L1 coefficient, and warm-up settings, then monitor L0, CE loss recovery, and dead feature metrics. - 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 has learned about geography loads a pre-trained SAE on layer 8, finds features that consistently activate for France-related prompts, and steers generation by amplifying the top feature. ## Quick Start Ask the agent to load the gpt2-small-res-jb pre-trained SAE with SAELens and show which sparse features activate for 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 with SAELens?

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 do I load a pre-trained SAE for GPT-2 analysis?

Use SAE.from_pretrained with a release like gpt2-small-res-jb and a sae_id such as blocks.8.hook_resid_pre. Then encode activations from a TransformerLens HookedTransformer cache to get sparse feature activations.

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 many dead features during training?

Dead features usually result from applying full L1 penalty too early. Set l1_warm_up_steps to 1000 or more, enable use_ghost_grads to revive inactive features, and avoid setting the L1 coefficient too high initially.

Can I use SAE features to steer language model generation?

Yes, extract a feature direction from sae.W_dec and add it to the residual stream via a TransformerLens forward hook during generation. Scaling the direction by a strength parameter controls how strongly the feature influences output.

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 features and studying superposition.