Hierarchical Attentive Transaction Embedding With Intra- and Inter-Transaction Dependencies for Next-Item Recommendation

Shoujin Wang, Longbing Cao, Liang Hu, Shlomo Berkovsky, Xiaoshui Huang, Lin Xiao, Wenpeng Lu

Introduction

Transaction-based recommender systems (TBRS) aim to predict a user's next purchase by analyzing their historical shopping behavior. However, traditional approaches often struggle with two primary limitations. First, they frequently overlook "inter-transaction dependencies," focusing solely on items within the current shopping basket while ignoring relevant context from previous trips. Second, many models rely on a "rigid order" assumption—using Markov Chains or Recurrent Neural Networks (RNNs) that prioritize the most recent items. In reality, a user's current choice may be more strongly influenced by a purchase made several transactions ago than by the item they just added to their cart.

Methodology: The HATE Model

To address these challenges, we propose HATE (Hierarchical Attentive Transaction Embedding), a "shallow and wide" neural network architecture. Unlike deep sequential models, HATE utilizes a two-level attention mechanism to capture non-linear dependencies across different temporal scales.

The HATE architecture employs a hierarchical attention mechanism to process item and transaction embeddings.

Hierarchical Attention Mechanism

  1. Level 1: Intra-transaction Attention: This layer assigns weights to items within a single transaction based on their relevance to the target item. This allows the model to distinguish between core purchases and unrelated "noise" items within the same basket.
  2. Level 2: Inter-transaction Attention: This layer evaluates a sequence of historical transactions. By using the current transaction context as a query, the model identifies which past shopping trips are most predictive of the current need, effectively "jumping back" to relevant historical data regardless of its chronological position.

Efficiency and Scalability

To maintain computational efficiency with large item catalogs, HATE employs Noise-Contrastive Estimation (NCE). This technique avoids the overhead of calculating full softmax probabilities over the entire item set during training, significantly speeding up the learning process.

Experimental Evaluation

The model was evaluated using two real-world grocery datasets: Dunnhumby, a public dataset of household shopping records, and ANS, a proprietary dataset from an Australian supermarket. The evaluation used a sliding window approach to create triple-transaction units for context and prediction.

Key Results

HATE consistently outperformed state-of-the-art baselines, including GRU4Rec and SHAN. As shown in the results table below, HATE achieved a significant performance boost in recommendation accuracy.

Performance comparison of HATE against various baseline models across REC@10, REC@50, and MRR metrics.
  • Accuracy Improvement: HATE improved REC@10 and REC@50 by approximately 5% over the strongest baseline, SHAN.
  • Ablation Study: Removing either the inter-transaction context or the attention mechanism resulted in a performance drop of at least 10%, confirming that both hierarchical levels are essential.
  • Robustness to Context Length: The model's performance margin increased as more historical transactions were incorporated, demonstrating its superior ability to filter noise in long-term shopping histories.

Conclusion

The HATE model demonstrates that modeling the natural hierarchical structure of transactions—items within baskets and baskets within histories—is more effective than treating shopping data as a flat sequence. By prioritizing relevance over simple recency through attention, HATE provides a more accurate and efficient framework for next-item recommendation. Future work will explore extending this framework to other domains and refining the distinction between long-term preferences and immediate needs.

Summary updated

BibTeX
@article{wang2021hierarchical,
  author = {Shoujin Wang and Longbing Cao and Liang Hu and Shlomo Berkovsky and Xiaoshui Huang and Lin Xiao and Wenpeng Lu},
  title = {{Hierarchical Attentive Transaction Embedding With Intra- and Inter-Transaction Dependencies for Next-Item Recommendation}},
  journal = {IEEE Intell. Syst.},
  year = {2021},
  doi = {10.1109/mis.2020.2997362},
}
Figure