All models

SASRec

Self-attention sequential recommender that weighs a user's past actions to predict the next item.

Tabular and recommender · 83 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 (25 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
211K
Operations
83
Framework
PyTorch
Recurrent
No
Published
ICDM 2018
Cited by
76 (as of 19 October 2026)
Authors
Wang-Cheng Kang, Julian McAuley
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
m2638
Graph hash
a1d12840415ff5b059b6c084ca2bff70f024f74b90a00778fb019a686ed159a3
Skeleton hash
0d1c1c63322614954f2ec0832ace59fcbe953cd7d6cb774a8cde46823a96d4ba
Architecture hash
3ab55fc0fd61a37071624599fad5fbd5a666db7f8d1333d9f4961dc451d5a369
Diagram SHA-256
a31d7523c8517b5fc1e1c4cce1498265ae29de4f4b92e9fe49d62f253af716e2
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

SASRec is a sequential recommender that predicts a user's next action from their history with self-attention, which adaptively assigns weights to previous items at each time step. The paper sets it between two older approaches: Markov chains, which do best on very sparse data where a parsimonious model matters, and recurrent networks, which do better on denser data where more complexity is affordable. SASRec aims to capture long-term semantics like an RNN while, through attention, basing each prediction on relatively few actions like a Markov chain.

The model embeds the most recent items of a user's sequence and adds a learnable position embedding. It then applies stacked self-attention blocks, each a self-attention layer followed by a feed-forward network. Attention is made causal by forbidding links from each query position to later keys, so the prediction at step t uses only the first t items. A matrix factorization layer scores candidate items by inner product with the block output.

Across Amazon Beauty, Amazon Games, Steam and MovieLens-1M, the paper reports average gains of 6.9% in Hit Rate and 9.6% in NDCG over the strongest baseline. On MovieLens-1M it reports 1.7 seconds per training epoch, over 11 times faster than Caser and 18 times faster than GRU4Rec+. The network on this page is RecBole's PyTorch version, which builds the feed-forward network from fully connected layers where the authors' TensorFlow code used 1x1 convolutions.

Key idea. SASRec uses causal self-attention over a user's action sequence to capture long-range context while basing each prediction on a few relevant past items.

  • sasrec
  • self-attentive sequential recommendation
  • sequential recommendation
  • self-attention
  • next item recommendation
  • recbole sasrec
  • transformer recommender
  • attention-based recommender

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

Cite the paper

@misc{kang2018selfattentivesequentialrecommendation,
      title={Self-Attentive Sequential Recommendation}, 
      author={Wang-Cheng Kang and Julian McAuley},
      year={2018},
      eprint={1808.09781},
      archivePrefix={arXiv},
      primaryClass={cs.IR},
      url={https://arxiv.org/abs/1808.09781}, 
}