Papers
Topics
Authors
Recent
Search
2000 character limit reached

Top-AFA: Adaptive Activation for SAEs

Updated 9 July 2026
  • Top-AFA is an input-adaptive activation function for sparse autoencoders that adjusts active feature counts based on embedding norms.
  • It replaces the fixed-k hyperparameter with a rule that matches the sparse code norm to the dense embedding norm under quasi-orthogonality.
  • Empirical evaluations on GPT-2 embeddings show that Top-AFA yields lower NMSE and improved quasi-orthogonality metrics compared to traditional top-k methods.

Top-AFA is an input-adaptive activation function for sparse autoencoders (SAEs) introduced in “Evaluating and Designing Sparse Autoencoders by Approximating Quasi-Orthogonality” (Lee et al., 31 Mar 2025). In mechanistic interpretability, where SAEs are used to decompose dense language-model embeddings into sparse feature vectors, Top-AFA replaces the fixed hyperparameter kk of top-kk SAEs with a rule that selects, for each input, however many features are needed so that the sparse feature norm matches the norm predicted by the input embedding under approximate quasi-orthogonality. In the same framework, “AFA” denotes approximate feature activation: a theoretical link between the norm of the dense embedding and the norm of the sparse code, used both to design the activation rule and to evaluate pretrained SAEs (Lee et al., 31 Mar 2025).

1. Context and motivation

Sparse autoencoders are widely used in mechanistic interpretability research for LLMs. In the basic formulation, a dense hidden embedding zRd\mathbf{z}\in\mathbb{R}^d is mapped to a sparse feature vector f(z)Rh\mathbf{f}(\mathbf{z})\in\mathbb{R}^h, typically with h>dh>d, and then reconstructed linearly as

f(z)=σ(Wencz+benc),z^=Wdecf(z)+bdec.\mathbf{f}(\mathbf{z})=\sigma(W_{\text{enc}}\mathbf{z}+\mathbf{b}_{\text{enc}}), \qquad \hat{\mathbf{z}}=W_{\text{dec}}\mathbf{f}(\mathbf{z})+\mathbf{b}_{\text{dec}}.

The paper situates Top-AFA against the state of the art in kk-sparse autoencoders, where sparsity is imposed by keeping exactly kk nonzero activations. Its central critique is that the choice of kk, often treated as an 0\ell_0 hyperparameter, lacks a theoretical grounding. A fixed kk0 also assumes that every input should activate the same number of features, despite possible variation in embedding complexity across tokens and layers (Lee et al., 31 Mar 2025).

Top-AFA is proposed as a replacement for fixed-kk1 sparsification. Rather than prescribing a constant activation count, it uses the input embedding itself to infer how much sparse activation should occur. This suggests an input-conditioned sparsity regime in which activation count is an emergent quantity rather than a manually specified constant.

2. Approximate feature activation and quasi-orthogonality

The theoretical basis of Top-AFA is the approximate feature activation formulation. The paper assumes the linear representation hypothesis for SAEs with linear decoders: kk2 where kk3 is the decoder dictionary and kk4 is the sparse code. This is paired with the superposition setting kk5.

The relevant geometric notion is kk6-quasi-orthogonality. For a column-normalized dictionary kk7, the paper defines

kk8

If kk9 is approximately quasi-orthogonal, then zRd\mathbf{z}\in\mathbb{R}^d0 is approximately identity, and the dense embedding norm and sparse-code norm become tightly linked. The paper’s central bound is

zRd\mathbf{z}\in\mathbb{R}^d1

Equivalently,

zRd\mathbf{z}\in\mathbb{R}^d2

In the limit zRd\mathbf{z}\in\mathbb{R}^d3, this reduces to zRd\mathbf{z}\in\mathbb{R}^d4. The paper uses that approximation as its operative target: the input embedding norm is treated as the theoretically expected sparse activation norm. A related corollary is that when zRd\mathbf{z}\in\mathbb{R}^d5,

zRd\mathbf{z}\in\mathbb{R}^d6

so zRd\mathbf{z}\in\mathbb{R}^d7 can be read as an approximation to the number of activated features. This is the paper’s route from an zRd\mathbf{z}\in\mathbb{R}^d8-norm statement to adaptive control of zRd\mathbf{z}\in\mathbb{R}^d9-style sparsity (Lee et al., 31 Mar 2025).

3. Definition of the Top-AFA activation rule

Top-AFA operationalizes the AFA theory as an activation rule. For a batch input f(z)Rh\mathbf{f}(\mathbf{z})\in\mathbb{R}^h0, the algorithm first centers the input,

f(z)Rh\mathbf{f}(\mathbf{z})\in\mathbb{R}^h1

then computes the target norm

f(z)Rh\mathbf{f}(\mathbf{z})\in\mathbb{R}^h2

Positive pre-activations are obtained by

