Papers
Topics
Authors
Recent
Search
2000 character limit reached

SASRec: Transformer-Based Sequential Rec

Updated 5 June 2026
  • SASRec is a Transformer-based sequential recommendation model that leverages self-attention to capture both short- and long-range item dependencies.
  • It employs multi-head causal self-attention, residual connections, and layer normalization for efficient next-item prediction.
  • Extensions like eSASRec and DenseRec enhance accuracy, address cold-start issues, and ensure scalability for industrial-scale datasets.

Sequential IDRec, most commonly instantiated as the SASRec (“Self-Attentive Sequential Recommendation”) architecture, is a class of Transformer-based models designed for next-item prediction in user interaction sequences. By leveraging self-attention over ID-encoded item sequences, SASRec captures both short- and long-range sequential dependencies, outperforming Markov Chains, RNNs, and traditional collaborative filtering when equipped with sufficient capacity and appropriate loss functions. Since its introduction, SASRec has become a baseline for sequential recommendation, demonstrating exceptional scalability, efficiency on dense datasets, and extensibility to industrial-scale catalogs and hybrid recommendation scenarios (Kang et al., 2018, Petrov et al., 2024, Tikhonovich et al., 8 Aug 2025).

1. Architectural Foundations and Model Formulation

SASRec models user behavior as a discrete-time sequence of item IDs. Each user’s interaction history S=(i1,i2,,in)S = (i_1, i_2, \ldots, i_n) is encoded as a fixed-length input sequence (padding or truncation as needed). Each item iti_t is mapped to a learned embedding xtRdx_t \in \mathbb{R}^d, and positional encodings ptp_t are added to inject sequential information. Thus:

ht0=xt+pth^0_t = x_t + p_t

for t=1,,nt = 1,\ldots,n.

The model stacks LL identical Transformer encoder blocks, each comprising:

  • Multi-Head Causal Self-Attention: For each position, attention is restricted to positions 1,,t1,\ldots,t to preserve causality.
  • Position-Wise Feed-Forward Networks: Usually a two-layer MLP with nonlinearity (ReLU, GELU, or SwiGLU).
  • Residual Connections and Layer Normalization: Both applied after each sublayer; Post-LN or Pre-LN arrangements are common.

At position tt, the item prediction for the next step is obtained by scoring all candidate items via the dot product between the final hidden state htLh^L_t and each item's embedding. The result can be interpreted as a logit score, which is passed through a softmax or sigmoid, depending on the loss formulation (Kang et al., 2018, Liu, 8 Jul 2025, D'Ercoli et al., 17 Jun 2025, Betello et al., 2024).

2. Loss Functions and Training Objectives

SASRec’s effectiveness is strongly dependent on the choice of loss:

  • Original Binary Cross-Entropy (BCE): For each user and position, the loss is computed between the positive next item and one or more sampled negatives:

iti_t0

  • Sampled Softmax: Replaces BCE by optimizing a sample-based approximation of softmax over a subset of candidates (typically iti_t1 negatives per positive). The distribution is:

iti_t2

Loss per position is the negative log-likelihood of the true label (Tikhonovich et al., 8 Aug 2025, Lichtenberg et al., 25 Aug 2025).

  • Full Softmax Cross-Entropy: Some later variants advocate a per-position, full-vocabulary softmax:

iti_t3

This achieves greater accuracy as each update considers every possible target, but is tractable only for moderate catalog sizes (Li et al., 2023).

