Scalable In-Context Learning on Tabular Data via Retrieval-Augmented Large Language Models

Xumeng Wen, Shun Zheng, Zhen Xu, Yiming Sun, Jiang BianarXiv 2025 · DOI

Abstract

Tabular In-Context Learning (TabICL) allows Large Language Models (LLMs) to perform classification and regression tasks without explicit training by providing examples in the prompt. However, the limited context window of LLMs restricts their ability to leverage large-scale datasets. This paper introduces a retrieval-augmented approach, RAG+Phi3-GTL, which uses a specialized tabular retriever to select the most relevant instances for the LLM. We demonstrate that this method enables "any-shot" learning, where performance scales predictably with the size of the training pool, achieving competitive results on a benchmark of 69 diverse datasets.

Introduction: The Context Wall in Tabular Learning

Tabular data is the backbone of critical sectors like finance and healthcare. While tree-based models like XGBoost remain the standard, LLMs have shown promise through Tabular In-Context Learning (TabICL). By representing rows as text, LLMs can generalize from examples provided in the prompt. However, the "context wall"—the token limit of LLMs—restricts them to a few dozen examples, preventing them from utilizing the thousands of rows available in real-world datasets. This limitation has historically kept LLMs from matching the performance of classical models that process the entire training set.

Methodology: RAG+Phi3-GTL

To overcome the context wall, the authors propose a decoupled architecture consisting of two main components:

  1. TabRAG (The Retriever): A non-parametric module tailored for tabular data. It calculates distances using feature-wise similarities, employing Pearson Correlation for linear relationships and Predictive Power Score (PPS) for non-linear ones. This ensures the LLM receives the most informative neighbors rather than random samples.
  2. Retrieval-Guided Instruction-Tuning: The researchers post-trained a Phi-3-Medium model (with a 128k context window) to reason specifically over these retrieved contexts. This alignment allows the model to effectively process the distribution of neighbors provided by the TabRAG module.

Scaling Laws and Decision Boundaries

A primary finding of this work is the "Power Law of Tabular Scaling." As the training pool size ($D$) for the retriever increases, the LLM’s error drops at a predictable rate, following $L(D) = (D_c/D)^\alpha$. This suggests that LLMs can effectively "search" through massive datasets to find relevant case-by-case evidence, effectively bypassing the context window constraint.

Scaling performance of RAG-based TabICL compared to random selection across training pool sizes and in-context instance counts.

Furthermore, LLMs produce "jagged" decision boundaries, indicating a sophisticated form of generalization distinct from the smooth boundaries of neural networks or the axis-aligned splits of tree models. This unique behavior allows LLMs to handle "integer regression" naturally and provide natural language explanations for their predictions, acting as a universal interface for data.

Experimental Results

The model was evaluated on a benchmark of 69 datasets, including standard deep learning challenges and synthetic patterns.

Comparison of RAG+Phi3-GTL against state-of-the-art tabular models across classification (AUROC) and regression (NMAE) tasks.

Key findings include:

  • Scalability: The retrieval mechanism allows the LLM to leverage up to 50,000+ training instances, far exceeding the limits of standard few-shot learning.
  • Competitive Performance: RAG+Phi3-GTL outperformed state-of-the-art models on approximately 17-20% of datasets. While it slightly trails the best-tuned numeric models like TabPFN-v2 on average, it offers a diverse error profile that makes it an excellent candidate for ensembling with models like LightGBM.
  • Efficiency: Performance often saturates with just a few dozen "adaptive" neighbors, proving that a smart retriever is more valuable than a massive, uncurated context.

Conclusion and Future Work

RAG+Phi3-GTL demonstrates that LLMs can scale to large tabular datasets through intelligent retrieval. While challenges remain in "retrieval engineering"—finding the optimal features for neighbor selection—and closing the numeric reasoning gap, this approach opens a new path for universal, language-interfaced tabular AI. Future research will focus on refining retrieval policies and using synthetic data to further improve model robustness.

Summary updated

BibTeX
@misc{wen2025scalable,
  author = {Xumeng Wen and Shun Zheng and Zhen Xu and Yiming Sun and Jiang Bian},
  title = {{Scalable In-Context Learning on Tabular Data via Retrieval-Augmented Large Language Models}},
  year = {2025},
  eprint = {2502.03147},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.03147},
}
Figure