All models

pytorch_tabular.TabTransformer

Transformer layers over categorical column embeddings give tabular models contextual features that rival boosted trees.

Tabular and recommender · 195 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (33 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
272.3K
Operations
195
Framework
PyTorch
Recurrent
No
Published
2020
Cited by
1,391 (as of 27 November 2026)
Authors
Xin Huang, Ashish Khetan, Milan Cvitkovic, Zohar Karnin
License
MIT
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m8461
Graph hash
48b6d2d8a2a6eb1b560428b96c1d1c2c0bf9ce462dec8fd86ae784b22b48aa0e
Skeleton hash
f1e032614d8beebf4a0aff7cd2240d8a2dc2ef2a2f2247722ccbe14d5e5bd6a7
Architecture hash
6e03d4604df3a9fb35bc08be8a16585c1d7b5889abd79ccae64ad394fc95126a
Diagram SHA-256
e77bf6743e8fc679ef30dd50ba425743e57041eaaa2754dca317d6ef5eca833c
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

About this model's family

TabTransformer is a deep model for tabular data, the rows-and-columns data behind recommender systems and online advertising, built for both supervised and semi-supervised learning. It matters because tree ensembles such as gradient boosted decision trees were the state of the art for tabular data, while plain MLPs did not match them on most datasets. The idea is borrowed from NLP: run Transformer layers over the embeddings of categorical features so that each becomes a contextual embedding informed by the others.

The architecture is a column embedding layer, a stack of N Transformer layers and a multilayer perceptron on top. Only the categorical columns go through the Transformer, and their contextual embeddings are then concatenated with the raw continuous features before the MLP. Each column embedding carries a unique column identifier alongside the value embedding, and there are no positional encodings because table columns have no order. Every embedding table also holds one extra entry for a missing value. For semi-supervised settings the Transformer layers can be pre-trained on unlabeled rows with masked language modeling or replaced token detection, called TabTransformer-MLM and TabTransformer-RTD.

The reported configuration fixes the embedding dimension, layer count and attention heads at 32, 6 and 8. Across 15 datasets it beat the baseline MLP on 14 of them with an average 1.0% AUC gain. Against gradient boosted trees it performed comparably. The paper also argues the contextual embeddings make the model more stable than an MLP when categorical values are noisy or missing. The lucidrains readme sums it up as a simple architecture that came within a hair's breadth of GBDT's performance.

Key idea. Contextual embeddings for categorical features, produced by Transformer layers over column embeddings, which lift tabular deep learning past MLPs and up to tree-ensemble accuracy while supporting unsupervised pre-training on unlabeled rows.

  • tabtransformer
  • tab transformer
  • tabular data
  • contextual embeddings
  • categorical features
  • column embedding
  • tabular deep learning
  • gbdt
  • semi-supervised tabular
  • tabtransformer-mlm
  • tabtransformer-rtd
  • pytorch_tabular
  • pytorch-widedeep
  • tab-transformer-pytorch
  • amazon

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{huang2020tabtransformertabulardatamodeling,
      title={TabTransformer: Tabular Data Modeling Using Contextual Embeddings}, 
      author={Xin Huang and Ashish Khetan and Milan Cvitkovic and Zohar Karnin},
      year={2020},
      eprint={2012.06678},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2012.06678}, 
}