---
title: Approximate Feature Activation (AFA)
url: https://www.emergentmind.com/topics/approximate-feature-activation-afa
type: topic
---

# Approximate Feature Activation (AFA)

Approximate Feature Activation (AFA) is a framework for sparse autoencoders (SAEs) that links the norm of a sparse feature vector to the norm of the corresponding dense embedding under a quasi-orthogonal decoder dictionary, and uses that link both to evaluate pre-trained SAEs and to design a top-$k$-style activation rule that does not require a fixed hyperparameter $k$ [2503.24277]. In the formulation introduced in “Evaluating and Designing Sparse Autoencoders by Approximating Quasi-Orthogonality,” AFA addresses a central limitation of $k$-sparse autoencoders: the number of nonzero latent activations, $\ell_0 = k$, is normally chosen ad hoc, is input-agnostic, and lacks theoretical justification. The AFA framework instead seeks to tie the number of active features to properties of each input embedding $z$, and thereby to remove the need to pick a fixed $k$ across all inputs [2503.24277].

## 1. Problem setting in sparse autoencoders

In a $k$-sparse autoencoder one enforces that exactly $k$ entries of the latent vector $f$ are nonzero, typically via a top-$k$ activation function [2503.24277]. This design removes the need for an explicit sparsity penalty $\lambda_s$, but it replaces that penalty with a new hyperparameter $k$ whose choice is ad hoc, input-agnostic, and without theoretical justification. The central question posed by AFA is whether the number of active features, $\ell_0$, can be tied to the properties of each input $z$ rather than fixed globally [2503.24277].

The paper formulates this question in the setting of SAEs trained on transformer hidden embeddings. In the reported experiments, GPT-2 Small layer 6, 7, and 8 embeddings are used as SAE inputs, with dictionary size $h = 16 \cdot d$, and training is carried out for $20\,000$ steps, corresponding to approximately $81.9$M tokens from OpenWebText [2503.24277]. Within that setting, AFA functions both as a theoretical lens on latent activation norms and as a practical design principle for activation selection.

A plausible implication is that AFA changes the role of sparsity control. Instead of prescribing a constant cardinality budget in latent space, it treats sparse activation as an input-conditioned quantity determined by a norm-matching target. That interpretation follows directly from the paper’s guiding objective: choose, for each input $z$, the smallest number of active features so that $\|f\|_2 \approx \|z\|_2$ [2503.24277].

## 2. Quasi-orthogonality and the Linear-AFA theorem

The theoretical derivation begins from two assumptions [2503.24277]. The first is the Linear Representation Hypothesis (LRH), written as
$$
z(x) \approx D f
$$
where $D \in \mathbb{R}^{d \times h}$ and $h > d$. The second is quasi-orthogonality of the decoder dictionary: after normalizing each column $d_i$ of $D$ to unit norm, the Gram matrix satisfies
$$
D^\top D = I^{\le \epsilon},
$$
with $1$’s on the diagonal and off-diagonals bounded by $|\epsilon_{ij}| \le \epsilon$ [2503.24277].

Under these assumptions, the key algebraic identity is
$$
\|z\|_2^2 = (Df)^\top(Df) = f^\top(D^\top D)f = f^\top I^{\le \epsilon} f
= \sum_i f_i^2 + \sum_{i \ne j} f_i f_j \epsilon_{ij}.
$$
The cross-terms are then bounded using $|\epsilon_{ij}| \le \epsilon$ and $\|f\|_1^2 \le h \|f\|_2^2$, yielding Theorem 1, called “Linear-AFA” in the paper:
$$
\|z\|_2^2 \in \left[(1-\epsilon(h-1))\|f\|_2^2,\; (1+\epsilon(h-1))\|f\|_2^2\right]
$$
and therefore
$$
\|f\|_2^2 \in \left[\frac{\|z\|_2^2}{1+\epsilon(h-1)},\; \frac{\|z\|_2^2}{1-\epsilon(h-1)}\right].
$$
This gives a closed-form error controlled by $\epsilon(h-1)$ [2503.24277].

The interpretation stated in the paper is that if $\epsilon$ is small, meaning the dictionary is nearly orthogonal, then the $\ell_2$-norm of the sparse code $f$ is tightly determined by the $\ell_2$-norm of the dense embedding $z$ up to a closed-form error proportional to $\epsilon(h-1)$ [2503.24277]. This provides the theoretical basis for replacing a fixed $\ell_0$ target with a per-input activation rule derived from norm agreement.

