/NewsRecommendation

Implementation of several news recommendation methods in Pytorch.

Primary LanguagePythonMIT LicenseMIT

News Recommendation

Implementation of several news recommendation methods in Pytorch.

Support multi-GPU training and testing.

WARNING: Multi-GPU training and testing only work on Linux because currently torch.distributed only support Linux.

Requirements

  • python
  • pytorch
  • numpy
  • scikit-learn
  • nltk
  • tqdm

You can create a conda virtual environment named nr with the provided env.yaml.

conda env create -f env.yaml			# Maybe only work on Linux

Usage

  • Clone this repository

    git clone https://github.com/yflyl613/NewsRecommendation.git
    cd NewsRecommendation
  • Prepare data

    A scirpt download_data.sh is provided to download and unzip all the required data. It will create a new folder data/ under NewsRecommendation/.

    # In NewsRecommendation/
    chmod +x download_data.sh
    ./download_data.sh
  • Start training

    A script demo.sh is provied for model training and testing, in which you can modify parameters for the experiment. Please refer to parameters.py for more details.

    # In NewsRecommendation/data/
    cd ../src
    chmod +x demo.sh
    
    # train
    ./demo.sh train
    
    # test
    ./demo.sh test <checkpoint name>
    # E.g. ./demo.sh test epoch-1.pt

Results on MIND-small validation set[1]

  • NAML[2]

    News information AUC MRR nDCG@5 nDCG@10 Configuration
    subcategory
    category
    title
    66.24 32.08 35.36 41.56 batch size 128 (32*4)
    5 epochs
    lr 3e-4
  • NRMS[3]

    News information AUC MRR nDCG@5 nDCG@10 Configuration
    title 66.61 31.86 35.19 41.46 batch size 128 (32*4)
    4 epochs
    lr 3e-4

Please feel free to contact me by opening an issue if you have any problem or find a bug :)

Reference

[1] Fangzhao Wu, Ying Qiao, Jiun-Hung Chen, Chuhan Wu, Tao Qi, Jianxun Lian, Danyang Liu, Xing Xie, Jianfeng Gao, Winnie Wu and Ming Zhou. MIND: A Large-scale Dataset for News Recommendation. ACL 2020.

[2] Chuhan Wu, Fangzhao Wu, Mingxiao An, Jianqiang Huang, Yongfeng Huang, and Xing Xie. Neural News Recommendation with Attentive Multi-View Learning. IJCAI. 2019.

[3] Chuhan Wu, Fangzhao Wu, Suyu Ge, Tao Qi, Yongfeng Huang, and Xing Xie. Neural News Recommendation with Multi-Head Self-Attention. EMNLP-IJCNLP. 2019.