Skip to content

Guide · Agent skill

How to use the SAELens Sparse Autoencoder Training agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

This guide shows you how to install and use the sparse-autoencoder-training agent skill, which gives your AI agent step-by-step guidance for SAELens, a Python library for sparse autoencoders (SAEs). A sparse autoencoder splits a language model's internal activations into separate features that you can inspect, such as a feature that fires on legal language or code syntax. By the end you will know what the skill covers, how to install it, how to ask for it in plain language, and what hardware and accounts you need.

SAELens Sparse Autoencoder TrainingOrchestra-Research/AI-Research-SKILLs · MIT

Quick start

  1. 1Install the skill. Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use or into .claude/skills/ in a project. Alternatively, upload the ZIP under Settings → Capabilities → Skills in the Claude apps.
  2. 2Install the Python libraries. Make sure you have Python 3.10 or newer, then run pip install sae-lens. The skill also relies on transformer-lens and torch.
  3. 3Check your hardware. The examples use device='cuda', so a CUDA GPU is recommended. Training needs substantial compute.
  4. 4Ask a specific question. Name the goal, the model and the layer, for example which features fire on a sentence in GPT-2 small at block 8.
  5. 5Load a pre-trained SAE. Let the agent load the matching SAE for your layer and encode your prompt's activations into features.
  6. 6Inspect the features. Look at the top features per token and test them with contrasting sentences before drawing conclusions.
  7. 7Train or steer if needed. For a custom SAE, review L0, CE loss and dead features. For steering, use a feature's decoder direction and check the output carefully.

What the skill makes the agent do

Neurons inside a neural network are often polysemantic, meaning one neuron responds to several unrelated contexts. The source explains this as the result of superposition: models represent more features than they have neurons. SAEs address this by decomposing dense activations into sparse features, where only a few features are active for any given input and each one ideally corresponds to a single interpretable concept.

With this skill installed, the agent can guide you through three kinds of work: loading pre-trained SAEs and listing the top-activating features for each token, training a custom SAE with the SAELens library, and analyzing individual features or steering with a feature direction. The skill is a guidance document built around SAELens and TransformerLens code, so the agent follows and adapts those workflows rather than running a standalone program.

  • Load a pre-trained SAE for a chosen layer and encode model activations into features
  • Find which features activate on specific text and check reconstruction quality
  • Configure a custom SAE training run and review metrics such as L0 and CE loss recovery
  • Test what a feature does by adding its decoder direction to the residual stream

Install the skill from the ZIP download or the Claude apps

Option one is a personal install. Download the ZIP from this page and unzip it into ~/.claude/skills/ so the skill folder sits there. Option two is a project install: unzip it into the .claude/skills/ folder inside your project so only that project uses it.

Option three is for the Claude apps. Open Settings, go to Capabilities, then Skills, and upload the ZIP there. The file set includes SKILL.md, references/README.md, references/api.md and references/tutorials.md. Keep these files together in the folder so the agent can read the reference material.

  • Personal: unzip into ~/.claude/skills/
  • Project: unzip into .claude/skills/ in your project folder
  • Claude apps: Settings → Capabilities → Skills, then upload the ZIP

Set up the SAELens Python environment

The skill's examples depend on the SAELens library and TransformerLens, so the agent will expect them to be installed. The source gives the install command for SAELens and lists Python 3.10+ and transformer-lens as requirements. The skill's frontmatter also lists torch as a dependency.

Run the following in the Python environment you plan to use. Ask the agent to check your setup before you start a larger job.

pip install sae-lens

Trigger the skill with natural requests

You do not need special syntax. Describe the interpretability task in plain language and mention a model or layer if you have one. The skill's description says it applies when you are discovering interpretable features, analyzing superposition, or studying monosemantic representations in language models, so requests that match those ideas should bring it in.

Good requests name the goal, the model and the layer. For example, you can ask which SAE features fire on a given sentence in GPT-2 small at a specific residual stream layer. Vague requests such as general coding help will not match this skill.

  • Which SAE features activate on the word Paris in GPT-2 small at block 8?
  • Help me load a pre-trained SAE for the residual stream and list the top features per token.
  • I want to train a sparse autoencoder with an expansion factor of 8 on layer 8 of GPT-2 small.
  • Show me how to steer a model with a feature direction from my SAE and check the effect.
  • Check whether my SAE reconstructs activations well and how many features are active on average.

