---
title: Recursive Feature Machine (RFM)
url: https://www.emergentmind.com/topics/recursive-feature-machine-rfm
type: topic
---

# Recursive Feature Machine (RFM)

Recursive Feature Machine (RFM) denotes a class of kernel methods in which the feature geometry is not fixed in advance, but is updated recursively from the model’s own input sensitivities. In the RFM literature, the central object is the average gradient outer product (AGOP), a positive semidefinite matrix built from predictor gradients; its eigenspaces define task-relevant directions, and the learned matrix \(M\) is then used as a Mahalanobis-type metric inside the kernel. RFMs are therefore positioned between fixed-kernel methods and neural networks: they retain kernel-regression structure, but acquire an explicit iterative feature-learning mechanism that reshapes similarity relations during training [2407.20199] [2401.04553] [2508.10053].

## 1. Core mechanism and algorithmic structure

An RFM alternates between predictor fitting and metric update. For a predictor \(f:\mathbb{R}^d\to\mathbb{R}^c\), the AGOP is defined in this literature as
\[
\mathrm{AGOP}(f;\{x^{(j)}\}_{j=1}^n)
=
\frac1n\sum_{j=1}^n
\frac{\partial f(x^{(j)})}{\partial x}
\left(\frac{\partial f(x^{(j)})}{\partial x}\right)^\top
\in\mathbb{R}^{d\times d}.
\]
This matrix summarizes directions in input space along which the current predictor varies most strongly. Large diagonal entries indicate coordinatewise sensitivity, while leading eigendirections identify low-dimensional structure used by the model [2407.20199].

In the standard kernel-RFM formulation, one starts from a positive definite or positive semidefinite matrix \(M_0\), fits a kernel predictor under the current metric, computes AGOP, and replaces the metric by a matrix function of AGOP. A representative iteration used in the literature is
\[
f^{(t)}(x)=k(x,X;M_t)\alpha,\qquad
\alpha = k(X,X;M_t)^{-1}y,
\]
followed by
\[
M_{t+1}=\bigl[\mathrm{AGOP}(f^{(t)})\bigr]^s,
\]
with \(s>0\), often \(s=\tfrac12\). The predictor remains a kernel expansion, but the kernel geometry changes because \(M_t\) changes [2407.20199].