## 3. top-AFA: adaptive activation without a fixed $k$

The activation function introduced on top of the AFA formulation is called top-AFA. Its stated goal is to choose, for each input $z$, the smallest number of active features so that $\|f\|_2 \approx \|z\|_2$ [2503.24277]. The algorithm operates on a batch of embeddings $Z \in \mathbb{R}^{B \times d}$ with encoder $W_{\mathrm{enc}}$, decoder $W_{\mathrm{dec}}$, and biases $b_{\mathrm{enc}}, b_{\mathrm{dec}}$.

The procedure is as follows [2503.24277]. First, the input is centered:
$$
Z_c = Z - b_{\mathrm{enc}}.
$$
Second, pre-activations are computed with ReLU:
$$
F = \mathrm{ReLU}(Z_c W_{\mathrm{enc}}) \in \mathbb{R}^{B \times h}.
$$
Third, each feature receives a score
$$
s_i = f_i \cdot \|d_i\|_2^2,
$$
where $d_i$ is the $i$-th column of $W_{\mathrm{dec}}$; in matrix form,
$$
S = F \odot \mathrm{row}(\|W_{\mathrm{dec}}\|_2^2).
$$
For each example, the scores are sorted in descending order to obtain a permutation $\pi$, and cumulative sums are formed:
$$
C_k = \sum_{j=1}^k S_{\pi_j},
$$
with $C_0 = 0$ and $C_h$ set large for numerical stability. The target value is
$$
a_{\mathrm{target}} = \|z_c\|_2^2.
$$
The selected cardinality is then
$$
k^* = \arg\min_{k \in \{0,\dots,h\}} \left|\sqrt{C_k} - \|z_c\|_2\right| + 1.
$$
A binary mask $m$ keeps the top $k^*$ positions of $\pi$, the sparse code becomes
$$
f_{\text{top-AFA}} = f \odot m,
$$
and decoding produces
$$
\hat Y = F_{\text{topAFA}} W_{\mathrm{dec}} + b_{\mathrm{dec}}.
$$
This adaptively chooses $\ell_0$ per input so that $\|f\|_2$ matches $\|z\|_2$, in line with the AFA theorem [2503.24277].

The distinguishing property of top-AFA is therefore not merely that it is dynamic, but that its dynamics are explicitly tied to the norm relation implied by quasi-orthogonality. In that sense, it is a top-$k$-style mechanism whose effective $k$ is determined from each example’s activation statistics and centered embedding norm rather than supplied as a constant hyperparameter.

## 4. Evaluation of pre-trained SAEs under AFA

AFA is also presented as an evaluation methodology for pre-trained SAEs [2503.24277]. The paper argues that existing SAE evaluation methods and loss functions had overlooked the theoretically expected activation magnitude that can be computed from the input embedding. Two diagnostic tools are introduced for this purpose: the ZF plot and the quantity $\epsilon_{\mathrm{LBO}}$.

The ZF plot places each input’s dense norm $\|z\|_2$ on the $x$-axis and its learned sparse norm $\|f\|_2$ on the $y$-axis; perfect alignment is the red line $\|f\|_2 = \|z\|_2$ [2503.24277]. This visualization directly compares actual latent activations against the norm-matching relation implied by AFA. The associated scalar diagnostic is
$$
\epsilon_{\mathrm{LBO}}(x)=\frac{|\|z\|_2^2-\|f\|_2^2|}{(h-1)\|f\|_2^2},
$$
described as the “lower-bound” estimate of $\epsilon$ required to justify the observed activations [2503.24277].

By plotting $\epsilon_{\mathrm{LBO}}$ across layers or models, one can diagnose over- or under-activation relative to theory [2503.24277]. This makes the AFA perspective evaluative as well as constructive: it does not only prescribe how to design a new activation function, but also supplies a criterion for assessing whether a learned SAE behaves as though its dictionary were sufficiently quasi-orthogonal for the norm approximation to be credible.

This suggests a shift in SAE diagnostics away from reconstruction error alone. The paper’s claim is narrower and more precise: AFA connects embedding norms and feature norms in a data-driven metric that had been missing from SAE evaluation [2503.24277]. Within the paper’s framework, norm mismatch is therefore treated as an interpretable failure mode rather than merely an optimization artifact.

