MambaPFN: Amortized Nonlinear Variable Selection Without Refitting
Variable selection can be turned into a one-time pretrained mapping: MambaPFN trains a Transformer on synthetic graph-structured data and infers on new datasets without parameter updates, at the cost of a positive-density assumption.
On this page
Your team has a wide behavior table and one week to decide which columns go into next quarter's model. The easy move is to rerun the selector every time the data changes: fit a linear regression and sort by coefficient size, or train a model that can approximate arbitrary curves and look at which columns matter. That habit carries a hidden cost. Each selection round is a fresh fit, so more columns means more waiting, and the column list you get this week has no reuse value next week. MambaPFN attacks exactly that: pretrain once on a large batch of synthetic tasks so that "look at data, pick variables" becomes a fixed mapping, then infer on new data without touching a single parameter [1].
The default: refit the selector every time the data changes
Existing variable-selection methods fall into roughly two camps. Model-based methods assume a shape for the regression function — typically linear — and shrink coefficients to zero under a penalty; Lasso is the canonical case, and the selected set is read off the nonzero coefficients. These are interpretable and come with guarantees, but the guarantees are tied to the assumed structure. Assume linearity and you get a method that is good at finding linear effects.
Model-agnostic methods drop the shape assumption. On the statistics side, knockoffs construct negative-control variables and use them to control the false discovery rate; kernel methods instead find variables through gradients of conditional dependence measures in a reproducing kernel Hilbert space. On the machine-learning side, neural networks are used directly, because they can approximate arbitrary nonlinear relationships and therefore pick up variables whose relation to the response is complicated [1].
The problem is not accuracy; it is the workflow. None of these methods is amortized — meaning trained once and then applied to new tasks by inference rather than refitting — so every new dataset triggers a fresh fit. Neural-network-based selectors without distributional assumptions on the data can also be slow. The paper makes a deployment point: variable selection is a pre-modelling step, meant to shrink the column set before you fit anything, and a slow pre-step is a bad trade.
There is a quieter cost too. These methods learn nothing across datasets. You may have selected variables on a thousand tables, and the thousand-and-first still starts from scratch. The paper leans on Sutton's Bitter Lesson: over time, general methods that scale with compute tend to win. That reframes the question as: can "look at data, pick variables" itself be learned as a mapping? [1]
What MambaPFN actually does: selection as a fixed mapping
MambaPFN stands for Model-Agnostic Markov Blanket selection with Prior-data Fitted Networks. Each part of the name maps to a design decision.
Start with the target. The paper aims at what it calls the Markov blanket of Y: given this set of variables, the remaining variables are conditionally independent of the response. There is a terminology boundary worth keeping straight: in the general literature any set satisfying that conditional independence can be called a blanket, while the smallest one is the Markov boundary. The paper says in a footnote that some references call it the Markov boundary but that it uses the term Markov blanket throughout, and the unique minimal set is guaranteed only under Assumption 1, which requires the joint density of (X1,...,Xp,Y) to be strictly positive on R^(p+1) [1]. Read from the graph, the set is the union of Y's parents, Y's children, and the other parents of those children (the paper calls them spouses). It does not rely on a linear or generalized additive model, which is what makes it suitable for detecting nonlinear effects [1].
Now the mapping. Variable selection can be written as a function T that takes a dataset and returns a p-dimensional 0/1 indicator vector, where a 1 in position j means column j should be selected. Lasso fits this framing too: it estimates coefficients under a linear assumption, then derives the indicator from those coefficients. The difference is that MambaPFN does not prespecify T; it learns T with a Transformer. A standard Transformer handles variable-length input with embeddings, self-attention and multilayer perceptrons, then averages representations across samples and multiplies by a learnable vector to output a scalar. That cannot be used as-is here: the input and output shapes do not match, the response must not be treated as an ordinary covariate, and the model has to be invariant to permutations of observations and equivariant to permutations of covariates [1]. The paper therefore redesigns it with entry-wise embedding, bidirectional self-attention (row-axis then column-axis), a softmax-weighted aggregation over observations using a learnable query, and a sigmoid head that outputs a p-dimensional vector of inclusion probabilities, so it can ingest datasets with different sample sizes n and column counts p [1].
Where the pretraining data comes from: random graphs and layered sampling
Amortized methods need a large supply of training pairs with known answers. Real datasets do not carry those answers — nobody knows which columns are truly relevant. So the paper synthesizes them, under three principles: computational scalability (cheap enough to generate in bulk), distributional richness (covering a wide range of covariate-response relationships), and faithfulness (the generated data really does correspond to its labelled answer and satisfies Assumption 1).
The third principle is where naive approaches break. If you first declare "columns 3 and 7 are relevant" and then generate data arbitrarily, the data may not actually depend only on those columns. The paper inverts the order: draw a directed acyclic graph (a graph whose edges are one-directional and contain no cycles), with one node per covariate plus the response, then read the Markov blanket straight off the graph, the union of parents, children, and spouses. That is the ground-truth indicator I*.
Data generation follows the graph. Nodes are partitioned into topological layers. Root nodes are sampled from densities drawn from a family of strictly positive densities. Every other node is generated as a function of its parents plus noise, with the function drawn from a function class and the noise drawn from the positive-density family, so the joint density stays strictly positive and Assumption 1 holds [1]. But the blanket read off the graph equaling the true minimal set is not automatic: the paper gives counterexamples where dependencies cancel (for Y = X1 + e and X2 = Y + X1 + e', X1 lies in the graph blanket yet not in S*), and uses Assumptions 2-4 (local graph structure, a non-degenerate function class, log-concave noise densities that include Gaussian, Laplace and logistic) plus Lemma 2 to guarantee MB_psi(Y) = S* [1]. Swap the graph, the functions, or the noise, and you have a new task, which is why the generator can supply pretraining data indefinitely; the reported scaling of performance with pretraining rests on exactly this endlessly supplied, label-faithful synthetic distribution [1].
The training objective and the architecture changes
The objective does not regress directly on 0/1 labels. It targets each variable's posterior inclusion probability (PIP). Be precise about what that means: PIP = P(I_j = 1 | D_n) is the probability that the variable belongs to the true blanket given the observed data, under the synthetic distribution family P used for pretraining. The paper explicitly notes that this posterior depends only on the family P from the pretraining data-generation process, so it is not a frequentist confidence score calibrated against arbitrary real data distributions [1]. Proposition 3 states that under Assumptions 2-4 and with a sufficiently large function class, the global minimizer of the Bernoulli log-loss identifies these PIPs; Proposition 4 states that the output converges to the true label as the sample size n goes to infinity [1]. With finite samples the output is a p-dimensional vector in the unit interval, so obtaining a 0/1 list still needs a hard threshold alpha: the paper picks alpha on synthetic data by the mis-selection rate of each candidate (other criteria such as the Matthews correlation coefficient can be substituted), separating probability estimation from metric-specific variable selection so that changing the criterion needs no retraining [1]. The output is therefore a prior-dependent probability score, not a calibrated confidence value that can be read off directly; using it as a confidence judgment requires extra calibration tests and coverage conditions that the paper does not provide. Architecturally the model is a modified Transformer whose output gives per-variable inclusion probabilities, trained jointly with the data generator. After pretraining, a new dataset requires only a forward pass with no parameter updates; the paper's exact phrasing is that it is applied to new datasets without parameter updates [1].
The three pieces of evidence: simulation, scaling, and Facebook comments
First, simulation studies (Section 4.1, Figure 1). The paper reports three quantities: the F1-score of the selected subset, the area under the ROC curve (AUC) for the full ranking of covariates, and the absolute model-size gap versus the truth. Baselines are Lasso, SCAD, ABESS, DFS, STG, HSIC-Lasso, Knockoffs and the amortized causal-discovery method CauScale [1]. Settings are n in 100 / 200 / 400 / 800 / 1600 with p = 20, or n = 800 with p in 15 / 20 / 25 / 30 / 35; the paper reports that MambaPFN typically attains the highest F1 and AUC and keeps a substantially smaller model-size gap that approaches zero as n grows [1]. The per-cell numbers live in the three panels of Figure 1 rather than in the body text, so only the metrics, baselines and direction are stated here; no per-method accuracy table is invented.
Second, a scaling experiment (Section 4.2, Figure 2). The paper draws a pool of 3.2 x 10^5 synthetic datasets, forms six nested training sets from 9.6 x 10^3 up to 3.2 x 10^5, ranges model size from 5.9 x 10^4 to 1.1 x 10^7 parameters, and validates on 2,048 held-out data-generating processes from a seed stream disjoint from the pretraining pool [1]. What it observes is that validation log-loss decreases as both the number of pretraining datasets M and the parameter count N grow, so the estimated inclusion probabilities move closer to the PIPs, and the paper suggests accuracy can be improved further by scaling up pretraining [1]. This is an empirical observation (Figure 2 fits power laws), not a theorem that more compute always helps, and it is a property non-amortized methods cannot have: running Lasso ten thousand times does not make Lasso stronger.
Third, the Facebook comments dataset (Section 5, Figure 4). This is the UCI Facebook Comment Volume data with 40,949 observations and 53 covariates, the response being the number of new comments in the following H hours; the paper stresses that this dataset was never used to train the Transformer, so it is an out-of-distribution setting [1]. Because the truly relevant variables are unknown here, the paper uses a surrogate criterion: randomly allocate 30% of observations to variable selection, 30% to fitting an MLP on only the selected variables, and 40% to measuring test-set R-squared, repeated over 10 splits. Figure 4 shows test R-squared, number of selected variables and runtime, with error bars of one standard error across the 10 splits [1]. Results: MambaPFN achieves the highest R-squared, selects the fewest variables (the three selected variables have PIPs 0.94, 0.89 and 0.71), and takes less than one second; relative to the best baseline on predictive performance, the R-squared improvement approaches 20%, and the paper does not name which baseline that is [1]. Speed has to be scoped: in the simulation study (Section 4.3) it is nearly 10 times faster than model-agnostic methods such as Knockoffs and HSIC-Lasso and about 10 times faster than CauScale, also faster than Lasso and SCAD; on this Facebook dataset it is about 5 and 9 times faster than HSIC-Lasso and CauScale respectively [1]. So the claim of being more than 10-fold faster than a neural-network baseline gets the comparison group wrong and merges numbers from two different settings; approaching 20% is a direction in R-squared against one best baseline, not a 20% win over every baseline, and not a 20% rise in variable-selection accuracy.
| Method family | Representative approach | On a new dataset | Improves with pretraining scale? |
|---|---|---|---|
| Model-based | Linear model with penalty (Lasso) | Refit | No |
| Statistical, model-agnostic | Knockoff negative controls; kernel conditional-dependence gradients | Recompute | No |
| ML-based, model-agnostic | Neural networks approximating nonlinearity | Retrain, potentially slow | No |
| Amortized (MambaPFN) | Transformer learns dataset-to-indicator mapping | One forward pass, no tuning | Yes (scaling law reported) |
Where this method stops: assumptions, target, and cost
First, Assumption 1 is load-bearing, but do not overstate what it rules out. It requires a strictly positive joint density, and Section 2.1 describes it as an identifiability condition that excludes cases where two variables follow an exact deterministic relationship (for example, an exact linear one); columns that are strongly correlated yet each carry independent noise still have a strictly positive joint density and do not violate it on that account [1]. A hypothetical three-column comparison makes the boundary concrete (this is a constructed example for explanation, not paper data): X2 = 2 X1 is a deterministic duplicate that collapses the distribution to a lower dimension and breaks strict positivity; X2 = 2 X1 + e with independent noise e is strongly correlated but non-deterministic, so the assumption still holds, though collinearity makes finite-sample estimates less stable; a nonlinear interaction such as Y depending on X1 times X2 is also allowed and is exactly the kind of effect the method targets [1]. What preprocessing must remove is the first kind, exact deterministic duplication or complete collinearity, not every highly correlated column. Break the assumption and the unique minimal blanket may not exist, leaving the method's target ill-defined [1].
Second, it finds a Markov blanket, not a full causal graph, and not causal directions. The paper says this itself: amortized causal-discovery methods must first recover the whole graph, a harder task than identifying the response's Markov blanket. If your question is "what causes what," this method does not answer it [1].
Third, split the cost into two layers instead of charging it all to the user [1]. The pretrainer pays a one-time cost: generating a large volume of synthetic tasks (the paper's pool is 3.2 x 10^5 datasets) and training a model up to 1.1 x 10^7 parameters; that money is spent once, at training time [1]. A user who reuses an already trained model pays only a single forward pass, and the paper makes applied to new datasets without parameter updates its selling point; on the Facebook data that step takes less than one second [1]. The original draft wrote synthetic-task generation and large-model training as an upfront cost every project must bear, which assumes every user pretrains from scratch and is not the usage the paper sets up. To be fair, though, the paper does not state that pretrained weights or a code repository are publicly downloadable, so whether a ready-made model can be reused remains a premise the user has to confirm (to be verified). For a one-off project with no ready-made model, running Lasso is simply less trouble; only when variable selection repeats across many structurally similar tables and the same model can be reused does the upfront cost get amortized.
Fourth, the empirical base is narrow, so the denominators must be pinned down. The simulations are synthetic; only one real dataset (Facebook comments) is reported, in an out-of-distribution setting with test R-squared as a surrogate because the true variables are unknown [1]. Approaching 20% is the improvement in test R-squared over the single best-performing baseline, not a 20% win against every baseline and not a 20% rise in variable-selection accuracy, and the paper does not name that best baseline [1]. Speed is likewise setting-specific (nearly 10-fold in simulation, about 5-fold and 9-fold on Facebook) and should not be merged into one more-than-10-fold claim.
