Recurrent Neural Networks with Top-k Gains for Session-based Recommendations

Balázs Hidasi, Alexandros Karatzoglou

Introduction

In modern e-commerce and streaming platforms, users often interact without logging in, or as first-time visitors. This "session-based" recommendation setting is challenging because the system lacks long-term user history and must rely entirely on the current sequence of actions. While Recurrent Neural Networks (RNNs), such as the GRU4Rec model, have shown promise in this area, they often struggle to accurately rank items at the very top of the list (the "Top-k") when trained with standard pairwise ranking losses.

The Gradient Dilution Problem

The authors identify a critical flaw in standard ranking losses like Bayesian Personalized Ranking (BPR). As the number of negative samples increases to improve model robustness, the gradients of these losses tend to "vanish." This happens because standard losses treat all negative samples equally. In a large pool of negatives, a few "hard" examples (items the user might actually like) are overwhelmed by many "easy" examples (irrelevant items). This dilution prevents the model from focusing its learning on the most informative samples, causing performance to plateau.

Comparison of gradient magnitudes across different ranks for BPR and BPR-max losses.

Proposed Methods

To address these limitations, the paper introduces three primary enhancements to the GRU4Rec architecture:

  1. Ranking-max Loss Functions (BPR-max and TOP1-max): These new functions utilize a softmax-like weighting mechanism. By dynamically weighting the negative samples based on their current scores, the network is forced to focus on the "hardest" negatives. This prevents gradient vanishing and ensures continuous learning even with thousands of negative samples.
  2. Improved Sampling Strategies: The authors move beyond simple mini-batch sampling by introducing additional negative samples (up to thousands). They employ a sampling cache to keep the GPU fully utilized, ensuring that the increased sample size does not significantly impact training throughput.
  3. Unified Item Representations: By sharing the weight matrix between the input embedding layer and the output scoring layer ("weight tying"), the model's memory footprint is reduced by 4x, which also aids in learning better representations for rare items.

Efficiency and Scalability

A key concern with increasing negative samples is the computational overhead. However, the authors demonstrate that with their optimized sampling cache, the training time remains relatively stable until the number of additional samples becomes extremely large. This allows for more thorough training without a prohibitive increase in resource consumption.

Training time vs. number of additional negative samples for various loss functions.

Key Results

The proposed methods were evaluated on four diverse datasets, including the public RSC15 (YOOCHOOSE) and proprietary video streaming and classifieds data. Key findings include:

  • Significant Accuracy Gains: On the CLASS dataset, BPR-max improved Recall@20 by 34.6% and Mean Reciprocal Rank (MRR@20) by 26.6% over the original GRU4Rec.
  • Outperforming Baselines: The improvements over traditional item-kNN methods reached as high as 53% in certain metrics.
  • Real-world Impact: A 2.5-month online A/B test on a live video portal showed a ~5% increase in watch time and video plays compared to a fine-tuned complex recommendation logic.

Conclusion

By focusing on the most informative negative samples through "max" loss functions and optimizing sampling efficiency, this research significantly advances the state-of-the-art in session-based recommendations. These techniques are not limited to RNNs and could potentially enhance other architectures like Matrix Factorization or Autoencoders in ranking-heavy tasks.

Summary updated

BibTeX
@inproceedings{hidasi2018recurrent,
  author = {Balázs Hidasi and Alexandros Karatzoglou},
  title = {{Recurrent Neural Networks with Top-k Gains for Session-based Recommendations}},
  booktitle = {ACM International Conference on Information and Knowledge Management},
  year = {2018},
  url = {https://openreview.net/forum?id=EpXut3lxjCy},
}
Figure