Standard Transformers are designed for sequences. When we apply them to tabular data, the traditional approach is to "flatten" the table into a one-dimensional string of tokens. However, this destroys the inherent two-dimensional structure of a spreadsheet, where the relationship between two features in the same row is fundamentally different from the relationship between the same feature across two different rows.
To solve this, researchers have converged on a shared architectural motif: Dual-Axis Attention. Instead of treating a table as a line, these models treat it as a grid, alternating between attention operations that look horizontally across features and vertically across samples.
The 1D Flattening Problem
In natural language, the order of words creates meaning. In a table, the "meaning" is defined by two axes:
- The Row (Intra-sample): How different attributes (e.g., Age, Income, Zip Code) interact to describe a single entity.
- The Column (Inter-sample): How a single attribute varies across the population, providing the statistical context needed to identify outliers or trends.
As Lin Long and colleagues argue in Bridging the Semantic Gap Between Text and Table, flattening this structure into a 1D sequence forces the model to "re-learn" the grid geometry from scratch, often leading to poor structural understanding in tasks like SQL generation.
The Mechanism: Alternating Row and Column Attention
The core innovation of models like SAINT (Gowthami Somepalli et al., SAINT: Improved Neural Networks for Tabular Data) and NPT-AD (Hugo Thimonier et al., Beyond Individual Input for Deep Anomaly Detection on Tabular Data) is the use of two distinct attention layers:
- Column-wise (Feature) Attention: This layer allows the model to capture dependencies between different features of a single record. For example, it helps the model understand that a high "Income" value is contextually linked to a specific "Job Title."
- Row-wise (Sample) Attention: Often called "intersample attention," this layer allows the model to compare the current record against other records in the batch. This is the "aha!" moment for tabular AI: it enables the model to perform non-parametric learning directly within the forward pass.
By alternating these layers, the model builds a representation for every cell that is informed by both its row-mates and its column-peers. Jannik Kossen and the team behind Self-Attention Between Datapoints demonstrated that this allows deep learning models to go beyond individual input-output pairs, effectively "looking at the rest of the dataset" to make a prediction.
Efficiency through Decoupling
A naive transformer attending to every cell in a table with $R$ rows and $C$ columns would face a computational complexity of $O((R \times C)^2)$. This is prohibitive for large datasets.
Dual-axis architectures like TABBIE (Hiroshi Iida et al., TABBIE: Pretrained Representations of Tabular Data) and the work of Yufan Zhuang in Learning a Decision Tree Algorithm with Transformers solve this by decoupling the axes. By processing rows and columns independently and then merging the information, they reduce the complexity to $O(R \cdot C^2 + C \cdot R^2)$. This allows models to scale to much larger tables while maintaining the 2D inductive bias.
From Anomaly Detection to Foundation Models
This dual-axis approach has proven transformative across several domains:
- Anomaly Detection: In NPT-AD, row-wise attention allows the model to identify "victim samples"—records that look normal in isolation but appear suspicious when compared to the broader population distribution.
- Interpretable ML: Andreas Mueller and colleagues introduced GAMformer (GAMformer: Bridging Tabular Foundation Models and Interpretable Machine Learning), which uses this dual-axis processing to estimate shape functions, providing the transparency of Generalized Additive Models with the power of a foundation model.
- Causal Inference: Nan Rosemary Ke et al. utilized alternating attention in CSIvA (Learning to Induce Causal Structure) to figure out the "arrow of causality" between variables by analyzing their distributions across the entire dataset simultaneously.
The Future: Target-Permutation Equivariance
Recent refinements have focused on the mathematical symmetries of tables. Michael Arbel and Frank Hutter introduced EquiTabPFN (EquiTabPFN: A Target-Permutation Equivariant Prior Fitted Network), which ensures that the model's predictions remain stable regardless of how class labels are ordered. This is achieved by baking symmetry directly into the dual-axis attention mechanism, allowing these models to handle an arbitrary number of classes and generalize to new tasks without retraining.
By treating the table as a structured grid rather than a flat sequence, dual-axis attention provides the necessary inductive bias to finally bring the "Transformer revolution" to the world of structured data.