## 5. Training objective, baselines, and empirical findings

The training loss used for top-AFA SAEs is
$$
L = \|z-\hat y\|_2^2 + \alpha \cdot L_{\mathrm{aux}} + \lambda_{\mathrm{AFA}} \cdot (\|f\|_2-\|z\|_2)^2,
$$
with $\alpha = 1/32$ for Ghost Grads and $\lambda_{\mathrm{AFA}} = 1/16$ found stable [2503.24277]. The auxiliary norm-matching term explicitly biases learning toward dictionaries that satisfy the AFA relationship. The implementation guidance also specifies that decoder columns should be normalized to unit norm and their lengths absorbed into the encoder side so that $D^\top D \approx I^{\le \epsilon}$ holds, and that inputs should be centered by the encoder bias before computing $\|z\|_2$ [2503.24277].

The reported experiments use OpenWebText, sequences of length $128$, and approximately $80$M tokens processed over $20$k iterations [2503.24277]. Baselines are top-$k$ SAEs with $k \in \{32,64,\dots,8192\}$ and batch-top-$k$ SAEs with average $k = \mathrm{constant}$, both trained without the AFA loss [2503.24277]. The evaluation metric is normalized MSE.

The main quantitative result is that, on layers 6–8, top-AFA achieves the lowest MSE across all comparisons, including lower reconstruction error than fixed-$k$ and batch-top-$k$ baselines [2503.24277]. The paper gives a representative example on layer 6: the best top-AFA MSE is approximately $1.76 \times 10^{-4}$, whereas the best top-$k$ MSE is approximately $2.19 \times 10^{-4}$ [2503.24277]. Under top-AFA, the sparsity level $\ell_0$ adapts between approximately $2\,000$ and $3\,000$ nonzeros out of $h \approx 12\,288$, rather than remaining fixed across inputs [2503.24277].

The computational overhead is reported as
$$
O(Bhd + Bh\log h)
$$
per batch, which the paper describes as comparable to other top-$k$ methods, with wall-clock training time within $5$–$10\%$ of standard top-$k$ [2503.24277]. The empirical picture presented by the paper is therefore that top-AFA replaces hyperparameter tuning of $k$ with a modest sorting-based overhead while simultaneously improving normalized MSE and adapting the support size to each input.

## 6. Practical usage and terminological scope

The implementation guidelines associated with AFA are explicit [2503.24277]. Decoder columns should be normalized to unit norm, per-feature decoder norms $\|d_i\|_2^2$ should be precomputed and used in the scoring step, inputs should be centered by the encoder bias before computing $\|z\|_2$, and the top-AFA routine should use sorting plus cumulative sums over the $h$ features per input to produce candidate norms $\sqrt{C_k}$. The paper further recommends adding the AFA loss term $(\|f\|_2-\|z\|_2)^2$ with coefficient $\lambda_{\mathrm{AFA}} \approx 1/16$, using Ghost Grads or similar to keep features from dying, and monitoring $\epsilon_{\mathrm{LBO}}$ on a held-out set through ZF plots to verify quasi-orthogonality and detect over- or under-activation [2503.24277].

A recurring source of confusion is that the acronym “AFA” is used in several unrelated literatures. In privacy-preserving neural networks, “Batch-oriented Element-wise Approximate Activation” denotes trainable low-degree polynomial approximation of ReLU under FHE and CKKS packing, rather than sparse feature activation in SAEs [2403.10920]. In explainable AI, “Anytime Approximate Formal Feature Attribution” refers to adaptive AXp/CXp enumeration for approximating formal feature importance, and defines feature attribution as the fraction of abductive explanations containing a given feature [2312.06973]. In sequential decision-making, “Active Feature Acquisition” denotes policies that choose which features to observe under a budget, including a zero-shot variant based on LLM-elicited discriminative MRFs [2606.18933]. These usages are terminologically adjacent but methodologically distinct.

Within mechanistic interpretability, Approximate Feature Activation has a narrower and more specific meaning: it is the norm-based SAE framework derived from quasi-orthogonality, used both to assess whether learned latent activations are theoretically consistent with the input embedding and to construct the top-AFA activation rule that removes the need to tune a constant $k$ [2503.24277].

Source: https://www.emergentmind.com/topics/approximate-feature-activation-afa