Inferensys

Glossary

Dictionary Learning

A method for decomposing a model's activations into a sparse linear combination of learned basis vectors, each representing a distinct, interpretable feature.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
MECHANISTIC INTERPRETABILITY

What is Dictionary Learning?

A method for decomposing a model's activations into a sparse linear combination of learned basis vectors, each representing a distinct, interpretable feature.

Dictionary learning is a technique that decomposes a neural network's dense, polysemantic activations into a sparse linear combination of learned basis vectors, called dictionary features. By enforcing sparsity, it isolates monosemantic concepts from superimposed representations, transforming an opaque activation vector into a set of independently interpretable components.

A sparse autoencoder is typically trained on a layer's activations to learn an overcomplete dictionary and produce a sparse code. The reconstruction loss ensures fidelity, while an L1 penalty drives sparsity. This process disentangles superposition, allowing researchers to identify distinct features for concepts like "legal text" or "DNA sequences" that were previously entangled in a single neuron.

SPARSE FEATURE DECOMPOSITION

Key Characteristics of Dictionary Learning

Dictionary learning transforms dense, polysemantic neural activations into a sparse linear combination of learned basis vectors, each representing a distinct, monosemantic feature. This enables the decomposition of superposition in deep networks.

01

Sparse Overcomplete Representations

The learned dictionary contains more basis vectors than the activation space's dimensionality, creating an overcomplete representation. A sparsity penalty (L1 regularization) forces each input to be reconstructed using only a small subset of available dictionary elements. This mirrors the hypothesized strategy biological neurons use for efficient coding and directly addresses the superposition hypothesis in artificial networks.

02

Monosemantic Feature Disentanglement

The primary objective is to find basis vectors that are monosemantic—each corresponding to exactly one human-interpretable concept. This contrasts with natural neurons which are often polysemantic, firing for multiple unrelated inputs. A successfully trained dictionary decomposes a neuron that fires for both 'DNA sequences' and 'academic citations' into two separate, independently activating feature directions.

03

Sparse Autoencoder Architecture

The standard implementation uses a sparse autoencoder with a single hidden layer:

  • Encoder: Maps activations to a sparse latent representation via a learned weight matrix and ReLU activation
  • Decoder: Reconstructs the original activation from the sparse code
  • Bias terms: Include both encoder and decoder biases, with the decoder bias often initialized to the geometric median of the data
  • The L1 penalty on latent activations enforces sparsity, typically with a coefficient (λ) tuned per layer.
04

Residual Stream Decomposition

In transformer models, dictionary learning is applied to the residual stream at specific layers. The residual stream accumulates information from attention heads and MLP layers, making it a natural bottleneck for feature analysis. By decomposing mid-layer residual stream activations, researchers can identify the precise point where abstract concepts like sentiment, syntax, or factual knowledge are represented before being read by downstream components.

05

Causal Feature Steering

Once a dictionary is trained, the learned feature directions enable activation engineering. By clamping a specific dictionary feature to a high value during the forward pass, the model's behavior can be causally steered. For example, amplifying the 'romantic love' feature in a language model causes it to generate text about relationships regardless of the original prompt, providing direct evidence that the feature is causally implicated in that concept.

06

Cross-Coder Variants for Model Comparison

Cross-coders extend standard dictionary learning by training on activations from two different models simultaneously. The learned dictionary contains:

  • Shared features: Basis vectors that activate for both models, representing universal concepts
  • Model-specific features: Vectors unique to one model, highlighting representational differences This technique is critical for comparing how different architectures or checkpoints encode the same underlying concepts.
DICTIONARY LEARNING

Frequently Asked Questions

Clear, technically precise answers to the most common questions about sparse dictionary learning for mechanistic interpretability.

Dictionary learning is an unsupervised decomposition method that factorizes a neural network's dense, polysemantic activations into a sparse linear combination of learned basis vectors, where each vector corresponds to a single, human-interpretable feature. The technique treats a layer's activation space as a compressed representation where multiple independent concepts are entangled in superposition. By training a sparse autoencoder or similar architecture on these activations, dictionary learning produces an overcomplete basis—a "dictionary" with more feature directions than the original dimensionality—allowing the model to represent more features than it has neurons. The sparsity constraint ensures that for any given input, only a small subset of dictionary features activate, making each active feature direction monosemantic and individually inspectable. This directly addresses the core challenge of polysemanticity, where a single neuron fires for multiple unrelated concepts, by disentangling those concepts into separate, interpretable components.

DICTIONARY LEARNING

Applications in Mechanistic Interpretability

Dictionary learning decomposes dense, polysemantic neural network activations into a sparse linear combination of learned basis vectors, each representing a distinct, interpretable feature. This section explores its critical applications in reverse-engineering model internals.

01

Disentangling Superposition

Dictionary learning is the primary tool for testing the Superposition Hypothesis. By training a sparse autoencoder to reconstruct activations from a higher-dimensional, sparse feature basis, researchers can recover more independent features than the model's native dimensionality. This provides empirical evidence that models compress representations and offers a method to extract them.

02

Resolving Polysemantic Neurons

A single neuron often fires for multiple unrelated concepts (polysemanticity). Dictionary learning provides a systematic solution:

  • Decomposition: A sparse autoencoder maps the neuron's activation context to a set of distinct dictionary elements.
  • Result: A neuron that fires for both 'DNA sequences' and 'academic citations' can be separated into two independent, monosemantic feature vectors, each with a single, clear meaning.
03

Automated Circuit Discovery

Instead of manually inspecting individual neurons, researchers use dictionary features as the atomic units for automated circuit discovery. Algorithms search for sparse subgraphs of dictionary features that causally mediate a specific behavior. This replaces manual hypothesis generation with a scalable, bottom-up decomposition of the computational graph into interpretable components.

04

Cross-Coder Feature Sharing

A Cross-Coder is a dictionary learning variant trained on the activations of two different models simultaneously. Its learned dictionary captures both model-specific and shared features. This enables direct comparison of how two distinct models—or a base model and its fine-tuned variant—internally represent the same concept, revealing the precise impact of training interventions.

05

Transcoder-Based Layer Replacement

A Transcoder is a dictionary learning model trained to replace a specific MLP layer or attention block. It decomposes the component's output into a sparse, interpretable feature basis. By analyzing the transcoder's dictionary, researchers can precisely define the function of a single layer in isolation, turning an opaque non-linear transformation into a transparent, feature-level operation.

06

Activation Engineering via Steering

Dictionary features provide a precise interface for activation engineering. Instead of adding a hand-crafted steering vector to control behavior, a practitioner can identify the specific dictionary element for a target concept (e.g., 'sycophancy') and directly modulate its coefficient during the forward pass. This enables surgical, causal control over model outputs with minimal side effects.

FEATURE DECOMPOSITION COMPARISON

Dictionary Learning vs. Related Techniques

Comparing dictionary learning with other methods for extracting interpretable features from neural network activations.

FeatureDictionary LearningSparse AutoencoderProbing ClassifierFeature Visualization

Primary objective

Decompose activations into sparse, interpretable basis vectors

Learn sparse overcomplete representation via reconstruction

Detect if specific information is linearly encoded in activations

Generate input that maximally activates a target neuron

Supervision required

Output type

Learned dictionary of monosemantic feature vectors

Sparse latent code and reconstruction

Binary or scalar prediction of a property

Synthetic input image or sequence

Causal intervention capability

Handles polysemanticity

Identifies novel features

Training data requirement

Model activations across diverse inputs

Model activations across diverse inputs

Labeled activation-property pairs

Gradient access to target neuron

Computational cost

Moderate to high

High

Low

Moderate

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.