All models

CL4SRec

A Transformer sequential recommender trained with contrastive learning over augmented user sequences.

Tabular and recommender · 110 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 (23 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
827.8K
Operations
110
Framework
PyTorch
Recurrent
No
Published
International Conference on Data Engineering (arXiv 2020)
Cited by
727 (as of 21 October 2026)
Authors
Xu Xie, Fei Sun, Zhaoyang Liu and others
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
m294
Graph hash
16c77d2ea9d8537fc52c9515a6c7eeaaf01c761eec86592c8643cbe4545f4214
Skeleton hash
1fdca43b45aa164f9ce93a4f8eeb6ab27ea7576cfd7fac6a94ad13d93169cf8a
Architecture hash
a12700be3f30c7179e369cdea81b5032cb1f0fecf3c7ff8e6a3f5b0fe2c208be
Diagram SHA-256
3b28aa48ae383c306b35033b3a30b0a8af2a26cfc6bee0c4a0718550b08d1fe2
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

CL4SRec is a sequential recommender: it predicts the next item for a user from the sequence of items they have interacted with, and adds a contrastive learning signal drawn from those same sequences. The paper argues that models trained on next-item prediction alone usually suffer from data sparsity, which makes it difficult for them to learn high-quality user representations.

The contrastive part is inspired by the SimCLR framework for visual representation learning. Two augmented views of the same user sequence are encoded, and the loss pulls them together while pushing apart views that come from different users. The views come from three augmentations the paper proposes: cropping, masking and reordering the items of a sequence. The contrastive task and the main sequence prediction task are optimized jointly.

The encoder is the SASRec architecture, a unidirectional Transformer encoder over the item sequence. Unlike SimCLR, the paper drops the extra non-linear projection after the encoder, reporting that removing it led to a significant improvement in its experiments. This model is the implementation in SELFRec, a Python framework for self-supervised recommendation. On Beauty, Sports, Yelp and ML-1M, the paper reports average gains over its baselines of 11.02% on HR at 5 and 8.50% on NDCG at 10.

Key idea. CL4SRec trains a sequential recommender with a contrastive loss over augmented views of each user sequence, built by item crop, mask and reorder, alongside next-item prediction.

  • CL4SRec
  • Contrastive Learning for Sequential Recommendation
  • sequential recommendation
  • contrastive learning
  • next item prediction
  • self-supervised recommendation
  • item crop mask reorder
  • user representation
  • sequence augmentation
  • SELFRec

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

Cite the paper

@misc{xie2021contrastivelearningsequentialrecommendation,
      title={Contrastive Learning for Sequential Recommendation}, 
      author={Xu Xie and Fei Sun and Zhaoyang Liu and Shiwen Wu and Jinyang Gao and Bolin Ding and Bin Cui},
      year={2021},
      eprint={2010.14395},
      archivePrefix={arXiv},
      primaryClass={cs.IR},
      url={https://arxiv.org/abs/2010.14395}, 
}