Problem
A team with a streaming catalog has user view histories and wants to predict what each user will watch next. The model family changed quickly after 2018: SASRec, BERT4Rec, then HSTU and FuXi at scale. Teams have to try 20-30 variants and judge them on more than hit accuracy.
Example from the article: the running example is the KION video service; in the KION tutorial data the average history is over 5.5 events and transformers already work well.
Solution in brief
Treat each user history as a token sequence and train a transformer on the shifted sequence: at every position the target is the next item, scored against a sampled negative. Newer models change the loss, add user actions as tokens, drop manual features or split time into channels. The open-source RecTools library implements SASRec and BERT4Rec with configurable options and built-in validation, including beyond-accuracy and popularity-debiased metrics.
Questions this case answers
- How to train a sequential model that predicts the next item from an ordered interaction history when only one action type is logged
- How to compare many sequential recommender variants on accuracy and on diversity or popularity bias with one validation setup
- How to build a next-item recommender from user interaction histories with a transformer?
- How to choose between SASRec, BERT4Rec and newer sequential architectures for my catalog?
Tools and methods
- SASRec — causal self-attention on shifted sequences, one negative per step
- BERT4Rec — bidirectional masked-item training
- HSTU — item and action tokens, no manual features
- Negative sampling — how the wrong item is chosen
- Result diversification — beyond-accuracy metrics
- RecTools — MTS library with configurable models and validation
- PyTorch Lightning — training loop and metric callbacks
Google or a one-time email code. No password.