mindspore/model_zoo/official/recommend/naml
yuzhenhua acc8fa5391 fix ctpn crnn compile error 2021-04-21 14:25:57 +08:00
..
ascend310_infer fix ctpn crnn compile error 2021-04-21 14:25:57 +08:00
script fix ctpn crnn compile error 2021-04-21 14:25:57 +08:00
src clean redundant code 2021-04-10 15:53:20 +08:00
README.md update README at model_zoo 2021-04-12 19:56:43 +08:00
eval.py add naml 2021-02-24 09:06:10 +08:00
export.py add naml 2021-02-24 09:06:10 +08:00
postprocess.py clean redundant code 2021-04-10 15:53:20 +08:00
train.py add distribute file for naml 2021-03-02 14:40:15 +08:00

README.md

Contents

NAML Description

NAML is a multi-view news recommendation approach. The core of NAML is a news encoder and a user encoder. The newsencoder is composed of a title encoder, a abstract encoder, a category encoder and a subcategory encoder. In the user encoder, we learn representations of users from their browsed news. Besides, we apply additive attention to learn more informative news and user representations by selecting important words and news.

Paper Chuhan Wu, Fangzhao Wu, Mingxiao An, Jianqiang Huang, Yongfeng Huang and Xing Xie: Neural News Recommendation with Attentive Multi-View Learning, IJCAI 2019

Dataset

Dataset used: MIND

MIND contains about 160k English news articles and more than 15 million impression logs generated by 1 million users.

You can download the dataset and put the directory in structure as follows:

└─MINDlarge
  ├─MINDlarge_train
  ├─MINDlarge_dev
  └─MINDlarge_utils

Environment Requirements

Script description

Script and sample code

├── naml
  ├── README.md                    # descriptions about NAML
  ├── scripts
     ├──run_train.sh              # shell script for training
     ├──run_eval.sh               # shell script for evaluation
     ├──run_infer_310.sh          # shell script for 310 inference
  ├── src
     ├──option.py                 # parse args
     ├──callback.py               # callback file
     ├──dataset.py                # creating dataset
     ├──naml.py                   # NAML architecture
     ├──config.py                 # config file
     ├──utils.py                  # utils to load ckpt_file for fine tune or incremental learn
  ├──ascend310_infer               #application for 310 inference
  ├── train.py                     # training script
  ├── eval.py                      # evaluation script
  ├── export.py                    # export mindir script
  └──postprogress.py               # post process for 310 inference

Training process

Usage

You can start training using python or shell scripts. The usage of shell scripts as follows:

# train standalone
bash run_train.sh [PLATFORM] [DEVICE_ID] [DATASET] [DATASET_PATH]
# train distribute
bash run_distribute_train.sh [PLATFORM] [DEVICE_NUM] [DATASET] [DATASET_PATH] [RANK_TABLE_FILE]
# evaluation
bash run_eval.sh [PLATFORM] [DEVICE_ID] [DATASET] [DATASET_PATH] [CHECKPOINT_PATH]
  • PLATFORM should be Ascend.
  • DEVICE_ID is the device id you want to run the network.
  • DATASET MIND dataset, support large, small and demo.
  • DATASET_PATH is the dataset path, the structure as Dataset.
  • CHECKPOINT_PATH is a pre-trained checkpoint path.
  • RANK_TABLE_FILE is HCCL configuration file when running on Ascend.

Model Export

python export.py --platform [PLATFORM] --checkpoint_path [CHECKPOINT_PATH] --file_format [EXPORT_FORMAT] --batch_size [BATCH_SIZE]
  • EXPORT_FORMAT should be in ["AIR", "MINDIR"]

Model Description

Performance

Evaluation Performance

Parameters Ascend
Model Version NAML
Resource Ascend 910; CPU 2.60GHz, 56cores; Memory 314G; OS Euler2.8
uploaded Date 02/23/2021 (month/day/year)
MindSpore Version 1.2.0
Dataset MINDlarge
Training Parameters epoch=1, steps=52869, batch_size=64, lr=0.001
Optimizer Adam
Loss Function Softmax Cross Entropy
outputs probability
Speed 1pc: 62 ms/step
Total time 1pc: 54 mins

Inference Performance

Parameters Ascend
Model Version NAML
Resource Ascend 910; OS Euler2.8
Uploaded Date 02/23/2021 (month/day/year)
MindSpore Version 1.2.0
Dataset MINDlarge
batch_size 64
outputs probability
Accuracy AUC: 0.66

Inference on Ascend310 Performance

Parameters Ascend
Model Version NAML
Resource Ascend 310
Uploaded Date 03/13/2021 (month/day/year)
MindSpore Version 1.2.0
Dataset MINDlarge
batch_size 64
outputs probability
Accuracy AUC: 0.667

Description of Random Situation

In train.py, we set the seed which is used by numpy.random, mindspore.common.Initializer, mindspore.ops.composite.random_ops and mindspore.nn.probability.distribution.

ModelZoo Homepage

Please check the official homepage.