ClasSAE: Class-Aligned Sparse Autoencoders via Differentiable Feature-Class Affinity

Jakub Stępień, Marcin Mazur, Jacek Tabor, Przemysław SpurekarXiv 2026

TL;DR

ClasSAE is a new type of Sparse Autoencoder that uses class labels during training to automatically align its internal "features" with specific concepts. By making the feature-selection process differentiable, it creates a dictionary that is both highly interpretable and ready for precise model editing (like unlearning or steering) without the need for tedious post-hoc labeling.

What Problem Does This Paper Address?

Sparse Autoencoders (SAEs) are the current "gold standard" for mechanistic interpretability. They take the dense, messy activations of a neural network and decompose them into a large dictionary of sparse, human-understandable features.

However, standard SAEs are unsupervised. This creates two major headaches for researchers:

  1. The Labeling Burden: After training an SAE, you have to perform "post-hoc probing"—essentially a second round of analysis—to figure out which feature represents "a cat" versus "a toaster."
  2. Instability: Because the training is unsupervised, a specific concept might be split across many features or entangled with others, making it difficult to use these features for active interventions like "unlearning" a specific bias.

ClasSAE addresses this by arguing that if we already know the classes or concepts we care about, we should use that knowledge to shape the dictionary during training rather than just analyzing it afterward.

Methods

The core innovation of ClasSAE is the differentiable feature-class affinity matrix.

  • Joint Training: Unlike standard SAEs, ClasSAE learns the encoder, the decoder, and a "class affinity matrix" ($M$) all at once. This matrix tracks which features "belong" to which classes.
  • Differentiable Selection: The authors use a differentiable SoftTopK operator. This allows gradients to flow through the choice of which features are active for a given sample. If the model picks a feature that doesn't match the input's class, the "agreement loss" ($\mathcal{L}_{agr}$) penalizes it.
  • Per-Feature Budgets: Each feature is given a "budget" ($k_i$) for how many classes it can represent. Some features become "specialists" (representing one class), while others become "generalists" (shared across many).
Figure 1: ClasSAE jointly learns a sparse dictionary and a class affinity matrix, enabling classifier-free class prediction and targeted editing: removing only the features exclusive to a class erases that class from the reconstruction while shared features are preserved.

The authors propose three sparsity variants: Soft-gradient BatchTopK (the default), Hard BatchTopK, and an $L^1$-relaxed version.

Datasets

The researchers evaluated ClasSAE using:

  • ImageNet-1k: Specifically, they used embeddings from a pretrained CLIP ViT-L/14 model.
  • DINOv3: Used for qualitative patch-token experiments to show how features localize to specific parts of an image (like a cat's face vs. a dog's body).

Key Insights and Ideas

  • Supervision as a Structural Guide: The paper shows that class labels don't just help label features; they actually help the encoder find a more "separable" representation that is easier to manipulate.
  • Water-filling & PMI: The authors prove mathematically that their training objective naturally converges to a "Pointwise Mutual Information" (PMI) thresholding rule. In simple terms, the model automatically learns to associate features with classes based on how much information they provide about each other.
  • Precision over Recall: The agreement loss is designed to reward precision. It doesn't force every feature owned by a class to fire; it just ensures that whatever does fire is relevant to that class. This preserves the "adaptivity" of the SAE.
Figure 3: Visualization of the feature-class table building and the agreement loss mechanism.

Key Results

  • Faithful Annotations: ClasSAE’s internal affinity matrix ($M$) matches independent post-hoc estimates with high accuracy (Mean Cosine Similarity of 0.822 vs. 0.410 for standard BatchTopK).
  • Out-of-the-Box Classification: Even though it's an autoencoder, ClasSAE can act as a high-performing classifier. The $L^1$ variant achieved 79.9% top-1 accuracy on ImageNet without any separate classifier head.
  • Precise Interventions: In "Targeted Probe Perturbation" (a test of how well you can erase a concept), ClasSAE allowed for successful unlearning with significantly lower "edit strength" than baselines. This means you can remove a concept while doing less collateral damage to the rest of the model's knowledge.
  • Full Dictionary Utilization: ClasSAE variants achieved 100% "Alive" features, meaning every single coordinate in the dictionary was used, effectively eliminating the "dead latent" problem common in unsupervised SAEs.
Figure 2: Qualitative examples showing features localizing to specific image regions (cat vs. dog) even when trained only on whole-image labels.

Limitations and Future Work

  • Computational Cost: The SoftTopK operator is a major bottleneck. While it handles 1,000 ImageNet classes easily, scaling to millions of classes or massive dictionaries (e.g., for LLMs) will require more efficient implementations.
  • Reconstruction Trade-off: There is a slight "tax" on reconstruction quality. Standard unsupervised SAEs explain a bit more of the input variance (FVE) because they aren't constrained by class alignment.
  • Small-k Performance: At very low feature counts (e.g., TPP at $k=20$), ClasSAE was sometimes outperformed by unsupervised models, likely because the class-alignment pressure requires more features to represent a concept fully.

Future work could involve applying this to large language models (LLMs) to see if it can disentangle complex linguistic concepts or social biases during training.

Summary updated

BibTeX
@misc{stepien2026classae,
  author = {Jakub Stępień and Marcin Mazur and Jacek Tabor and Przemysław Spurek},
  title = {{ClasSAE: Class-Aligned Sparse Autoencoders via Differentiable Feature-Class Affinity}},
  year = {2026},
  eprint = {2610.04020},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.04020},
}
Figure