TL;DR
LinearPFN is a transformer-based model that brings "instant" Bayesian variable selection to linear models with interactions. By pretraining on millions of synthetic datasets, it replaces slow, iterative MCMC samplers with a single forward pass that delivers accurate inclusion probabilities and coefficients in milliseconds.
What Problem Does This Paper Address?
Variable selection—deciding which predictors actually matter for an outcome—is a cornerstone of scientific modeling. The "gold standard" Bayesian approach, spike-and-slab regression, provides a full probability distribution over possible models rather than just picking one. However, it has a massive computational catch: the number of possible models grows exponentially with the number of predictors.
For anything beyond a handful of variables, researchers must rely on approximations like Markov chain Monte Carlo (MCMC). MCMC is slow, requires a fresh run for every new dataset, and often struggles to converge. This makes large-scale Bayesian model averaging practically impossible for complex models involving interactions.
Methods
The authors introduce LinearPFN, a Prior-data Fitted Network (PFN). Instead of fitting a model to a dataset, they train a transformer to be the inference algorithm.
- Amortized Inference: The model is pretrained once on 2.4 million synthetic datasets drawn from a carefully designed prior. Once trained, it can perform inference on a new, unseen dataset in a single deterministic forward pass.
- Architecture: Based on
nanoTabPFN, the network uses a transformer backbone that attends across both features and rows to learn complex relationships. - Specialized Readout Heads: To handle the specific needs of variable selection, the model features three distinct "heads" (see Figure 3):
- Selection Head: Predicts Posterior Inclusion Probabilities (PIPs) for every main effect and interaction.
- Coefficient Head: Estimates posterior-mean coefficients.
- Regression Head: Outputs the full posterior predictive distribution.
- Conjugate Prior: The training data is generated using a conjugate spike-and-slab prior. This allows the authors to calculate the exact mathematical posterior for small datasets, providing a perfect "ground truth" to validate the neural network's accuracy.
Datasets
- Training: 2.4 million synthetic datasets generated from a prior designed to mimic real-world social science data (e.g., including latent factors, Likert scales, and binary variables).
- Main Benchmark: 10,000 datasets created by taking real predictor matrices from the
RDATASETScollection (383 tables from social science and psychology) and generating outcomes based on the study's prior. - Validation: A set of small-scale datasets ($p \le 5$) where the exact posterior can be computed via enumeration.
- Real-World Test: 7 classic published datasets (e.g., diabetes, prostate cancer) where LinearPFN is compared against a high-quality MCMC sampler.
Key Insights and Ideas
- Heredity Matters: The prior enforces "strong heredity," meaning an interaction effect is only considered likely if both of its "parent" main effects are also active. This mirrors how scientists typically think about interactions.
- Implicit Interaction Handling: Instead of requiring users to manually create interaction terms ($x_1 \times x_2$), the network's architecture (specifically the "combine-then-mean" summaries in the readout heads) is designed to detect these relationships automatically from the raw data.
- Validation against the "Exact": By using a conjugate prior, the authors move beyond just comparing against other approximations. They prove their network closely matches the true mathematical posterior where it's computable.
Key Results
- Superior Selection: On the main benchmark, LinearPFN achieved a higher selection AUC (0.96) and F1 score (0.77) than five classical baselines, including Lasso, SuSiE, and specialized interaction models like
hierNet. - Massive Speedup: A single forward pass on a GPU takes just 0.03 seconds. In comparison, an MCMC sampler targeting the same posterior takes about 57 seconds on a CPU—a nearly 2,000x difference in throughput.
- Robustness: The model's performance lead remained stable even when the data violated training assumptions, such as having heavy-tailed noise or fixed-magnitude coefficients.
- High Fidelity: On real-world datasets, LinearPFN's inclusion probabilities correlated at 0.972 with those from a long-running MCMC chain.
Limitations and Future Work
- Collinearity: Like many variable selection methods, LinearPFN can struggle when two predictors are nearly identical, splitting the probability between them so that neither is selected by standard rules.
- CPU Latency: While lightning-fast on a GPU, the model is relatively slow on a single CPU thread compared to simple frequentist methods like the Lasso.
- Fixed Prior: The current version is tied to the specific prior used during training. The authors suggest that future work could "condition" the network on hyperparameters, allowing users to specify their own priors at inference time without retraining.
Summary updated