Skip to content

Commit 3e6ddcb

Browse files
committed
Merge branch 'bug_fix_39' of https://github.com/wangzhen38/PaddleRec into bug_fix_39
2 parents 88e8ea7 + 27e0ab9 commit 3e6ddcb

35 files changed

+774
-149
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ output
44
paddlerec.egg-info/
55
*~
66
*.pyc
7-
*.DS_Store
7+
*.DS_Store
8+
kernel_meta/

README_CN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
- 源于飞桨生态的搜索推荐模型 **一站式开箱即用工具**
3232
- 适合初学者,开发者,研究者的推荐系统全流程解决方案
33-
- 包含内容理解、匹配、召回、排序、 多任务、重排序等多个任务的完整推荐搜索算法库
33+
- 包含内容理解、匹配、召回、排序、 多任务、重排序等多个任务的完整推荐搜索算法库[支持模型列表](#支持模型列表)
3434

3535
<h2 align="center">快速使用</h2>
3636

@@ -107,6 +107,8 @@ python -u tools/static_trainer.py -m models/rank/dnn/config.yaml # 静态图训
107107
### 致谢
108108
* [外部开发者贡献列表](contributor.md)
109109

110+
### 支持模型列表
111+
110112
<h2 align="center">支持模型列表</h2>
111113

112114

README_EN.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
- A quick start tool of search & recommendation algorithm based on [PaddlePaddle](https://www.paddlepaddle.org.cn/documentation/docs/en/beginners_guide/index_en.html)
2727
- A complete solution of recommendation system for beginners, developers and researchers.
28-
- Recommendation algorithm library including content-understanding, match, recall, rank, multi-task, re-rank etc.
28+
- Recommendation algorithm library including content-understanding, match, recall, rank, multi-task, re-rank etc.[Support model list](#Support_Model_List)
2929

3030
<h2 align="center">Getting Started</h2>
3131

@@ -73,31 +73,33 @@ python -u tools/static_trainer.py -m models/rank/dnn/config.yaml # Training wit
7373

7474
### Background
7575
* [Recommendation System](doc/rec_background.md)
76-
* [Distributed deep learning](doc/ps_background.md)
76+
* [Distributed deep Learning](doc/ps_background.md)
7777

78-
### Introductory tutorial
79-
* [PaddleRec function introduction](doc/introduction.md)
78+
### Introductory Tutorial
79+
* [PaddleRec Function Introduction](doc/introduction.md)
8080
* [Dygraph Train](doc/dygraph_mode.md)
8181
* [Static Train](doc/static_mode.md)
8282
* [Distributed Train](doc/fleet_mode.md)
8383

8484

85-
### Advanced tutorial
85+
### Advanced Tutorial
86+
* [Submit Specification](doc/contribute.md)
8687
* [Custom Reader](doc/custom_reader.md)
8788
* [Custom Model](doc/model_develop.md)
88-
* [Configuration description of yaml](doc/yaml.md)
89-
* [Training visualization](doc/visualization.md)
89+
* [Configuration Description of Yaml](doc/yaml.md)
90+
* [Training Visualization](doc/visualization.md)
9091
* [Serving](doc/serving.md)
91-
* [Python inference](doc/inference.md)
92+
* [Python Inference](doc/inference.md)
9293
* [Benchmark](doc/benchmark.md)
9394

9495
### FAQ
9596
* [Common Problem FAQ](doc/faq.md)
9697

9798
### Acknowledgements
98-
* [Contributions from external developer](contributor.md)
99+
* [Contributions From External Developer](contributor.md)
99100

100-
<h2 align="center">Support model list</h2>
101+
#### Support_Model_List
102+
<h2 align="center">Support Model List</h2>
101103

102104

103105
| Type | Algorithm | Online Environment | Parameter-Server | Multi-GPU | version | Paper |

doc/source/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
models/recall/mind.md
6363
models/recall/ncf.md
6464
models/recall/word2vec.md
65+
models/recall/ensfm.md
66+
models/recall/tisas.md
6567
models/rank/bst.md
6668
models/rank/dcn.md
6769
models/rank/deepfefm.md
@@ -79,6 +81,10 @@
7981
models/rank/naml.md
8082
models/rank/wide_deep.md
8183
models/rank/xdeepfm.md
84+
models/rank/bert4rec.md
85+
models/rank/fat_deepffm.md
86+
models/rank/deeprec.md
87+
models/rank/autofis.md
8288
models/multitask/esmm.md
8389
models/multitask/maml.md
8490
models/multitask/mmoe.md

doc/source/models/rank/autofis.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# AutoFIS (Automatic Feature Interaction Selection in Factorization Models)
2+
3+
代码请参考:[AutoFIS](https://github.com/PaddlePaddle/PaddleRec/tree/master/models/rank/autofis)
4+
如果我们的代码对您有用,还请点个star啊~
5+
6+
## 内容
7+
8+
- [模型简介](#模型简介)
9+
- [数据准备](#数据准备)
10+
- [运行环境](#运行环境)
11+
- [快速开始](#快速开始)
12+
- [效果复现](#效果复现)
13+
- [进阶使用](#进阶使用)
14+
- [FAQ](#FAQ)
15+
16+
## 模型简介
17+
Automatic Feature Interaction Selection in Factorization Models(点击率预测问题下因子分解机模型的自动特征交互选择模)是华为在2020kdd上提出了新的CTR预估方法。论文指出,很多CTR预估算法都需要进行特征组合,但是传统的特征组合方式都是简单的暴力组合或者人工选择,人工选择的方式依赖于先验知识,而简单的暴力组合其实对模型的性能的提升并不是总有益的,有些组合方式其实对模型的性能提升并没有多少的帮助,甚至会损害模型的性能,而且大量无效的特征组合会形成很多的参数,降低内存的利用率。根据AutoML技术,提出AutoFIS,顾名思义,就是自动去找最佳的特征组合。
18+
19+
## 数据准备
20+
21+
数据为[Criteo](http://labs.criteo.com/downloads/download-terabyte-click-log),选择了第6-12天的数据作为训练集,低13天的数据测试集。正负样本采用后的比例约为1:1
22+
在模型目录的data目录下为您准备了快速运行的示例数据,若需要使用全量数据可以参考下方[效果复现](#效果复现)部分。
23+
24+
## 运行环境
25+
PaddlePaddle>=2.0
26+
27+
python 2.7/3.5/3.6/3.7
28+
29+
os : windows/linux/macos
30+
31+
## 快速开始
32+
本文提供了样例数据可以供您快速体验,在任意目录下均可执行。在deepfm模型目录的快速执行命令如下:
33+
```bash
34+
# 进入模型目录
35+
# cd models/rank/deepfm # 在任意目录均可运行
36+
# 动态图训练
37+
python -u ../../../tools/trainer.py -m config.yaml # 全量数据运行config_bigdata.yaml
38+
# 动态图预测
39+
python -u ../../../tools/infer.py -m config.yaml
40+
```
41+
## 效果复现
42+
为了方便使用者能够快速的跑通每一个模型,我们在每个模型下都提供了样例数据。如果需要复现readme中的效果,请按如下步骤依次操作即可。
43+
在全量数据下模型的指标如下:
44+
| 模型 | auc | log_loss|batch_size | epoch_num| Time of each epoch |
45+
| :------| :------ | :------ | :------ | :------| :------ |
46+
| AutodeepFM | 0.8009 |0.5403 | 2000 | 1 | 约3小时 |
47+
48+
1. 确认您当前所在目录为PaddleRec/models/rank/autofis
49+
2. 进入paddlerec/datasets/criteo_autofis
50+
3. 执行命令运行全量数据
51+
52+
``` bash
53+
cd ../../../datasets/criteo_autofis
54+
sh run.sh
55+
```
56+
```bash
57+
cd - # 切回模型目录
58+
# 动态图训练
59+
python trainer.py -m config_bigdata.yaml # stage0:自动搜索最佳特征组合
60+
python trainer.py -m config_bigdata.yaml -o stage=1 # stage1:训练最终模型
61+
python -u ../../../tools/infer.py -m config_bigdata.yaml -o stage=1 # 全量数据运行config_bigdata.yaml
62+
```
63+
## 进阶使用
64+
65+
## FAQ

doc/source/models/rank/bert4rec.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# BERT4Rec模型 (Sequential Recommendation with Bidirectional Encoder Representations from Transformer)
2+
3+
代码请参考:[bert4rec](https://github.com/PaddlePaddle/PaddleRec/tree/master/models/rank/bert4rec)
4+
如果我们的代码对您有用,还请点个star啊~
5+
6+
## 内容
7+
8+
- [模型简介](#模型简介)
9+
- [数据准备](#数据准备)
10+
- [运行环境](#运行环境)
11+
- [快速开始](#快速开始)
12+
- [模型组网](#模型组网)
13+
- [效果复现](#效果复现)
14+
- [进阶使用](#进阶使用)
15+
- [FAQ](#FAQ)
16+
17+
18+
## 模型简介
19+
BERT4Rec将NLP中的mask language任务迁移到序列推荐问题来,**给予了序列推荐一种不同于item2item,left2right的训练范式**
20+
具体来说,对于一条物品序列,**以一定的概率p随机mask掉序列中的物品****使用transformer的encoder结构**对mask item进行预测。
21+
通过数据增强,完形填空任务的方式使得训练更加充分。
22+
23+
[BERT4Rec: Sequential Recommendation with Bidirectional Encoder Representations from Transformer](https://dl.acm.org/doi/abs/10.1145/3357384.3357895)
24+
本模型来自飞桨论文复现挑战赛(第四期)的[BERT4Rec的第一名方案](https://aistudio.baidu.com/aistudio/projectdetail/2558070)达到了原作者github[BERT4Rec](https://github.com/FeiSun/BERT4Rec)的精度。
25+
26+
## 数据准备
27+
本模型使用论文中的数据集Beauty Dataset,在模型目录的data目录下。
28+
29+
## 运行环境
30+
PaddlePaddle>=2.0
31+
32+
python 3.7
33+
34+
## 快速开始
35+
本文提供了样例数据可以供您快速体验,在任意目录下均可执行。在BERT4Rec模型目录的快速执行命令如下:
36+
```bash
37+
# 进入模型目录
38+
# cd models/rank/bert4rec # 在任意目录均可运行
39+
# 动态图训练
40+
python -u ../../../tools/trainer.py -m config.yaml # 全量数据运行config_bigdata.yaml
41+
# 动态图预测
42+
python -u ../../../tools/infer.py -m config.yaml
43+
```
44+
45+
## 模型组网
46+
在BERT4Rec之前,SASRec已经将self-attention应用在了序列推荐任务中。
47+
48+
而与之对应的,BERT4Rec的作者认为像SASRec那种left-to-right的建模方式限制了模型的表达能力。 虽然用户的行为序列长期来看存在顺序的依赖关系,但在短期的一段时间内,用户的行为顺序不应该是严格顺序依赖的。
49+
50+
为了解决上述问题,BERT4Rec将NLP中的Mask Language任务迁移到序列推荐问题来,给予了序列推荐一种不同于item2item,left2right的训练范式。
51+
具体来说,对于一条物品序列,以一定的概率p随机mask掉序列中的物品(体现在data_augment_candi_gen.py),使用Transformer的Encoder结构对masked item进行预测(net.py)。
52+
训练的过程中,则是取出Encoder对应mask位置的representation来预测mask的label物品。即完形填空。
53+
54+
可以注意到,通过随机mask,我们可以成倍的生成新样本。(BERT4Rec训练样本是原有的十一倍(10:随机mask 1:原本样本)) 因此BERT4Rec效果的提升,也从数据增强的角度来解释。即通过数据增强,和完形填空式的前置任务的方式使得模型训练得更加充分。
55+
56+
在模型上面,BERT4Rec正如其名,就是跟BERT一样,使用Transformer的Encoder部分来做序列特征提取。
57+
58+
在测试的时候,我们只需要mask掉序列最后的物品,并取出模型最后一步的representation出来,那么就将训练好的模型成功应用在Next-item Prediction任务上。
59+
60+
## 效果复现
61+
62+
| 模型 | HR@10 | NDCG@10 | MRR | epoch_num| Time of each epoch |
63+
| :------| :------ |:------ | :------ | :------| :------ |
64+
| BERT4Rec | 0.305 | 0.184 | 0.166 | 50 | 约2小时 |
65+
66+
本文提供了beauty数据集可以供您快速体验及其复现。在BERT4Rec模型目录的快速执行命令如下:
67+
68+
```bash
69+
# 进入模型目录
70+
# cd models/rank/bert4rec # 在任意目录均可运行
71+
# 数据增强与候选集生成
72+
python -u data_augment_candi_gen.py
73+
# 动态图训练
74+
python -u ../../../tools/trainer.py -m config_bigdata.yaml
75+
# 动态图预测
76+
python -u ../../../tools/infer.py -m config_bigdata.yaml
77+
```
78+
79+
## 进阶使用
80+
81+
## FAQ
82+

doc/source/models/rank/deeprec.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# DeepRec (Training Deep AutoEncoders for Collaborative Filtering)
2+
3+
代码请参考:[DeepRec](https://github.com/PaddlePaddle/PaddleRec/tree/master/models/rank/deeprec)
4+
如果我们的代码对您有用,还请点个star啊~
5+
6+
## 内容
7+
8+
- [DeepRec](#deeprec)
9+
- [内容](#内容)
10+
- [模型简介](#模型简介)
11+
- [数据准备](#数据准备)
12+
- [运行环境](#运行环境)
13+
- [快速开始](#快速开始)
14+
- [模型组网](#模型组网)
15+
- [效果复现](#效果复现)
16+
- [进阶使用](#进阶使用)
17+
- [FAQ](#faq)
18+
19+
## 模型简介
20+
DeepRec使用基于自编码器的协同过滤,加入了一些tricks,达到了比以往的协同过滤方法更好的效果。tricks包括:1. 加大Dropout的比例(0.8); 2. 使用带负值的激活函数selu; 3. 提出Dense re-feeding, 把预测结果重新放回自编码器中作为新的样本再次预测, 以达到数据增强帮助防止模型过拟合
21+
22+
## 数据准备
23+
我们在作者处理过的开源数据集Netflix上验证模型效果,在模型目录的data目录下为您准备了快速运行的示例数据,若需要使用全量数据可以参考下方[效果复现](#效果复现)部分。
24+
数据的格式如下:
25+
生成的格式以\t为分割点
26+
27+
```
28+
u_id i_id rating
29+
116 341 3.7
30+
```
31+
32+
## 运行环境
33+
PaddlePaddle>=2.0
34+
35+
python 3.5/3.6/3.7/3.8
36+
37+
os : windows/linux/macos
38+
39+
## 快速开始
40+
本文提供了样例数据可以供您快速体验,在任意目录下均可执行。在deeprec模型目录的快速执行命令如下:
41+
```bash
42+
# 进入模型目录
43+
# cd models/rank/deeprec # 在任意目录均可运行
44+
# 动态图训练
45+
python -u trainer.py -m config.yaml # 全量数据运行config_bigdata.yaml
46+
# 动态图预测
47+
python -u infer.py -m config.yaml
48+
```
49+
50+
## 模型组网
51+
DeepRec是一个自编码器, 由encoder和decoder组成, 在encoder和decoder之间加入了一个drop概率很大的dropout层, 使用selu作为激活函数。模型的主要组网结构如下:
52+
[DeepRec](../../../doc/imgs/AutoEncoder.png)
53+
54+
55+
### 效果复现
56+
为了方便使用者能够快速的跑通每一个模型,我们在每个模型下都提供了样例数据。如果需要复现readme中的效果,请按如下步骤依次操作即可。
57+
在全量数据下模型的指标如下:
58+
59+
| 模型 | rmse | layer_sizes | batch_size | epoch_num | Time of each epoch |
60+
| :------| :------ | :------ | :------| :------ | -------|
61+
| DeepRec | 0.9172 | [n(17768), 512, 512, 1024] | 128 | 45 | 约55秒 |
62+
63+
1. 确认您当前所在目录为PaddleRec/models/rank/deeprec
64+
2. 进入paddlerec/datasets/Netflix目录下,执行该脚本,会从国内源的服务器上下载Netflix Price数据集,并解压到指定文件夹。
65+
66+
``` bash
67+
cd data
68+
sh run.sh
69+
```
70+
3. 切回模型目录,执行命令运行全量数据
71+
```bash
72+
cd - # 切回模型目录
73+
# 动态图训练
74+
python -u trainer.py -m config_bigdata.yaml # 全量数据运行config_bigdata.yaml
75+
python -u infer.py -m config_bigdata.yaml # 全量数据运行config_bigdata.yaml
76+
```
77+
78+
## 进阶使用
79+
80+
## FAQ

0 commit comments

Comments
 (0)