saelens

Train and analyze sparse autoencoders for mechanistic interpretability of neural networks.

239k|48.8k|Updated Jul 22, 2025
One-click install
npx skills add https://github.com/NousResearch/hermes-agent --skill saelens
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: saelens
Source: https://github.com/NousResearch/hermes-agent/tree/main/optional-skills/mlops/saelens
Command: npx skills add https://github.com/NousResearch/hermes-agent --skill saelens

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 across unrelated contexts due to superposition, which makes understanding what models have learned extremely difficult. This Skill provides a complete workflow for training Sparse Autoencoders (SAEs) that decompose dense activations into sparse, monosemantic features corresponding to interpretable concepts.

Core Features & Use Cases

  • Pre-trained SAE Loading: Load and analyze existing SAEs from releases like gpt2-small-res-jb to inspect features without retraining.
  • Custom SAE Training: Configure and train SAEs with Standard, Gated, TopK, or JumpReLU architectures using LanguageModelSAERunnerConfig.
  • Feature Analysis & Steering: Identify top-activating features per token, perform feature attribution to specific predictions, and steer model outputs by injecting feature directions.
  • Use Case: A safety researcher wants to find features in GPT-2 that activate on deceptive or harmful content. They load a pre-trained SAE, encode activations from a curated dataset of prompts, and identify the top features for manual interpretation.

Quick Start

Use the saelens skill to load the gpt2-small-res-jb SAE and identify the top 10 features activating on the prompt 'The capital of France is'.

Frequently Asked Questions about saelens

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I train a sparse autoencoder on transformer activations?

Use LanguageModelSAERunnerConfig with a nested SAE sub-config like StandardTrainingSAEConfig specifying d_in, d_sae, and l1_coefficient. Then instantiate LanguageModelSAETrainingRunner and call run() to train on activations collected from a specified hook point.

What is the difference between SAELens and TransformerLens for interpretability?

TransformerLens provides direct access to model activations and hooks for causal interventions. SAELens specifically trains sparse autoencoders to decompose those activations into interpretable features, solving the polysemanticity problem that raw neuron analysis cannot address.

Does SAELens support TopK sparse autoencoders?

Yes, SAELens v6 supports TopKTrainingSAEConfig where you set k directly on the SAE sub-config to enforce exactly K active features per token, providing consistent sparsity without L1 penalty tuning.

Why does my SAE have a high dead feature ratio?

Dead features occur when L1 penalty is applied too aggressively early in training. Increase l1_warm_up_steps to gradually ramp up the sparsity penalty, or use ghost gradients to revive dead features during training.

When should I use SAELens versus pyvene for interpretability?

Use SAELens when you need to discover and analyze interpretable features in model activations. Use pyvene when you need causal intervention experiments with predefined concepts, as pyvene focuses on activation patching rather than feature discovery.