Bidirectional Gated Mamba for Sequential Recommendation

Ziwei Liu, Qidong Liu, Yejing Wang, Wanyu Wang, Pengyue Jia, Maolin Wang, Zitao Liu, Yi Chang, Xiangyu Zhao · OpenReview

Abstract

In various domains, Sequential Recommender Systems (SRS) have become essential due to their superior capability to discern intricate user preferences. Typically, SRS utilize transformer-based architectures to forecast the subsequent item within a sequence. Nevertheless, the quadratic computational complexity inherent in these models often leads to inefficiencies, hindering the achievement of real-time recommendations. Mamba, a recent advancement, has exhibited exceptional performance in time series prediction, significantly enhancing both efficiency and accuracy. However, integrating Mamba directly into SRS poses several challenges. Its inherently unidirectional nature may constrain the model's capacity to capture the full context of user-item interactions, while its instability in state estimation can compromise its ability to detect short-term patterns within interaction sequences. To overcome these issues, we introduce a new framework named Selective Gated Mamba (SIGMA) for Sequential Recommendation. This framework leverages a Partially Flipped Mamba (PF-Mamba) to construct a bidirectional architecture specifically tailored to improve contextual modeling. Additionally, an input-sensitive Dense Selective Gate (DS Gate) is employed to optimize directional weights and enhance the processing of sequential information in PF-Mamba. For short sequence modeling, we have also developed a Feature Extract GRU (FE-GRU) to efficiently capture short-term dependencies. Empirical results indicate that SIGMA outperforms current models on five real-world datasets.

Introduction

Sequential Recommender Systems (SRS) aim to predict a user's next interaction based on their history. Currently, Transformers (like SASRec or BERT4Rec) are the gold standard because they excel at capturing long-range dependencies. However, they suffer from quadratic computational complexity—meaning as the user's history grows, the processing time and memory requirements explode.

Recently, Mamba (a type of State Space Model or SSM) emerged as a linear-time alternative. While fast, Mamba has two major flaws when applied to recommendations:

  1. Unidirectional Constraints: Standard Mamba only looks "backward." In recommendation, understanding the full context of a sequence (bidirectional) is often necessary to identify shifts in user intent.
  2. Short-Sequence Instability: Mamba can be unstable when estimating states for very short sequences, a common issue known as the "long-tail user problem," where users with few interactions receive poor recommendations.

Methods: The SIGMA Framework

The authors propose SIGMA (SelectIve Gated MAmba), which consists of three primary innovations to adapt the Mamba architecture for recommendation tasks.

The SIGMA framework overview, detailing the G-Mamba Block and the Dense Selective (DS) Gate.

Partially Flipped Mamba (PF-Mamba)

Instead of just processing a sequence forward, SIGMA uses a bidirectional approach. Crucially, it doesn't just flip the whole sequence (which can destroy short-term patterns). It "partially flips" the sequence, reversing the earlier items while keeping the most recent $r$ items in their original order to preserve immediate intent.

Dense Selective Gate (DS Gate)

This input-dependent gating mechanism learns how to weight the information coming from the forward and flipped paths. It acts as a filter to ensure only the most relevant contextual information is passed forward, optimizing the directional weights within the PF-Mamba.

Feature Extract GRU (FE-GRU)

To address Mamba's struggle with short sequences, a parallel path is added. It uses a 1D-Convolutional layer to aggregate local features followed by a Gated Recurrent Unit (GRU), which is historically robust at capturing short-term dependencies. These components are combined in a G-Mamba Block, which replaces the standard attention layers found in traditional models.

Key Results

SIGMA was evaluated on five widely used real-world recommendation benchmarks: Yelp, Amazon (Beauty, Sports, and Games), and MovieLens-1M (ML-1M). The model outperformed all baselines (including SASRec, BERT4Rec, and vanilla Mamba4Rec) across all datasets. On the Yelp dataset, it showed an 8.82% improvement in Hit Rate (HR@10) over the best baseline.

Performance comparison (Hit@10) across different user groups based on interaction sequence length.
  • Robustness to Short Sequences: In grouped analysis, SIGMA significantly beat vanilla Mamba models for users with fewer than 5 interactions, proving the FE-GRU successfully mitigated the long-tail problem.
  • Efficiency without Sacrifice: SIGMA achieves the accuracy of a Transformer with the speed of an RNN. For example, on the Beauty dataset, SIGMA’s inference time was 68ms per batch compared to 123ms for SASRec, while using significantly less GPU memory (2.89GB vs 7.58GB).

Conclusion

SIGMA demonstrates that State Space Models like Mamba can be effectively adapted for sequential recommendation by addressing their inherent limitations in context modeling and short-sequence stability. By combining bidirectional processing with robust short-term feature extraction, SIGMA offers a high-performance, linear-time alternative to Transformer-based recommenders suitable for production environments.

Summary updated

BibTeX
@inproceedings{liu2025bidirectional,
  author = {Ziwei Liu and Qidong Liu and Yejing Wang and Wanyu Wang and Pengyue Jia and Maolin Wang and Zitao Liu and Yi Chang and Xiangyu Zhao},
  title = {{Bidirectional Gated Mamba for Sequential Recommendation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  url = {https://openreview.net/forum?id=LpjnJpwnfh},
}
Figure