Example: load a pre-trained SAE and inspect features

The most common starting point is loading a pre-trained SAE and encoding model activations. The snippet below is the core workflow from the source: load GPT-2 small with TransformerLens, load a matching SAE for the residual stream at block 8, run a prompt, encode the activations, and list the top features for each token. It uses device='cuda', so it needs a CUDA GPU as described below.

  • The release and sae_id values must match a pre-trained SAE that exists for your model.
  • Pre-trained SAEs are downloaded over the network the first time they are loaded.
from transformer_lens import HookedTransformer from sae_lens import SAE model = HookedTransformer.from_pretrained('gpt2-small', device='cuda') sae, cfg_dict, sparsity = SAE.from_pretrained( release='gpt2-small-res-jb', sae_id='blocks.8.hook_resid_pre', device='cuda' ) tokens = model.to_tokens('The capital of France is Paris') _, cache = model.run_with_cache(tokens) activations = cache['resid_pre', 8] sae_features = sae.encode(activations) print(f'Active features: {(sae_features > 0).sum()}')

Example: train a custom SAE and check the metrics

For a custom SAE, the source shows a LanguageModelSAERunnerConfig with the model, hook point, architecture, learning rate, L1 coefficient, training token count, dataset and checkpointing settings, followed by SAETrainingRunner. Training uses the monology/pile-uncopyrighted dataset in the example and can log to Weights & Biases if you enable it.

After training, the source suggests checking L0 (average active features per token) and CE loss score. The skill lists rough targets for these values, but treat them as guidance for your own run, not guarantees.

  • Key settings: d_sae (typically 4 to 16 times d_model), l1_coefficient, lr, and l1_warm_up_steps
  • Metrics to check: L0, CE loss score, dead feature ratio and explained variance
  • log_to_wandb is optional and needs a Weights & Biases account

Analyze and steer individual features

To study one feature, the source runs several test sentences through the model and records that feature's maximum activation for each. This shows which inputs drive the feature most. The skill also describes feature steering: take the feature's decoder direction from sae.W_dec and add a scaled copy to the residual stream with a hook during generation.

The steering example in the source is cut off before its hook returns, so the agent should complete and check that code against the references before you rely on it.

  • Use several contrasting sentences so you can see what the feature responds to
  • Treat any label you give a feature as a hypothesis to test

What people use it for

  • Finding which SAE features fire on specific words or sentences in GPT-2 small for an interpretability project
  • Training a small custom SAE on a chosen layer to study superposition in a model you already use
  • Checking whether a pre-trained SAE reconstructs activations well enough for your analysis
  • Teaching a course module on polysemanticity, superposition and sparse features with worked examples

Frequently asked questions

How do I install the SAELens agent skill?

Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use, or into .claude/skills/ inside a project. In the Claude apps, you can instead upload the ZIP under Settings → Capabilities → Skills.

Is the sparse autoencoder training skill free?

The skill is published under the MIT licence, as stated on this page. SAELens and its dependencies are open-source Python packages, but you still need your own compute and any accounts you choose to use.

What do I need to run it?

You need Python 3.10 or newer, the sae-lens and transformer-lens packages, and torch. A CUDA GPU is recommended because the examples use device='cuda', and training needs substantial compute.

Does the skill run scripts or use the network?

The source lists that the skill does not run scripts but does use the network. Pre-trained SAEs and datasets such as monology/pile-uncopyrighted are downloaded from Hugging Face, and Weights & Biases logging is optional.

What is the difference between this and TransformerLens alone?

TransformerLens gives you basic activation analysis and model access. The SAELens skill adds sparse autoencoder loading, training and feature analysis on top of it. The source suggests using TransformerLens directly for basic activation analysis or pyvene for causal intervention experiments.

Can I trust the feature labels the agent gives?

Not for high-stakes decisions. SAE features are research artifacts, and their interpretations can be wrong, so check labels with contrasting examples before relying on them, and do not use them alone for production safety decisions.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

This skill suits ML researchers, students and engineers who already work with transformer models and want guided SAE workflows in SAELens and TransformerLens. It is not a good fit for general coding help, for production safety decisions based on feature labels, or for anyone without a GPU and a Python environment.

Download the skill