Making Pre-trained Language Models Great on Tabular Prediction

Jiahuan Yan, Bo Zheng, Hongxia Xu, Yiheng Zhu, Danny Chen, Jimeng Sun, Jian Wu, Jintai Chen

Introduction

While deep learning has revolutionized text and image processing, tabular data has largely remained the stronghold of tree-based models like XGBoost. This paper introduces TP-BERTa, a pre-trained language model specifically adapted for tabular prediction. By introducing novel ways to tokenize numerical values and fuse feature names with their values, TP-BERTa successfully transfers knowledge across highly diverse tables, outperforming existing deep tabular models and competing directly with Gradient Boosted Decision Trees (GBDTs).

The Challenge of Tabular Transfer Learning

Transfer learning—training a massive model on diverse data and fine-tuning it on a specific task—is standard practice in Natural Language Processing (NLP) and Computer Vision (CV). However, applying this to tabular data is notoriously difficult because every table is heterogeneous; they have different column names, feature types, and distributions.

Language Models (LMs) are theoretically great candidates for cross-table transfer learning because they inherently understand the semantics of feature names (e.g., knowing that "Age" and "Years Old" are related). However, LMs face two massive hurdles when processing tables:

  1. Numerical Illiteracy: LMs are designed for discrete text, making them terrible at understanding continuous numerical values, which are ubiquitous in tables.
  2. Structural Confusion: Simply flattening a table into a long sentence (e.g., "[Age] is 30, [Income] is 50000") confuses the LM's attention mechanism. It forces the model to work hard just to match the correct value to the correct column name, while also ignoring the fact that column order in a table doesn't actually matter.

Methods: Introducing TP-BERTa

To overcome these hurdles, the authors build TP-BERTa (Tabular Prediction adapted BERT) on top of the RoBERTa architecture, introducing two key innovations:

Architecture of TP-BERTa, highlighting the Relative Magnitude Tokenization (RMT) and Intra-Feature Attention (IFA) modules.
  1. Relative Magnitude Tokenization (RMT): Instead of feeding numbers as raw strings, TP-BERTa discretizes numerical values using a target-aware C4.5 decision tree. These continuous values are mapped into 256 newly initialized "magnitude tokens" added to the LM's vocabulary. To ensure the model understands that these tokens represent numbers, a magnitude-aware triplet loss is applied during pre-training, forcing the embeddings of close numbers to be mathematically closer in the latent space than distant numbers.
  2. Intra-Feature Attention (IFA): Instead of feeding the entire table as one massive text sequence, the IFA module processes each feature independently. It uses a shared multi-head self-attention mechanism to fuse a single feature's name and its value into a single, refined vector. These fused vectors are then fed into the main RoBERTa encoder. This prevents the LM from accidentally mixing up mismatched names and values, makes the model invariant to column order, and reduces computational overhead.

Datasets and Pre-training

The model was pre-trained on a massive corpus from the TabPertNet database, consisting of 101 binary classification datasets and 101 regression datasets (totaling ~10 million samples). For downstream evaluation, it was tested on 145 typical tabular datasets (80 classification, 65 regression) with fewer than 10,000 samples each, alongside specialized scenarios including 32 multi-class classification tasks and 25 medical-domain datasets.

Key Insights

  • Semantics are the ultimate bridge: TP-BERTa proves that LMs can transfer knowledge across completely disjointed tables without needing overlapping columns. Because the LM understands semantics, patterns learned regarding "male & female" in pre-training can inherently transfer to "boy & girl" in a downstream task.
  • Treating numbers as strings is a trap: Previous attempts to use LMs for tabular data treated numbers as raw text. The authors showed that replacing their RMT approach with a "value string" approach caused a massive 12.45% average drop in AUC. Numbers need spatial, magnitude-aware embeddings to be useful to an LM.
  • Categorical dominance is the LM's sweet spot: TP-BERTa shines brightest on datasets where categorical (text-based) features dominate. If a dataset is purely numerical, traditional GBDTs still hold the advantage.

Key Results

TP-BERTa demonstrates state-of-the-art performance among deep tabular models and proves highly competitive with traditional tree-based methods.

Performance comparison of TP-BERTa against various baselines across 80 classification and 65 regression tasks.
  • Overall Performance: TP-BERTa outperformed all tested deep tabular models (including TabNet, FT-Transformer, and SAINT) and cross-table models (TransTab, XTab) in average rank across the 145 downstream datasets.
  • Competitiveness with GBDTs: TP-BERTa is highly competitive with XGBoost and CatBoost, frequently beating them on datasets with informative categorical features.
  • Ablation Success: Removing the IFA module and feeding raw text to the LM caused an average AUC decline of 4.17% and increased training time by 1.32x, proving the efficiency of fusing feature names and values early.
  • Medical Domain Zero-Shot-like Power: On 25 medical datasets, TP-BERTa (using only default hyperparameters) outperformed heavily tuned GBDTs and DNNs. This suggests pre-trained LMs can leverage general domain knowledge to excel in high-value, data-scarce fields like healthcare.

Limitations and Future Work

While powerful, TP-BERTa relies heavily on meaningful feature names. If a dataset is anonymized for privacy (e.g., columns named "v1", "v2") or uses obfuscated categorical values, the model loses its primary semantic advantage. Furthermore, the model still underperforms GBDTs on datasets that consist entirely of numerical features due to the inherent precision loss of tokenizing continuous values.

Future work will explore better numerical representation strategies to close the gap on purely numerical tables, as well as investigate why jointly pre-training the model on both classification and regression tasks simultaneously resulted in slightly worse performance than training specialized versions for each.

Summary updated

BibTeX
@inproceedings{yan2024making,
  author = {Jiahuan Yan and Bo Zheng and Hongxia Xu and Yiheng Zhu and Danny Chen and Jimeng Sun and Jian Wu and Jintai Chen},
  title = {{Making Pre-trained Language Models Great on Tabular Prediction}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=anzIzGZuLi},
}
Figure