Multi-Sample based Contrastive Loss for Top-k Recommendation

Hao Tang, Guoshuai Zhao, Yuxia Wu, Xueming QianarXiv 2021

TL;DR

This paper introduces Multi-Sample based Contrastive Loss (MSCL), a novel loss function for top-k recommendation that addresses the inherent imbalance between positive and negative samples in contrastive learning. By weighting sample importance and employing a new multi-positive data augmentation strategy, MSCL achieves state-of-the-art accuracy while converging up to 20x faster than traditional ranking losses.

What Problem Does This Paper Address?

Top-k recommendation systems typically learn user preferences by contrasting "positive" items (those a user interacted with) against "negative" items (those they didn't). Recently, Contrastive Loss (CL) has gained popularity for this task. However, the authors identify two major flaws in standard CL for recommendations:

  1. Sample Imbalance: Standard CL treats one positive sample and hundreds or thousands of negative samples (the rest of the training batch) as equally important. This creates a massive imbalance that hinders effective learning.
  2. Underutilized Sparsity: Recommendation data is notoriously sparse. Standard methods don't fully exploit the few precious positive interactions available, especially in "long-tail" scenarios where users have very few interactions.

Methods

The authors propose MSCL, which consists of two key innovations integrated into a single loss function:

  • Importance-aware CL (ICL): It introduces a hyperparameter $\alpha$ to explicitly weight the importance of positive vs. negative samples. This allows the model to prioritize learning from scarce positive signals, particularly in sparse datasets.
  • Multiple Positive Samples based CL (MCL): Instead of using just one positive item per user update, this method samples $M$ positive items simultaneously. It creates $M$ parallel learning paths, effectively acting as a powerful data augmentation technique that provides stronger constraints for the user's representation.
Conceptual comparison of standard Contrastive Loss vs. the proposed Multi-Sample based Contrastive Loss.

The authors implement this loss within a Graph Convolutional Network (GCN) framework, specifically using a simplified version of LightGCN (termed sLightGCN_MSCL) to demonstrate its effectiveness.

Overview of the sLightGCN_MSCL architecture, showing how multiple positive samples are fed into the importance-aware loss function.

Datasets

The researchers evaluated their method on three widely used benchmark datasets that vary in size and density:

  • Yelp2018: A dataset of local business reviews (Density: 0.00130).
  • Amazon-Book: Product reviews from Amazon (Density: 0.00062).
  • Alibaba-iFashion: A very large and extremely sparse fashion outfit recommendation dataset (Density: 0.00007).

Key Insights and Ideas

  • Weighting is Dataset-Dependent: The optimal weight $\alpha$ varies with sparsity. For extremely sparse datasets like Alibaba-iFashion, giving more weight to positive samples is crucial. For denser datasets, balancing the thousands of negative samples is the primary concern.
  • Parallel Augmentation Wins: Unlike traditional graph augmentation (like edge dropout) which is often applied serially, MSCL's multi-positive approach provides parallel constraints in the loss function, leading to more robust feature representations.
  • "Loss is a First-Class Citizen": The paper shows that improving the loss function can be more impactful than building a more complex model. Remarkably, a simple Matrix Factorization (MF) model using MSCL can outperform state-of-the-art GCN models that use standard BPR loss.
  • Ranking vs. Recall: MSCL shows even greater improvements in ranking-sensitive metrics like NDCG compared to Recall, suggesting it is particularly well-suited for the "top-k" nature of real-world recommendations.

Key Results

  • State-of-the-Art Performance: sLightGCN_MSCL outperformed the previous best method (SGL) across all datasets. On the Amazon-Book dataset, it achieved a 21.34% improvement in Recall and a 22.96% improvement in NDCG.
  • Blazing Fast Convergence: MSCL significantly speeds up training. On Yelp2018, it reached optimal performance in just 46 epochs, compared to over 900 epochs required by the standard BPR loss.
  • Model Agnostic: When applied to basic Matrix Factorization (MF), MSCL boosted Recall by nearly 50% on Yelp2018, making the simplest model highly competitive with complex graph-based baselines.
Impact of the number of positive samples (M) on performance across different datasets.

Limitations and Future Work

  • Hyperparameter Sensitivity: The method introduces two new hyperparameters ($\alpha$ and $M$) that require tuning for each dataset to achieve peak performance.
  • Computational Overhead: While total training time is reduced due to faster convergence, each training epoch is slightly more computationally expensive because it processes $M$ positive samples instead of one.
  • Future Directions: The authors suggest that the principles of MSCL—balancing importance and multi-sample augmentation—could be extended to other contrastive learning tasks beyond recommendation systems, such as in computer vision or natural language processing.

Summary updated

BibTeX
@misc{tang2021multi,
  author = {Hao Tang and Guoshuai Zhao and Yuxia Wu and Xueming Qian},
  title = {{Multi-Sample based Contrastive Loss for Top-k Recommendation}},
  year = {2021},
  eprint = {2109.00217},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2109.00217},
}
Figure