This learned matrix can be read as a supervised metric. In the Laplace form used in several papers,
\[
K(x,x')=\exp\!\left(-\gamma\sqrt{(x-x')^TM(x-x')}\right),
\]
so recursive updates change which directions dominate pairwise similarity. The literature also uses Mahalanobis Gaussian and quadratic kernels. A fixed kernel baseline is often defined as the same kernel with \(0\) recursive updates; in one empirical study, the “baseline” is precisely the Laplacian kernel at iteration \(0\) [2411.14079] [2303.15745].

A recurring interpretation is that RFM supplies kernel machines with an explicit feature-learning step analogous, in a limited sense, to hidden-layer adaptation in neural networks. Several papers connect this to the Neural Feature Ansatz, under which AGOP is correlated with matrices of the form \(W_l^T W_l\) in trained feedforward networks [2607.00329].

## 2. Linear RFM, spectral regularization, and the IRLS connection

The most developed theory in the supplied literature concerns the linear specialization, lin-RFM, for sparse linear regression and low-rank matrix recovery. In matrix sensing or completion, with observations \(y_i=\langle A_i,Y_\sharp\rangle\), lin-RFM trains a minimum-Frobenius-norm linear predictor in transformed coordinates and updates the transform via AGOP. In this regime, AGOP becomes exactly a Gram matrix: if \(Z=WM\), then \(\mathrm{AGOP}=Z^T Z\) [2401.04553].

The lin-RFM update can be written as
\[
W_t=\arg\min_W \|W\|_F^2
\quad\text{subject to}\quad
\langle A_iM_t,W\rangle=y_i,
\]
and
\[
M_{t+1}=\phi\!\left(M_t^TW_t^T W_t M_t\right).
\]
After reparameterization by \(Z_t=W_tM_t\), fixed points of the iteration are first-order critical points of a constrained spectral optimization problem
\[
\min_Z \sum_j \psi(\sigma_j(Z))
\quad\text{subject to}\quad
\langle A_i,Z\rangle=y_i,
\]
where \(\psi\) is induced by the matrix function \(\phi\) [2401.04553].

This yields an explicit bridge to classical iterative reweighting. For \(\phi(s)=(s+\epsilon)^\alpha\), lin-RFM is a reparameterization of IRLS with
\[
p=2-4\alpha.
\]
At \(\alpha=\tfrac14\), the induced penalty corresponds to nuclear-norm or \(\ell_1\)-type behavior; at \(\alpha=\tfrac12\), the fixed-point objective becomes log-determinant-like; for \(\alpha>\tfrac12\), the method becomes even more aggressively rank promoting. The paper’s central claim is that feature learning in this linear RFM sense generalizes well-studied IRLS dynamics rather than constituting a wholly separate mechanism [2401.04553].

The same work also proves an exact Neural Feature Ansatz statement for deep linear networks under balanced initialization and continuous-time gradient flow, and uses it to motivate “deep lin-RFM,” in which multiple AGOP-inspired matrices emulate the implicit bias of deeper linear architectures. On the computational side, it gives an SVD-free implementation for the \(\alpha=\tfrac12\) case and reports scaling to matrices with millions of missing entries; on a \(5000\times5000\) rank-\(10\) completion task with \(10^6\) observations, the implementation reached \(<10^{-3}\) test error in \(559\) seconds, compared with \(5095\) seconds and \(1779\) seconds for the cited deep linear baselines [2401.04553].

## 3. Generalization phenomena: grokking, symmetry, and feature scaling

A major strand of RFM research uses the method as a controlled model of feature learning itself. On modular arithmetic, RFM exhibits grokking: every iteration performs exact kernel interpolation, so training loss is identically zero and training accuracy is \(100\%\), yet test accuracy remains near zero for many iterations before rapidly jumping to \(100\%\). In the reported \(p=61\) experiments trained for \(30\) iterations, test metrics stay almost unchanged for roughly \(8\) iterations, test loss begins improving around iteration \(10\), and perfect test accuracy follows a few iterations later. The proposed explanation is not optimization progress, but gradual feature learning via AGOP [2407.20199].

The learned matrices in these algebraic tasks acquire highly structured forms. For modular addition and subtraction, the final \(M^*\in\mathbb{R}^{2p\times 2p}\) is reported to be block-circulant,
\[
M^*=
\begin{pmatrix}
A & C^T\\
C & A
\end{pmatrix},
\]
with circulant off-diagonal block \(C\); multiplication and division reveal the same structure after discrete-log reindexing. The paper further presents theoretical evidence that such block-circulant features implement the Fourier Multiplication Algorithm, previously proposed as the generalizing solution learned by neural networks on the same tasks [2407.20199].

A related group-theoretic study sharpens this picture. On algebraic tasks with one-hot encoded inputs, RFM reportedly generalizes only when the training set breaks a nontrivial symmetry of the target. For modular addition with \(p=61\), holding out all fixed points under a reflection subgroup yields essentially \(0\%\) test accuracy even though the training fraction is around \(99\%\). By contrast, starting from that non-generalizing split, moving one random point from train to test can restore \(98\%\) held-out accuracy for the Gaussian kernel on addition, whereas removing symmetric reflection pairs does not help. The authors interpret the learned AGOP as encoding permutation representations of subgroup elements, so that successful RFM generalization becomes a form of symmetry recovery rather than mere interpolation [2604.00316].

A third empirical phenomenon concerns ambient dimension. In a synthetic regression study, RFMs were evaluated while appending irrelevant Gaussian coordinates to data whose target depends only on the first few inputs. The reported RFM test MSE follows a decrease–increase–decrease pattern: a sharp decrease up to about \(D=0.1N\), an increase until around \(D=0.5N\), and then a shallower decrease from there to \(D=2N\). The same qualitative pattern appears across dataset sizes, label-noise levels, and a second target function, while the fixed Laplacian-kernel baseline exhibits earlier turning points around \(D=0.05N\) and \(D=0.2N\). The authors explicitly state that the similarity to double descent is phenomenological rather than established; no interpolation-threshold theorem is given [2303.15745].

## 4. Robustness and scalability extensions

Several later works modify the basic recursion to address regimes in which standard RFMs underperform. The most explicit such variant is K-Inverse-RFM, introduced for modular arithmetic, GCD, and related mathematical tasks under label corruption, imbalance, and compact Chinese Remainder Theorem (CRT) encodings. Its recursion alters three components at once: label projection,
\[
y_p = K(X,X;M_t)^d y,
\]
ridge-regularized kernel regression,
\[
\alpha_t=(K(X,X;M_t)+\lambda I)^{-1} y_p,
\]
and an inverse-loss-weighted moving average of recent AGOP matrices,
\[
M_{t+1}=
\frac{\sum_{i=t-k}^{t} \frac{1}{l_i} G(f_i)^s}
{\sum_{i=t-k}^{t} \frac{1}{l_i}}.
\]
The emphasized case \(d=-1\) motivates the name “K-Inverse.” The thesis argues that standard RFMs are limited by weak multiclass feature sharing, and that projecting labels through powers of the kernel matrix makes classes interact in a shared kernel-feature coordinate system [2607.00329].

Empirically, K-Inverse-RFM is reported to bridge an average of \(64\%\) of the gap between standard RFM and neural networks on noisy modular addition and multiplication, to improve over standard RFM by as much as \(39.3\) percentage points in test accuracy, and to remain comparable to feedforward neural networks up to about \(14\%\) label noise. On imbalanced data, it is reported to yield a \(53\%\) absolute jump in test accuracy over standard RFM at divisible-by-3 input weight \(1\), and on CRT inputs it outperforms both standard RFM and neural networks in \(5\) of \(6\) encoding-task pairs [2607.00329].

For large-scale tabular learning, xRFM localizes RFM through a supervised tree. Internal nodes fit lightweight RFM-style split models, compute AGOP, extract a top eigenvector \(v\), and split samples at the median of \(v^T x\); each leaf then trains a local RFM on at most \(C\) samples. The paper states training complexity \(O(n\log n)\) and inference complexity \(O(\log n)\) for fixed leaf size. On the TALENT benchmark, xRFM is reported to achieve the best performance across \(100\) regression datasets and to be competitive to the best methods across \(200\) classification datasets while outperforming GBDTs overall; it is also reported to outperform standard RFM and kernel ridge regression on TALENT regression with Wilcoxon \(p<10^{-4}\) [2508.10053].

## 5. Interpretability and application domains

Because the learned matrix \(M\) is explicit, RFM research repeatedly treats it as both a training mechanism and an interpretation object. In quantitative structure–property relationship modeling, RFM was applied to solubility prediction with MACCS keys, Morgan fingerprints, and a custom hybrid fingerprint (HF). The paper defines a local score
\[
\mathrm{score}(x_i)=x_i^T M x_i
\]
and a global score by dataset averaging. It reports that Matérn and Laplace kernels performed best among the tested kernel families; on AqSolDB with MACCS, the reported test RMSEs were \(1.171\) for Matérn, \(1.185\) for Laplace, \(1.276\) for Rational Quadratic, and \(1.307\) for Gaussian. The same study claims robust local and global explanations, substantial top-\(k\) overlap with permutation importance and SHAP on ESOL and FreeSolv, and stability after removing redundant features from the custom fingerprint representation [2411.14079].

RFM has also been used as a probe for hidden states of frozen generative models. In MusicRFM, layerwise RFMs are trained on mean-pooled MusicGen-large hidden states for symbolic music concepts, AGOP eigendecomposition produces orthogonal concept directions, and the top eigenvector at selected layers is injected back into the residual stream during autoregressive decoding. The steering rule is additive,
\[
h'_{t,\ell}=h_{t,\ell}+\eta_\ell(t)\,q_{\ell,j^\star},
\]
with optional layer weighting, time-varying schedules, and Bernoulli gating. In the main note-control result, target-note accuracy is reported to increase from \(0.23\) to \(0.82\), while text-prompt adherence remains within approximately \(0.02\) of the unsteered baseline over much of the tested range [2510.19127].

A closely related activation-space application identifies refusal subspaces in aligned large language models. An RFM-AGOP procedure with probe-informed initialization,
\[
M_0=\beta\,w w^T+(1-\beta)\Sigma_{X,k},
\]
and exponential moving-average AGOP updates is used to recover a multi-dimensional refusal subspace from harmful-versus-harmless residual activations. The paper reports that the subspace can be identified in seconds, that larger models require multiple directions rather than a single linear refusal vector, and that for Qwen 3 8B at least three directions are needed to exceed \(50\%\) attack success rate under ablation [2607.02396].

## 6. Limits, unresolved questions, and acronym ambiguity

Despite the breadth of applications, the supplied literature repeatedly emphasizes incomplete theory. The feature-scaling study does not derive a mechanism for its decrease–increase–decrease curve and does not provide diagnostics such as AGOP spectra or learned-metric condition numbers; the resemblance to double descent is explicitly described as suggestive rather than established [2303.15745]. The K-Inverse-RFM thesis argues that standard AGOP is only a linear input reweighting and leaves open whether stronger AGOP variants are needed for broader corrupted-data robustness [2607.00329]. Steering papers likewise report strong empirical utility while stating that the relationship between RFM-derived subspaces and alternatives such as refusal cones or sparse autoencoder features remains unclear [2607.02396].

Kernel scaling remains a general practical constraint. Standard RFM repeatedly rebuilds kernel matrices and recomputes AGOP, so large-\(n\) workloads motivate either structural modifications such as xRFM or task-specific adaptations. This suggests that future RFM research will likely continue to divide between theory of AGOP-driven geometry learning and systems work on local, sparse, or approximate implementations [2508.10053].

The acronym itself is also ambiguous outside this literature. In scientific computing, “RFM” can mean Random Feature Method, a collocation least-squares solver for PDEs that is unrelated to Recursive Feature Machines [2207.13380]. In robotics, “RFM-SLAM” denotes Relative Feature Measurements-based SLAM, where “RFM” refers to relative feature measurements rather than feature-learning kernels [1609.05235]. Within machine learning, however, Recursive Feature Machine has acquired a specific technical meaning: a kernel machine whose metric is recursively updated from AGOP so that representation learning is performed explicitly, analyzably, and, in many applications, interpretably.

Source: https://www.emergentmind.com/topics/recursive-feature-machine-rfm