f(z)Rh\mathbf{f}(\mathbf{z})\in\mathbb{R}^h3

Each candidate feature is scored by its squared activation weighted by the norm of the corresponding decoder column: f(z)Rh\mathbf{f}(\mathbf{z})\in\mathbb{R}^h4 The score vector is sorted in descending order, cumulative sums are taken, and the selected activation count is the prefix whose cumulative norm is closest to the target: f(z)Rh\mathbf{f}(\mathbf{z})\in\mathbb{R}^h5 after converting both f(z)Rh\mathbf{f}(\mathbf{z})\in\mathbb{R}^h6 and the cumulative sums to norms. The final sparse code keeps exactly those top f(z)Rh\mathbf{f}(\mathbf{z})\in\mathbb{R}^h7 activations for that input. Reconstruction then proceeds as

f(z)Rh\mathbf{f}(\mathbf{z})\in\mathbb{R}^h8

This differs from standard top-f(z)Rh\mathbf{f}(\mathbf{z})\in\mathbb{R}^h9 SAEs in that h>dh>d0 is no longer fixed globally. It also differs from batch top-h>dh>d1, which constrains average sparsity over a batch rather than choosing an input-specific activation count. The paper notes that decoder columns need not have unit norm; weighting by h>dh>d2 compensates for that by absorbing decoder scaling into the feature contribution. The associated norm-matching penalty is

h>dh>d3

and the full objective is

h>dh>d4

In the reported experiments, h>dh>d5, while h>dh>d6 is tuned over h>dh>d7 (Lee et al., 31 Mar 2025).

4. Evaluation methodology derived from AFA

The same theory is used to evaluate pretrained SAEs. The paper argues that standard SAE evaluation typically measures either reconstruction quality, through quantities such as MSE or NMSE, or sparsity in isolation, but does not assess whether the magnitude of feature activation is justified by the input embedding itself. To address that gap, it defines a lower-bound estimate on the degree of quasi-orthogonality required to explain the observed mismatch between dense and sparse norms: h>dh>d8 This quantity is interpreted as the minimum quasi-orthogonality level any dictionary would need in order to explain the activation norm actually produced by the SAE.

The paper also introduces ZF plots, which place h>dh>d9 and f(z)=σ(Wencz+benc),z^=Wdecf(z)+bdec.\mathbf{f}(\mathbf{z})=\sigma(W_{\text{enc}}\mathbf{z}+\mathbf{b}_{\text{enc}}), \qquad \hat{\mathbf{z}}=W_{\text{dec}}\mathbf{f}(\mathbf{z})+\mathbf{b}_{\text{dec}}.0 on opposing axes. In that visualization, points near the diagonal indicate agreement with the AFA prediction, while large deviations indicate over- or under-activation relative to the input-conditioned norm target. The paper presents f(z)=σ(Wencz+benc),z^=Wdecf(z)+bdec.\mathbf{f}(\mathbf{z})=\sigma(W_{\text{enc}}\mathbf{z}+\mathbf{b}_{\text{enc}}), \qquad \hat{\mathbf{z}}=W_{\text{dec}}\mathbf{f}(\mathbf{z})+\mathbf{b}_{\text{dec}}.1 as complementary to NMSE rather than a replacement for it: a model can reconstruct accurately while still using feature activations whose norm is difficult to reconcile with quasi-orthogonal sparse decomposition. The paper interprets lower f(z)=σ(Wencz+benc),z^=Wdecf(z)+bdec.\mathbf{f}(\mathbf{z})=\sigma(W_{\text{enc}}\mathbf{z}+\mathbf{b}_{\text{enc}}), \qquad \hat{\mathbf{z}}=W_{\text{dec}}\mathbf{f}(\mathbf{z})+\mathbf{b}_{\text{dec}}.2 as evidence of better-justified feature activations (Lee et al., 31 Mar 2025).

5. Empirical performance on GPT-2 SAEs

The empirical study trains SAEs on GPT-2 Small residual-stream embeddings from layers 6, 7, and 8, using OpenWebText with sequence length 128. Training runs for 20,000 iterations with 4,096 tokens per iteration, for a total of 81,920,960 tokens, and uses width f(z)=σ(Wencz+benc),z^=Wdecf(z)+bdec.\mathbf{f}(\mathbf{z})=\sigma(W_{\text{enc}}\mathbf{z}+\mathbf{b}_{\text{enc}}), \qquad \hat{\mathbf{z}}=W_{\text{dec}}\mathbf{f}(\mathbf{z})+\mathbf{b}_{\text{dec}}.3 on a single NVIDIA A100 GPU. The paper compares Top-AFA against fixed top-f(z)=σ(Wencz+benc),z^=Wdecf(z)+bdec.\mathbf{f}(\mathbf{z})=\sigma(W_{\text{enc}}\mathbf{z}+\mathbf{b}_{\text{enc}}), \qquad \hat{\mathbf{z}}=W_{\text{dec}}\mathbf{f}(\mathbf{z})+\mathbf{b}_{\text{dec}}.4 and batch top-f(z)=σ(Wencz+benc),z^=Wdecf(z)+bdec.\mathbf{f}(\mathbf{z})=\sigma(W_{\text{enc}}\mathbf{z}+\mathbf{b}_{\text{enc}}), \qquad \hat{\mathbf{z}}=W_{\text{dec}}\mathbf{f}(\mathbf{z})+\mathbf{b}_{\text{dec}}.5 baselines (Lee et al., 31 Mar 2025).

