You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 7.2 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. # Contents
  2. - [NAML Description](#NAML-description)
  3. - [Dataset](#dataset)
  4. - [Environment Requirements](#environment-requirements)
  5. - [Script Description](#script-description)
  6. - [Script and Sample Code](#script-and-sample-code)
  7. - [Training Process](#training-process)
  8. - [Model Export](#model-export)
  9. - [Model Description](#model-description)
  10. - [Performance](#performance)
  11. - [Evaluation Performance](#evaluation-performance)
  12. - [Inference Performance](#evaluation-performance)
  13. - [Description of Random Situation](#description-of-random-situation)
  14. - [ModelZoo Homepage](#modelzoo-homepage)
  15. # [NAML Description](#contents)
  16. 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.
  17. [Paper](https://arxiv.org/abs/1907.05576) Chuhan Wu, Fangzhao Wu, Mingxiao An, Jianqiang Huang, Yongfeng Huang and Xing Xie: Neural News Recommendation with Attentive Multi-View Learning, IJCAI 2019
  18. # [Dataset](#contents)
  19. Dataset used: [MIND](https://msnews.github.io/)
  20. MIND contains about 160k English news articles and more than 15 million impression logs generated by 1 million users.
  21. You can download the dataset and put the directory in structure as follows:
  22. ```path
  23. └─MINDlarge
  24. ├─MINDlarge_train
  25. ├─MINDlarge_dev
  26. └─MINDlarge_utils
  27. ```
  28. # [Environment Requirements](#contents)
  29. - Hardware(Ascend/GPU)
  30. - Prepare hardware environment with Ascend, GPU processor.
  31. - Framework
  32. - [MindSpore](https://www.mindspore.cn/install/en)
  33. - For more information, please check the resources below:
  34. - [MindSpore Tutorials](https://www.mindspore.cn/tutorial/training/en/master/index.html)
  35. - [MindSpore Python API](https://www.mindspore.cn/doc/api_python/en/master/index.html)
  36. # [Script description](#contents)
  37. ## [Script and sample code](#contents)
  38. ```path
  39. ├── naml
  40. ├── README.md # descriptions about NAML
  41. ├── scripts
  42. │ ├──run_train.sh # shell script for training
  43. │ ├──run_eval.sh # shell script for evaluation
  44. │ ├──run_infer_310.sh # shell script for 310 inference
  45. ├── src
  46. │ ├──option.py # parse args
  47. │ ├──callback.py # callback file
  48. │ ├──dataset.py # creating dataset
  49. │ ├──naml.py # NAML architecture
  50. │ ├──config.py # config file
  51. │ ├──utils.py # utils to load ckpt_file for fine tune or incremental learn
  52. ├──ascend310_infer #application for 310 inference
  53. ├── train.py # training script
  54. ├── eval.py # evaluation script
  55. ├── export.py # export mindir script
  56. └──postprogress.py # post process for 310 inference
  57. ```
  58. ## [Training process](#contents)
  59. ### Usage
  60. You can start training using python or shell scripts. The usage of shell scripts as follows:
  61. ```shell
  62. # train standalone
  63. bash run_train.sh [PLATFORM] [DEVICE_ID] [DATASET] [DATASET_PATH]
  64. # train distribute
  65. bash run_distribute_train.sh [PLATFORM] [DEVICE_NUM] [DATASET] [DATASET_PATH] [RANK_TABLE_FILE]
  66. # evaluation
  67. bash run_eval.sh [PLATFORM] [DEVICE_ID] [DATASET] [DATASET_PATH] [CHECKPOINT_PATH]
  68. ```
  69. - `PLATFORM` should be Ascend.
  70. - `DEVICE_ID` is the device id you want to run the network.
  71. - `DATASET` MIND dataset, support large, small and demo.
  72. - `DATASET_PATH` is the dataset path, the structure as [Dataset](#dataset).
  73. - `CHECKPOINT_PATH` is a pre-trained checkpoint path.
  74. - `RANK_TABLE_FILE` is HCCL configuration file when running on Ascend.
  75. ## [Model Export](#contents)
  76. ```shell
  77. python export.py --platform [PLATFORM] --checkpoint_path [CHECKPOINT_PATH] --file_format [EXPORT_FORMAT] --batch_size [BATCH_SIZE]
  78. ```
  79. - `EXPORT_FORMAT` should be in ["AIR", "MINDIR"]
  80. # [Model Description](#contents)
  81. ## [Performance](#contents)
  82. ### Evaluation Performance
  83. | Parameters | Ascend |
  84. | -------------------------- | ------------------------------------------------------------ |
  85. | Model Version | NAML |
  86. | Resource |Ascend 910; CPU 2.60GHz, 56cores; Memory 314G; OS Euler2.8 |
  87. | uploaded Date | 02/23/2021 (month/day/year) |
  88. | MindSpore Version | 1.2.0 |
  89. | Dataset | MINDlarge |
  90. | Training Parameters | epoch=1, steps=52869, batch_size=64, lr=0.001 |
  91. | Optimizer | Adam |
  92. | Loss Function | Softmax Cross Entropy |
  93. | outputs | probability |
  94. | Speed | 1pc: 62 ms/step |
  95. | Total time | 1pc: 54 mins |
  96. ### Inference Performance
  97. | Parameters | Ascend |
  98. | ------------------- | --------------------------- |
  99. | Model Version | NAML |
  100. | Resource | Ascend 910; OS Euler2.8 |
  101. | Uploaded Date | 02/23/2021 (month/day/year) |
  102. | MindSpore Version | 1.2.0 |
  103. | Dataset | MINDlarge |
  104. | batch_size | 64 |
  105. | outputs | probability |
  106. | Accuracy | AUC: 0.66 |
  107. ### Inference on Ascend310 Performance
  108. | Parameters | Ascend |
  109. | ------------------- | --------------------------- |
  110. | Model Version | NAML |
  111. | Resource | Ascend 310 |
  112. | Uploaded Date | 03/13/2021 (month/day/year) |
  113. | MindSpore Version | 1.2.0 |
  114. | Dataset | MINDlarge |
  115. | batch_size | 64 |
  116. | outputs | probability |
  117. | Accuracy | AUC: 0.667 |
  118. # [Description of Random Situation](#contents)
  119. <!-- In dataset.py, we set the seed inside “create_dataset" function. We also use random seed in train.py. -->
  120. 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.
  121. # [ModelZoo Homepage](#contents)
  122. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).