sparse-autoencoder-training

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

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

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 you through using SAELens to decompose dense activations into sparse, monosemantic features that correspond to human-interpretable concepts. ## 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 L1 warm-up, ghost grads, and W&B logging, then validate with L0, CE loss recovery, and dead feature metrics. - Feature Steering & 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: You want to find which features in GPT-2 drive the prediction of "Paris". Load the layer-8 residual SAE, compute feature contributions via decoder weights and the unembedding matrix, then steer or ablate the top feature to verify its causal role. ## Quick Start Ask the AI to load the gpt2-small-res-jb pre-trained SAE with SAELens and show the top-activating features for each token in 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 a LanguageModelSAERunnerConfig with your model name, hook point, d_sae expansion factor, L1 coefficient, and dataset, then pass it to SAETrainingRunner and call run(). 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?

Use SAE.from_pretrained with a release like gpt2-small-res-jb and an sae_id such as blocks.8.hook_resid_pre. Pair it with a HookedTransformer model from TransformerLens, then call sae.encode on cached activations to get sparse features.

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 a strong L1 penalty too early. Fix this by setting l1_warm_up_steps to around 1000, enabling use_ghost_grads to revive inactive features, and tuning the dead_feature_window parameter.

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