The choice of loss has major impact. Full softmax yields consistently higher accuracy, while sampled softmax or BCE with appropriate negative sampling balances efficiency with effectiveness. Optional frequency-domain biases (as in BSARec) can further enhance modeling of short-term dynamics (D'Ercoli et al., 17 Jun 2025).

3. Recent Enhancements: Modular and Hybrid Extensions

Major improvements to vanilla SASRec have focused on both architectural blocks and training strategy, without altering the recommendation protocol.

  • eSASRec: Incorporates LiGR-style Transformer layers (Pre-LN, sublayer gating, SwiGLU activations) and sampled softmax loss. Gating replaces plain residuals:

iti_t4

where iti_t5 is either multi-head attention or FFN. eSASRec, combined with uniform and in-batch negative sampling, achieves substantial gains in both accuracy (up to 30% relative improvement vs. SASRec-vanilla) and coverage on large academic and industrial datasets, while retaining high computational efficiency (Tikhonovich et al., 8 Aug 2025).

  • DenseRec: Tackles the item cold-start problem by augmenting SASRec's ID embeddings with dense (i.e., content-based) representations. It learns a projection from pretrained content vectors to the ID embedding space, applies stochastic path selection during training (ID vs. dense), and deterministically selects path at inference (ID for known items, dense for new). DenseRec demonstrates up to 34% improvement in Hit Rate@100 over ID-only SASRec under cold-start prevalence, with minimal architectural cost (Lichtenberg et al., 25 Aug 2025).
  • Efficient Inference (RecJPQ + PQTopK): Decomposes item IDs into shared sub-IDs, dramatically reducing memory and computation demands for million-scale catalogs. PQTopK algorithm enables per-item parallelism, realizing up to 4.5x end-to-end speedups without any loss in recommendation quality (Petrov et al., 2024).
  • SASRecLLM: Fuses SASRec as a collaborative encoder with a fine-tuned LLM via a trainable mapping. Used for LLM-based recommendation settings, the integration preserves structured collaborative signals and provides effective recommendation even in cold-start scenarios (Liu, 8 Jul 2025).

4. Empirical Evaluation and Comparative Analysis

SASRec and its derivatives have been extensively benchmarked:

  • Academic Datasets: On MovieLens-1M, ML-20M, Amazon Beauty, Steam, and Foursquare-NYC, SASRec routinely surpasses MC, RNN, and CNN baselines in Hit@10 and NDCG@10 as long as the model has sufficient embedding dimension (iti_t6256) and input sequence length (iti_t7100). On smaller parameter budgets (iti_t864), GRU4Rec can outperform SASRec, but the latter overtakes for large models (Kang et al., 2018, Betello et al., 2024).
  • Production-Scale Settings: eSASRec, HSTU, and FuXi all reside on the empirical Pareto frontier in terms of accuracy vs. coverage tradeoff, with eSASRec requiring no side information or timestamps. For example, on ML-20M, eSASRec delivers NDCG@10=0.1563 (31% over SASRec-vanilla) and Coverage@10=0.0889. On BeerAdvocate, eSASRec expands coverage by 270% vs. SASRec (Tikhonovich et al., 8 Aug 2025).
  • Loss Ablation: Full-sequence softmax cross-entropy universally outperforms BCE and dramatically improves per-position accuracy. Enhancements to the negative sampling protocol and training objectives yield further incremental gains (Li et al., 2023).
  • Cold-Start: DenseRec specifically yields improvement in scenarios with high rates of new items, both by direct prediction of unseen items and by improved representation of sequences containing such items (Lichtenberg et al., 25 Aug 2025).

5. Implementation Practices and Scalability

Key reproducibility and scaling principles include:

6. Broader Impact, Applications, and Future Directions

SASRec and its lineage have established Transformer-based sequential recommendation as the state of the art. The model class provides:

  • Robustness across data regimes, automatically adjusting context window via attention.
  • Superior scalability to long sequences and large item vocabularies given algorithmic enhancements.
  • Readiness for industrial deployment, as evidenced by adoption in hybrid frameworks and compatibility with compressed inference techniques (Tikhonovich et al., 8 Aug 2025, Petrov et al., 2024, Liu, 8 Jul 2025).
  • Extensibility to hybrid and cold-start settings with minimal augmentation (Lichtenberg et al., 25 Aug 2025).

A plausible implication is that future research may focus on further modular extension (e.g., side-information fusion, efficient knowledge distillation), systematic ablation of inductive biases, and tighter integration with LLM-based recommenders, especially as catalog and user scales continue to grow.


References:

(Kang et al., 2018, Li et al., 2023, Betello et al., 2024, Petrov et al., 2024, D'Ercoli et al., 17 Jun 2025, Liu, 8 Jul 2025, Tikhonovich et al., 8 Aug 2025, Lichtenberg et al., 25 Aug 2025)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Sequential IDRec (SASRec).