TL;DR
MatrixFormer is a pre-trained "matrix-native" transformer designed to solve matrix completion problems—from filling in missing tabular data to estimating causal effects—in a single forward pass. By treating the matrix as a 2D grid and training entirely on diverse synthetic data, it achieves state-of-the-art zero-shot performance across multiple domains while operating over 100x faster than previous entry-wise foundation models.
What Problem Does This Paper Address?
Matrix completion is a fundamental task in data science, appearing whenever we have partially observed data, such as user-item ratings in recommendation systems or missing clinical measurements. Traditionally, researchers have used task-specific methods like Singular Value Decomposition (SVD) or MICE, which must be re-fitted for every new dataset.
Recently, "foundation models" for tabular data have emerged, but they often treat matrix completion as a sequence of independent entry-by-entry predictions. This approach is computationally expensive because it repeats the entire context for every missing cell and, more importantly, it fails to fully exploit the two-dimensional structure (rows and columns) inherent in a matrix. The authors of MatrixFormer aim to create a general-purpose model that understands this 2D structure natively and can complete an entire matrix efficiently.
Methods
The core innovation of MatrixFormer is its axial attention architecture. Instead of performing standard self-attention across all cells (which would be computationally prohibitive), the model alternates between attending to all columns within a row (feature attention) and all rows within a column (datapoint attention). This allows information to flow across the entire matrix while keeping the computational cost manageable.
Key components of the method include:
- Grid Representation: Each cell is treated as a token. Observed values are embedded via an MLP, while missing values are represented by a learned mask token.
- CLS Tokens: The model prepends special "row-CLS" and "column-CLS" tokens to aggregate global information along each axis.
- Probabilistic Output: Rather than just predicting a single number, the decoder outputs a "bar distribution" (5000 bins), allowing the model to express uncertainty for every missing entry.
- Synthetic Pre-training: The model is trained purely on synthetic matrices generated from four distinct families (low-rank, spectral with slow/steep tails, and latent-factor). This ensures the model learns general structural patterns rather than memorizing specific datasets.
- Observed-Error Ensembling: The final MatrixFormer model is a convex blend of two experts: a general-purpose "Impute" model and a "RecSys" specialist. The weights for this blend are determined on-the-fly for each new matrix by minimizing the reconstruction error on the already observed entries.
Datasets
MatrixFormer was evaluated zero-shot (without further training) on a wide variety of benchmarks:
- Causal Panel Data: CPS placebo study, Kansas semi-synthetic factor design, and California smoking donor pool.
- Tabular Imputation: MissBench (42 datasets) and a UCI-style suite (12 datasets) covering various missingness mechanisms (MCAR, MAR, MNAR).
- Recommendation Systems: MovieLens 100K and a small subset of the Netflix dataset.
- LLM Evaluation: Reconstructing missing benchmark scores for language models using MTEB, MMLU, and BenchPress matrices.
Key Insights and Ideas
- 2D Structure Matters: By preserving the grid layout, MatrixFormer captures the dual nature of data—where rows represent individual units and columns represent shared features—far more effectively than models that flatten data into sequences.
- Synthetic Data is a Powerful Prior: The success of the model demonstrates that a sufficiently diverse synthetic training distribution (varying rank, spectral shape, and missingness patterns) can produce a model that generalizes to real-world tasks as varied as cigarette sales forecasting and movie recommendations.
- Efficiency via Factorization: The axial attention mechanism reduces the complexity from $O(R^2C^2)$ to $O(RC(R+C))$, enabling the model to handle much larger matrices than previous transformer-based imputers.
- In-Sample Evidence for Ensembling: Using the error on observed entries to weight experts allows the model to adapt to the specific "flavor" of a new matrix (e.g., whether it looks more like a recommendation grid or a tabular dataset) without needing ground truth for the missing values.
Key Results
MatrixFormer demonstrates significant improvements in both speed and accuracy:
- Speedup: For a 1024 x 10 matrix, MatrixFormer is 107x faster than the legacy TabImpute model, completing the task in just 0.0389 seconds.
- Causal Inference: It achieved the lowest normalized error in five out of six causal panel benchmarks, significantly outperforming established methods like Synthetic Difference-in-Differences (SDiD).
- Tabular Imputation: It attained the lowest overall NRMSE (Normalized Root Mean Squared Error) on both the MissBench and UCI suites, proving its robustness across different missing-data scenarios.
Limitations and Future Work
While MatrixFormer pushes the boundaries of foundation models for matrices, the authors note several areas for growth:
- Context Window Limits: Although the model handles larger matrices than its predecessors, it is currently limited to a training-derived window of roughly 2000 rows and 1000 columns.
- Ensemble Granularity: The current ensembling method uses a single weight for the entire matrix; future versions might benefit from cell-specific or row-specific weighting.
- Uncertainty Application: While the model predicts full distributions, the authors suggest that future work should focus on how to best use these distributions to provide confidence intervals for downstream tasks like treatment effect estimation.
Summary updated