
pytorch_widedeep.FTTransformer
Tabular and recommender145 ops134.2K params
Embed every table column, numeric or categorical, then let a plain Transformer and a [CLS] token do the prediction.
Tabular and recommender · 124 operations Checked
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.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
About this model's family
FT-Transformer, short for Feature Tokenizer plus Transformer, is a tabular model from the Yandex paper Revisiting Deep Learning Models for Tabular Data. The paper's starting point is that tabular deep learning papers rarely compare properly, so nobody knows which model performs best. Its answer is two reusable baselines, a ResNet-like network and FT-Transformer, with the second described as a simple adaptation of the Transformer architecture that outperforms other solutions on most tasks. The readme's one-sentence version is that MLP-like models are still good baselines and FT-Transformer is a new powerful adaptation of the Transformer for tabular problems.
The model turns every feature, categorical and numerical alike, into an embedding and runs a stack of Transformer layers over them, so each layer attends across the features of one row. The Feature Tokenizer gives each feature its own bias plus a learned mapping, an element-wise multiplication with a weight vector for numbers and a lookup table for categories. A [CLS] token is appended to the feature embeddings before the Transformer layers, and its final representation is passed through LayerNorm, ReLU and a linear layer for the prediction. The layers use the PreNorm variant, with the first normalization removed from the first layer for good performance. The default configuration has 3 layers, a feature embedding size of 192 and 8 attention heads. An ablation shows the feature biases are necessary, and that the vanilla Transformer backbone beats AutoInt, which the authors call the closest competitor in spirit.
Across the benchmark, FT-Transformer gets most of its edge over the ResNet on exactly the datasets where gradient boosted trees beat the ResNet, which the authors read as evidence it is a more universal tabular model. It does not win everything, though. Once hyperparameters are tuned, GBDTs dominate on some datasets, and the paper concludes there is still no universally superior solution. The cost is speed, since the readme notes FT-Transformer is slower than MLP-like models and the paper traces that to the quadratic cost of attention in the number of features. The paper was published at NeurIPS 2021.
Key idea. A Feature Tokenizer that embeds numerical as well as categorical columns with per-feature biases, feeding a vanilla PreNorm Transformer with a [CLS] token, which became a strong and more universal baseline for tabular deep learning.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{gorishniy2023revisitingdeeplearningmodels,
title={Revisiting Deep Learning Models for Tabular Data},
author={Yury Gorishniy and Ivan Rubachev and Valentin Khrulkov and Artem Babenko},
year={2023},
eprint={2106.11959},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2106.11959},
}