TL;DR
Foundation models for tabular data often struggle with "context bloat," where attending to every training row during inference becomes computationally prohibitive. This paper introduces Localized TabICLv2, a method that uses k-nearest neighbor (k-NN) retrieval within the model's own learned representation space to prune the context, achieving up to a 249x speedup in single-query serving while retaining over 98% of the original model's accuracy.
What Problem Does This Paper Address?
In the world of tabular machine learning, "In-Context Learning" (ICL) is the new frontier. Models like TabICLv2 allow you to make predictions by simply feeding the model a set of training examples and a query row in a single forward pass—no dataset-specific training required.
However, there is a massive catch: scalability. Standard TabICLv2 uses a transformer architecture where every test point attends to every training row. As your dataset grows from 1,000 to 100,000 rows, the computational cost and memory requirements explode. This makes these powerful foundation models too slow for real-time applications or massive datasets. The authors ask a simple but vital question: Can we get the same predictive power by only looking at the most relevant training examples?
Methods
The authors propose a "localized" version of the TabICLv2 architecture, which traditionally operates in three stages:
- Stage 1: Column-wise embedding.
- Stage 2: Row-wise interaction (creating a "representation space").
- Stage 3: Final ICL prediction via self-attention.
The innovation here is the insertion of a k-NN retrieval step between Stage 2 and Stage 3. Instead of passing the entire training set to the final predictor, the model uses the embeddings generated in Stage 2 to find the $k$ most similar training rows (using cosine similarity). Only these $k$ neighbors are passed to Stage 3.
Crucially, the authors don't just use the model "as-is." They perform joint fine-tuning of Stages 2 and 3. This encourages Stage 2 to learn representations that are specifically optimized for retrieval and trains Stage 3 to make high-quality predictions even when its "worldview" is limited to just a few neighbors.
Datasets
The researchers evaluated their approach using:
- TabArena: A comprehensive benchmark consisting of 38 binary and multiclass classification datasets.
- OpenML Credit-Card-Fraud: Used specifically for scaling analysis due to its large size (up to ~285k rows).
- Synthetic Data: The fine-tuning process utilized synthetic tables generated from the
mix_scmprior to ensure the model generalizes well across different tabular structures.
Key Insights and Ideas
- Learned Space > Raw Space: One of the most important findings is that retrieving neighbors based on the model's internal Stage 2 embeddings is significantly more effective than using raw feature similarity. The model "understands" which rows are relevant better than a simple distance metric on raw data.
- The Latency "Floor": In a single-query serving setting, the latency of the localized model becomes nearly independent of the training set size. Because the transformer only ever sees $k$ rows (e.g., $k=32$), the heavy lifting of the attention mechanism is constant, regardless of whether the underlying database has 10k or 200k rows.
- ICL is more than Voting: The authors performed an ablation study showing that Localized TabICLv2 consistently beats a simple k-NN majority vote and even XGBoost trained on the same $k$ neighbors. This proves that the Stage 3 transformer is doing sophisticated reasoning over the local context, not just simple label aggregation.
Key Results
- Accuracy Retention: The fine-tuned localized model (with $k=32$) retains 98.64% of the accuracy of the full-context model.
- Massive Speedups:
- Batch Inference: Achieved a median 2.18x speedup.
- Single-Query Serving: Achieved a median 249x speedup (and up to 1223x in specific cases).
- Competitive Performance: For binary classification, the localized model's ROC AUC actually exceeded that of XGBoost, despite the localized model requiring zero hyperparameter tuning.
Limitations and Future Work
While the results are promising, the authors note a few hurdles:
- Retrieval Overhead: On very small datasets or very large query batches, the overhead of performing the k-NN search can actually diminish the speed gains.
- Information Loss: If the "signal" required for a prediction is distributed across many rows that fall outside the top $k$, the localized model will inevitably lose accuracy.
- Future Directions: The team suggests exploring more advanced retrieval backends (like FAISS), implementing "adaptive $k$" (where the model decides how many neighbors it needs), and extending the framework to regression tasks.
By turning a "global" problem into a "local" one, this paper provides a clear path toward making tabular foundation models a reality for production-scale engineering.
Summary updated