anzhang314 / BC-Loss

Official code of "Incorporating Bias-aware Margins into Contrastive Loss for Collaborative Filtering" (2022 NeurIPS)
MIT License
22 stars 2 forks source link

BC-Loss

Overview

Official code of "Incorporating Bias-aware Margins into Contrastive Loss for Collaborative Filtering" (2022 NeurIPS)

Run the Code

MF backbone

For models with MF as backbone, use models with random negative sampling strategy. For example:

python main.py --modeltype LGN --dataset tencent.new --n_layers 0 --neg_sample 1
python main.py --modeltype INFONCE --dataset tencent.new  --n_layers 0 --neg_sample 128
python main.py --modeltype BC_LOSS --dataset tencent.new --n_layers 0 --neg_sample 128

LightGCN backbone

For models with LightGCN as backbone, use models with in-batch negative sampling strategy. For example:

python main.py --modeltype LGN --dataset tencent.new --n_layers 2 --neg_sample 1
python main.py --modeltype INFONCE_batch --dataset tencent.new  --n_layers 2 --neg_sample -1
python main.py --modeltype BC_LOSS_batch --dataset tencent.new --n_layers 2 --neg_sample -1

Details of hyperparameter settings for various baselines can be found in the paper.

Requirements

Reference

If you want to use our codes and datasets in your research, please cite:

@inproceedings{bc_loss,   
      author    = {An Zhang and
                   Wenchang Ma and 
                   Xiang Wang and 
                   Tat-seng Chua}, 
      title     = {Incorporating Bias-aware Margins into Contrastive Loss for Collaborative Filtering},  
      booktitle = {{NeurIPS}},  
      year      = {2022},   
}