The main reported result is that Top-AFA achieves the best NMSE on all three tested layers. The best settings reported in the paper are summarized below.

Layer Best Top-AFA result Best fixed-sparsity baselines
6 f(z)=σ(Wencz+benc),z^=Wdecf(z)+bdec.\mathbf{f}(\mathbf{z})=\sigma(W_{\text{enc}}\mathbf{z}+\mathbf{b}_{\text{enc}}), \qquad \hat{\mathbf{z}}=W_{\text{dec}}\mathbf{f}(\mathbf{z})+\mathbf{b}_{\text{dec}}.6, f(z)=σ(Wencz+benc),z^=Wdecf(z)+bdec.\mathbf{f}(\mathbf{z})=\sigma(W_{\text{enc}}\mathbf{z}+\mathbf{b}_{\text{enc}}), \qquad \hat{\mathbf{z}}=W_{\text{dec}}\mathbf{f}(\mathbf{z})+\mathbf{b}_{\text{dec}}.7, NMSE f(z)=σ(Wencz+benc),z^=Wdecf(z)+bdec.\mathbf{f}(\mathbf{z})=\sigma(W_{\text{enc}}\mathbf{z}+\mathbf{b}_{\text{enc}}), \qquad \hat{\mathbf{z}}=W_{\text{dec}}\mathbf{f}(\mathbf{z})+\mathbf{b}_{\text{dec}}.8 top-f(z)=σ(Wencz+benc),z^=Wdecf(z)+bdec.\mathbf{f}(\mathbf{z})=\sigma(W_{\text{enc}}\mathbf{z}+\mathbf{b}_{\text{enc}}), \qquad \hat{\mathbf{z}}=W_{\text{dec}}\mathbf{f}(\mathbf{z})+\mathbf{b}_{\text{dec}}.9: kk0; batch top-kk1: kk2
7 kk3, kk4, NMSE kk5 top-kk6: kk7; batch top-kk8: kk9
8 kk0, kk1, NMSE kk2 top-kk3: kk4; batch top-kk5: kk6

The reported average kk7 values are notably larger than the best fixed-kk8 baselines, which is consistent with the paper’s claim that the correct activation count should vary with the input rather than be set in advance. The paper also reports that Top-AFA achieves better kk9 distributions than top-kk0 and batch top-kk1, suggesting that the gain is not confined to reconstruction alone.

Computationally, the paper states that Top-AFA has the same asymptotic top-selection cost as top-kk2, with leading complexity

kk3

and is therefore not asymptotically worse than the compared activation rules. This suggests that its adaptive sparsity is not obtained by a qualitatively heavier activation mechanism.

6. Limitations, scope, and interpretation

The paper is explicit that the AFA theory is derived under the linear representation hypothesis with a one-layer linear decoder. Extensions to more general superposition mappings, two-layer decoders, or architectures such as Matryoshka SAEs are left open. It also notes that the expectation argument used to identify the embedding norm with the expected sparse-feature norm is simplifying, and that a more rigorous treatment could yield looser but more principled bounds (Lee et al., 31 Mar 2025).

A second limitation is that Top-AFA removes the inference-time hyperparameter kk4 but still introduces a training-time regularization coefficient kk5. The paper treats this as fundamentally different from choosing a fixed activation count, because kk6 shapes optimization rather than directly prescribing kk7, but the method is not hyperparameter-free. The paper also acknowledges that real pretrained decoder dictionaries are often less quasi-orthogonal than ideal high-dimensional geometry would permit, so the approximation kk8 is not exact in practice.

Finally, the empirical case made for Top-AFA is primarily geometric and reconstruction-centered. The paper does not claim a direct proof that lower kk9 yields uniquely canonical or monosemantic features. A plausible implication is that Top-AFA improves the alignment between input magnitude and sparse activation magnitude, which may be favorable for interpretability, but the paper stops short of proving that this alone resolves broader questions about feature semantics.

Top-AFA is therefore best understood as a theoretically motivated, input-adaptive alternative to fixed top-0\ell_00 sparsification in SAEs. Its distinctive contribution is not merely higher reconstruction quality, but a reformulation of sparsity control around approximate feature activation: the sparse code should activate to the extent predicted by the input embedding norm, not to the extent imposed by a global constant.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Top-AFA.