Abstract
Sequential recommender systems are essential for modeling dynamic user interests. However, as users accumulate thousands of interactions over time—forming "lifelong" sequences—traditional models like Transformers and RNNs struggle with computational complexity or information retention. This paper introduces RecMamba, a framework utilizing Selective State Space Models (Mamba) to efficiently process lifelong user histories. Experiments on real-world datasets demonstrate that RecMamba matches state-of-the-art performance while reducing training time by 70% and memory costs by 80%, effectively overcoming the "memory wall" of quadratic-complexity models.
Introduction
Modern online platforms generate vast amounts of user behavioral data. While standard sequential recommendation research focuses on short windows (e.g., the last 50 items), real-world sequences often span thousands of interactions. Capturing these long-range dependencies is critical for understanding evolving user preferences.
Existing architectures face significant trade-offs. Recurrent Neural Networks (RNNs) are efficient but suffer from vanishing gradients and forgetting over long distances. Transformers, such as SASRec, capture dependencies effectively but possess quadratic computational complexity ($O(L^2)$), causing them to hit "Out of Memory" (OOM) errors as sequence lengths grow beyond 2,000 items. RecMamba addresses these challenges by leveraging the linear scaling and selective memory of State Space Models.
The RecMamba Framework
RecMamba replaces the self-attention layers of traditional models with Mamba blocks. The core of this architecture is a selective mechanism that allows the model to dynamically decide which information to propagate or discard based on the current input. Unlike previous time-invariant State Space Models, this data-dependent selection is vital for recommendation tasks, where the model must distinguish between a user's core interests and transient, noisy interactions.
By utilizing a hardware-optimized parallel algorithm, RecMamba achieves linear scaling ($O(L)$) relative to sequence length, allowing it to process sequences of 10,000 items or more on standard hardware where Transformers fail.
Performance Gains from Lifelong Sequences
A key finding of this research is that "longer is indeed better." By testing sequence lengths ranging from 0.25k to 10k on the KuaiRand and LFM-1b datasets, the authors observed a consistent improvement in recommendation accuracy (NDCG@10).
This trend proves that lifelong histories contain valuable signals that are lost when models are restricted to short-term windows. RecMamba's ability to ingest these long sequences without performance degradation makes it a superior choice for large-scale production environments.
Efficiency and the Memory Wall
Beyond accuracy, RecMamba offers transformative efficiency gains. In head-to-head comparisons with SASRec at a sequence length of 2,000, RecMamba reduced training duration by approximately 73% and inference time by 61%.
As shown in the efficiency analysis, SASRec's computational requirements grow exponentially, leading to OOM errors at lengths of 5k and above. In contrast, RecMamba (kssm) maintains stable, linear growth in both time and memory consumption. This allows RecMamba to operate in regimes that were previously inaccessible to Transformer-based recommenders.
Conclusion
RecMamba represents a significant step forward for lifelong sequential recommendation. By combining the selective memory of SSMs with linear computational complexity, it breaks the memory wall that has long limited the depth of user history modeling. Future work will explore extending this framework to multi-behavior modeling and incorporating rich side information like item metadata and visual features.
Summary updated