All models

pytorch_widedeep.SAINT

SAINT is a tabular transformer that attends across both the columns of a row and the rows of a batch.

Tabular and recommender · 131 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 (18 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
643K
Operations
131
Framework
PyTorch
Recurrent
No
Published
2021
Cited by
753 (as of 19 November 2026)
Authors
Gowthami Somepalli, Micah Goldblum, Avi Schwarzschild and others
License
Apache-2.0
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
m8464
Graph hash
1362842b7998e3d87730a3d3c7d552d00b2c0211882bf69e7030d7393419e330
Skeleton hash
c6cc5739434f06a12467faa3df6a20a48c3f55b544ab437af164bf78af46249d
Architecture hash
bc1c64f21fa874246fc820e00967e8aa57cc90d866c8ba1c5b9439559c3c2111
Diagram SHA-256
70c91733d0732653cabf6aee9614f1b370f37db5c7bbc9fb0d07680ea0916be0
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

This pytorch-widedeep port is a deeptabular component whose output is its last layer of activations, meant to be wrapped by WideDeep rather than to return class scores.

SAINT, the Self-Attention and Intersample Attention Transformer, is a transformer built for tabular data. Tabular data matters because it underpins applications from fraud detection to genomics and healthcare. Classical methods such as gradient boosting and random forests are still the practitioner's default there. SAINT's headline result is that, on average over a variety of benchmark tasks, it outperforms those boosted trees, including XGBoost, CatBoost, and LightGBM.

All features, categorical and continuous, are projected into one dense vector space and passed as tokens into a transformer encoder. Each continuous feature gets its own single fully-connected layer with a ReLU, which is where SAINT departs from TabTransformer. Each stage of the network then has two blocks: a self-attention block over the features of a row, and an intersample attention block. Intersample attention works like a nearest-neighbor classification whose distance metric is learned end-to-end rather than fixed. When a feature is missing or noisy in one row, it lets SAINT borrow the corresponding features from similar rows in the batch. Only the contextual embedding of the CLS token is passed through an MLP to obtain the final prediction.

For settings with few labels the paper adds contrastive self-supervised pre-training, using CutMix in the input space and mixup in the embedding space to make the two views. The official code exposes the variants as an attention-type flag: 'col' is SAINT-s, 'row' is SAINT-i, and 'colrow' is full SAINT. Two of the four captured members come from that official repository, and two are the same SAINT class from pytorch-widedeep, a package for deep learning with tabular data.

Key idea. SAINT adds intersample attention, attention across the rows of a batch, on top of ordinary feature self-attention, and embeds continuous features so they join the attention too. Paired with contrastive pre-training, it beats prior deep tabular models and on average even boosted trees.

  • SAINT
  • Self-Attention and Intersample Attention Transformer
  • tabular data
  • tabular transformer
  • intersample attention
  • row attention
  • contrastive pre-training
  • somepago/saint
  • pytorch-widedeep
  • TabTransformer

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

Cite the paper

@misc{somepalli2021saintimprovedneuralnetworks,
      title={SAINT: Improved Neural Networks for Tabular Data via Row Attention and Contrastive Pre-Training}, 
      author={Gowthami Somepalli and Micah Goldblum and Avi Schwarzschild and C. Bayan Bruss and Tom Goldstein},
      year={2021},
      eprint={2106.01342},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2106.01342}, 
}