Learning Self-Modulating Attention in Continuous Time Space with Applications to Sequential Recommendation

Chao Chen, Haoyu Geng, Nianzu Yang, Junchi Yan, Daiyue Xue, Jianping Yu, Xiaokang Yang

Overview

Standard attention mechanisms in recommendation systems often treat user behavior as a discrete sequence, ignoring the actual time elapsed between actions. This paper introduces self-modulating attention, a novel approach that uses continuous-time intensity functions to dynamically amplify or attenuate past behaviors based on when they occurred. This method leads to state-of-the-art accuracy and significantly better model interpretability.

The Problem: Time-Insensitivity and Over-Density

Sequential recommendation aims to predict a user’s next move based on their history. While attention-based models (like SASRec) are excellent at finding "spatial" correlations—such as noticing that buying a camera often leads to buying a lens—they suffer from two major flaws:

  1. Time-Insensitivity: They often treat the sequence as a series of equidistant steps (1, 2, 3) rather than points in continuous time. In reality, a purchase made five minutes ago is usually far more relevant than one made five months ago.
  2. Over-Density: Standard attention tends to spread "interest" across the entire history. However, a user's next action is typically driven by only a small, sparse subset of their past behaviors.

The authors argue that identical sequences of actions should result in different recommendations if the time intervals between those actions differ.

Methodology: Self-Modulating Attention

The core innovation of this paper is the Self-Modulating Layer (SMLayer) and its corresponding training strategy.

  • Temporal Point Processes (TPP): Instead of merely calculating a similarity score between items, the model uses a "conditional intensity function." This acts as a probability rate that an event will happen at time $t$ given the user's history.
  • Self-Modulation: The model "modulates" standard attention weights. If the intensity function for a past behavior is high at the current time, its contribution is amplified; if it's low, it's attenuated. If it drops to zero, the behavior is effectively ignored, creating the "sparsity" needed for better generalization.
  • Endogenous vs. Exogenous Forces: The intensity function accounts for both the internal logic of the sequence (how items relate to one another) and external temporal decay (how interest naturally fades over time).
  • Continuous Time Regularization (CTReg): To ensure the model actually learns these temporal patterns, the authors add a regularization term to the loss function. This term maximizes the log-likelihood of the actual timestamps observed in the data, bridging the gap between traditional recommendation and temporal process modeling.

Evaluation Datasets

The model was evaluated on three large-scale, real-world datasets:

  • Amazon Electronics: A dataset of user reviews, filtered for users with at least 5 records.
  • Koubei: A retail behavior dataset where users were kept if they had at least 5 records, and items were kept if purchased by at least 100 users.
  • Tmall: A massive click-log dataset from Alibaba, filtered for active users (10+ clicks) and popular items (200+ views).

Key Insights and Ideas

  • Sparsity Improves Generalization: The authors provide a theoretical proof showing that limiting a user's future actions to correlate with only a small subset of past behaviors actually reduces generalization error. By "silencing" irrelevant past actions, the model avoids overfitting to noise.
  • Time as a Filter, Not Just a Feature: Most previous attempts at "time-aware" recommendation simply add a time-embedding to the input. This paper treats time as a modulator of the attention mechanism itself, offering a more mathematically rigorous way to handle evolving preferences.
  • Interpretability: Because the model uses intensity functions, you can plot how a user's interest in a specific category waxes and wanes over time. This provides a clear "why" behind the recommendation that standard "black-box" attention cannot.
Attention intensity over time for different item categories

Key Results

The proposed method was tested against heavyweights like SASRec, DIN, and GRU4REC.

  • Superior Performance: The self-modulating version of SASRec consistently outperformed the original and even "SASRec+," which uses functional time embeddings. On the Tmall dataset, it achieved a Hit Rate (HR@10) of 0.51347, significantly higher than the baseline's 0.50433.
Performance comparison across Amazon, Koubei, and Tmall datasets
  • Plug-and-Play: The SMLayer is designed as an orthogonal "plug-in." The authors showed it could improve both DIN and SASRec, demonstrating its versatility across different attention architectures.
  • Ablation Success: Experiments confirmed that both the SMLayer (the architecture) and the CTReg (the loss function) are necessary to achieve peak performance.

Limitations and Future Work

  • Computational Complexity: Calculating intensities for every potential next item is computationally expensive for large catalogs. The authors suggest a workaround by clustering items into groups (e.g., via spectral clustering) to reduce the workload, though this adds a preprocessing step.
  • Dataset Sensitivity: On the Amazon dataset, the temporal regularization (CTReg) showed diminishing returns. The authors attribute this to "nuisance patterns"—specifically, users writing multiple reviews at the exact same timestamp, which confuses the continuous-time model.
  • Future Directions: The authors suggest exploring how this self-modulating mechanism could be applied to other fields involving irregular time-series data, such as healthcare diagnostics or financial forecasting.

Summary updated

BibTeX
@inproceedings{chen2021learning,
  author = {Chao Chen and Haoyu Geng and Nianzu Yang and Junchi Yan and Daiyue Xue and Jianping Yu and Xiaokang Yang},
  title = {{Learning Self-Modulating Attention in Continuous Time Space with Applications to Sequential Recommendation}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
  url = {https://openreview.net/forum?id=bKHrY8OdDKH},
}
Figure