Dynamic Memory based Attention Network for Sequential Recommendation

Qiaoyu Tan, Jianwei Zhang, Ninghao Liu, Xiao Huang, Hongxia Yang, Jingren Zhou

Abstract

Sequential recommendation aims to predict a user's next interaction based on their historical behavior. However, as user histories grow to thousands of interactions, existing models struggle with computational costs and information dilution. We present the Dynamic Memory-based Attention Network (DMAN), which effectively balances short-term trends and long-term preferences. By segmenting sequences and employing a capsule-based dynamic memory with an auxiliary reconstruction loss, DMAN achieves state-of-the-art performance on long-sequence benchmarks while maintaining deployment efficiency.

Introduction

Modern e-commerce and social media platforms generate massive user behavior sequences. Traditional sequential models, such as Recurrent Neural Networks (RNNs) or Self-Attention mechanisms (e.g., SASRec), face a "long-sequence dilemma." First, scanning entire histories for every recommendation is computationally prohibitive. Second, these architectures often fail to capture dependencies over long distances, leading to "forgetting" or noise overwhelming the signal. Finally, users typically exhibit a split between fleeting short-term interests and stable long-term preferences, which many models fail to decouple effectively.

Methodology

DMAN processes long sequences in segments to maintain efficiency and capture multi-scale interests. The architecture consists of four primary modules:

  1. Recurrent Attention Network: This module handles short-term interests by segmenting the history. It utilizes a self-attention layer that incorporates the hidden state of the previous segment as context, allowing information to flow across chunks without quadratic complexity relative to the total history length.
  2. Long-term Attention Network: This component interacts with an external Dynamic Memory matrix. It uses the current user state as a query to retrieve relevant long-term patterns.
  3. Dynamic Memory Update: Instead of a simple buffer, DMAN uses an abstraction function based on Dynamic Routing (from Capsule Networks) to compress history into fixed memory slots. An auxiliary reconstruction loss ensures these slots remain high-quality summaries of the past.
  4. Neural Gating Network: A sigmoid-based gate adaptively weights short-term and long-term embeddings to produce the final user representation.
The full DMAN architecture, illustrating the flow between Recurrent Attention, Long-term Attention, and the Dynamic Memory Net.

Experimental Results

The model was evaluated on four benchmarks: MovieLens, Taobao, JD.com, and XLong (a Taobao subset with average sequence lengths >1,000).

DMAN consistently outperformed state-of-the-art baselines:

  • Long-Sequence Performance: On the XLong dataset, DMAN improved Recall@200 and Recall@500 by approximately 23% and 26%, respectively, over the best baseline (SDM).
  • General Accuracy: On the standard Taobao dataset, it achieved a 15.05% improvement in Hit Rate (HR@50).
  • Ablation Studies: Removing either the dynamic memory or the recurrent connections led to significant performance degradation, confirming that both components are vital for modeling complex user behavior.

Discussion and Key Insights

A core innovation of DMAN is treating long-term memory as an abstraction rather than mere storage. By using capsule-style routing, the model distills thousands of interactions into a few representative "interest prototypes."

The performance of DMAN is sensitive to the number of memory slots ($m$). As shown in the sensitivity analysis, increasing the number of slots generally improves the Hit Rate, with diminishing returns after a certain point.

Impact of the number of memory slots (m) on HR@50, showing performance gains as the memory capacity increases.

Conclusion

DMAN addresses the challenges of long-sequence recommendation by combining efficient segmentation with a sophisticated memory abstraction mechanism. While hyper-parameter tuning for memory slots remains a consideration for industrial deployment, the model's ability to explicitly gate short- and long-term interests provides a robust framework for handling evolving user preferences.

Summary updated

BibTeX
@inproceedings{tan2021dynamic,
  author = {Qiaoyu Tan and Jianwei Zhang and Ninghao Liu and Xiao Huang and Hongxia Yang and Jingren Zhou and Xia Hu},
  title = {{Dynamic Memory based Attention Network for Sequential Recommendation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i5.16564},
}
Figure