torch-rechub 0.0.2__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/LICENSE +21 -21
- {torch-rechub-0.0.2/torch_rechub.egg-info → torch_rechub-0.0.3}/PKG-INFO +177 -139
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/README.md +143 -112
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/setup.cfg +4 -4
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/setup.py +37 -34
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/basic/activation.py +54 -52
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/basic/callback.py +32 -32
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/basic/features.py +94 -70
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/basic/initializers.py +92 -92
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/basic/layers.py +720 -441
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/basic/loss_func.py +33 -33
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/basic/metaoptimizer.py +72 -72
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/basic/metric.py +250 -234
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/matching/__init__.py +11 -7
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/matching/comirec.py +188 -188
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/matching/dssm.py +65 -65
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/matching/dssm_facebook.py +79 -79
- torch_rechub-0.0.3/torch_rechub/models/matching/dssm_senet.py +75 -0
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/matching/gru4rec.py +87 -87
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/matching/mind.py +101 -101
- torch_rechub-0.0.3/torch_rechub/models/matching/narm.py +76 -0
- torch_rechub-0.0.3/torch_rechub/models/matching/sasrec.py +140 -0
- torch_rechub-0.0.3/torch_rechub/models/matching/sine.py +151 -0
- torch_rechub-0.0.3/torch_rechub/models/matching/stamp.py +83 -0
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/matching/youtube_dnn.py +71 -71
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/matching/youtube_sbc.py +97 -97
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/multi_task/__init__.py +4 -4
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/multi_task/aitm.py +83 -83
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/multi_task/esmm.py +55 -48
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/multi_task/mmoe.py +58 -58
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/multi_task/ple.py +130 -130
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/multi_task/shared_bottom.py +45 -45
- torch_rechub-0.0.3/torch_rechub/models/ranking/__init__.py +11 -0
- torch_rechub-0.0.3/torch_rechub/models/ranking/afm.py +63 -0
- torch_rechub-0.0.3/torch_rechub/models/ranking/bst.py +63 -0
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/ranking/dcn.py +37 -37
- torch_rechub-0.0.3/torch_rechub/models/ranking/dcn_v2.py +69 -0
- torch_rechub-0.0.3/torch_rechub/models/ranking/deepffm.py +123 -0
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/ranking/deepfm.py +41 -41
- torch_rechub-0.0.3/torch_rechub/models/ranking/dien.py +191 -0
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/ranking/din.py +91 -89
- torch_rechub-0.0.3/torch_rechub/models/ranking/edcn.py +117 -0
- torch_rechub-0.0.3/torch_rechub/models/ranking/fibinet.py +50 -0
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/ranking/widedeep.py +41 -41
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/trainers/__init__.py +2 -2
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/trainers/ctr_trainer.py +128 -115
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/trainers/match_trainer.py +170 -171
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/trainers/mtl_trainer.py +206 -161
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/utils/data.py +360 -245
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/utils/match.py +274 -190
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/utils/mtl.py +126 -94
- {torch-rechub-0.0.2 → torch_rechub-0.0.3/torch_rechub.egg-info}/PKG-INFO +177 -139
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub.egg-info/SOURCES.txt +12 -0
- torch-rechub-0.0.2/torch_rechub/models/ranking/__init__.py +0 -4
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/__init__.py +0 -0
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/basic/__init__.py +0 -0
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/models/__init__.py +0 -0
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub/utils/__init__.py +0 -0
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub.egg-info/dependency_links.txt +0 -0
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub.egg-info/requires.txt +0 -0
- {torch-rechub-0.0.2 → torch_rechub-0.0.3}/torch_rechub.egg-info/top_level.txt +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Datawhale
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Datawhale
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,139 +1,177 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: torch-rechub
|
|
3
|
-
Version: 0.0.
|
|
4
|
-
Summary: A Lighting Pytorch Framework for Recommendation System, Easy-to-use and Easy-to-extend.
|
|
5
|
-
Home-page: https://github.com/datawhalechina/torch-rechub
|
|
6
|
-
Author: Datawhale
|
|
7
|
-
Author-email: laimc@shanghaitech.edu.cn
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Classifier: Intended Audience ::
|
|
12
|
-
Classifier: Intended Audience ::
|
|
13
|
-
Classifier:
|
|
14
|
-
Classifier:
|
|
15
|
-
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.
|
|
18
|
-
Classifier:
|
|
19
|
-
Classifier:
|
|
20
|
-
Classifier: Topic ::
|
|
21
|
-
Classifier: Topic ::
|
|
22
|
-
Classifier:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
model =
|
|
133
|
-
|
|
134
|
-
ctr_trainer =
|
|
135
|
-
ctr_trainer.fit(train_dataloader, val_dataloader)
|
|
136
|
-
auc = ctr_trainer.evaluate(ctr_trainer.model, test_dataloader)
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: torch-rechub
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: A Lighting Pytorch Framework for Recommendation System, Easy-to-use and Easy-to-extend.
|
|
5
|
+
Home-page: https://github.com/datawhalechina/torch-rechub
|
|
6
|
+
Author: Datawhale
|
|
7
|
+
Author-email: laimc@shanghaitech.edu.cn
|
|
8
|
+
Keywords: ctr,click through rate,deep learning,pytorch,recsys,recommendation
|
|
9
|
+
Platform: all
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Intended Audience :: Education
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: numpy>=1.19.0
|
|
29
|
+
Requires-Dist: torch>=1.7.0
|
|
30
|
+
Requires-Dist: pandas>=1.0.5
|
|
31
|
+
Requires-Dist: tqdm>=4.64.0
|
|
32
|
+
Requires-Dist: scikit_learn>=0.23.2
|
|
33
|
+
Requires-Dist: annoy>=1.17.0
|
|
34
|
+
|
|
35
|
+
# Torch-RecHub
|
|
36
|
+
|
|
37
|
+
<p align="left">
|
|
38
|
+
<img src='https://img.shields.io/badge/python-3.8+-brightgreen'>
|
|
39
|
+
<img src='https://img.shields.io/badge/torch-1.7+-brightgreen'>
|
|
40
|
+
<img src='https://img.shields.io/badge/scikit_learn-0.23.2+-brightgreen'>
|
|
41
|
+
<img src='https://img.shields.io/badge/pandas-1.0.5+-brightgreen'>
|
|
42
|
+
<img src='https://img.shields.io/badge/annoy-1.17.0-brightgreen'>
|
|
43
|
+
<img src="https://img.shields.io/pypi/l/torch-rechub">
|
|
44
|
+
<a href="https://github.com/datawhalechina/torch-rechub"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fdatawhalechina%2Ftorch-rechub&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false"/></a>
|
|
45
|
+
|
|
46
|
+
## 中文Wiki站
|
|
47
|
+
|
|
48
|
+
查看最新研发进度,认领感兴趣的研发任务,学习rechub模型复现心得,加入rechub共建者团队等
|
|
49
|
+
|
|
50
|
+
[点击链接](https://www.wolai.com/rechub/2qjdg3DPy1179e1vpcHZQC)
|
|
51
|
+
|
|
52
|
+
## 安装
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
#稳定版
|
|
56
|
+
pip install torch-rechub
|
|
57
|
+
|
|
58
|
+
#最新版(推荐)
|
|
59
|
+
1. git clone https://github.com/datawhalechina/torch-rechub.git
|
|
60
|
+
2. cd torch-rechub
|
|
61
|
+
3. python setup.py install
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 核心定位
|
|
65
|
+
|
|
66
|
+
易用易拓展,聚焦复现业界实用的推荐模型,以及泛生态化的推荐场景
|
|
67
|
+
|
|
68
|
+
## 主要特性
|
|
69
|
+
|
|
70
|
+
* scikit-learn风格易用的API(fit、predict),即插即用
|
|
71
|
+
|
|
72
|
+
* 模型训练与模型定义解耦,易拓展,可针对不同类型的模型设置不同的训练机制
|
|
73
|
+
|
|
74
|
+
* 接受pandas的DataFrame、Dict数据输入,上手成本低
|
|
75
|
+
|
|
76
|
+
* 高度模块化,支持常见Layer,容易调用组装成新模型
|
|
77
|
+
|
|
78
|
+
* LR、MLP、FM、FFM、CIN
|
|
79
|
+
|
|
80
|
+
* target-attention、self-attention、transformer
|
|
81
|
+
|
|
82
|
+
* 支持常见排序模型
|
|
83
|
+
|
|
84
|
+
* WideDeep、DeepFM、DIN、DCN、xDeepFM等
|
|
85
|
+
|
|
86
|
+
* 支持常见召回模型
|
|
87
|
+
|
|
88
|
+
* DSSM、YoutubeDNN、YoutubeDSSM、FacebookEBR、MIND等
|
|
89
|
+
|
|
90
|
+
* 丰富的多任务学习支持
|
|
91
|
+
|
|
92
|
+
* SharedBottom、ESMM、MMOE、PLE、AITM等模型
|
|
93
|
+
|
|
94
|
+
* GradNorm、UWL、MetaBanlance等动态loss加权机制
|
|
95
|
+
|
|
96
|
+
* 聚焦更生态化的推荐场景
|
|
97
|
+
|
|
98
|
+
- [ ] 冷启动
|
|
99
|
+
|
|
100
|
+
- [ ] 延迟反馈
|
|
101
|
+
|
|
102
|
+
* [ ] 去偏
|
|
103
|
+
|
|
104
|
+
* 支持丰富的训练机制
|
|
105
|
+
|
|
106
|
+
* [ ] 对比学习
|
|
107
|
+
|
|
108
|
+
* [ ] 蒸馏学习
|
|
109
|
+
|
|
110
|
+
* [ ] 第三方高性能开源Trainer支持(Pytorch Lighting)
|
|
111
|
+
|
|
112
|
+
* [ ] 更多模型正在开发中
|
|
113
|
+
|
|
114
|
+
## 快速使用
|
|
115
|
+
|
|
116
|
+
### 使用案例
|
|
117
|
+
|
|
118
|
+
- 所有模型使用案例参考 `/examples`
|
|
119
|
+
|
|
120
|
+
- 202206 Datawhale-RecHub推荐课程 组队学习期间notebook教程参考 `/tutorials`
|
|
121
|
+
|
|
122
|
+
### 精排(CTR预测)
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from torch_rechub.models.ranking import DeepFM
|
|
126
|
+
from torch_rechub.trainers import CTRTrainer
|
|
127
|
+
from torch_rechub.utils.data import DataGenerator
|
|
128
|
+
|
|
129
|
+
dg = DataGenerator(x, y)
|
|
130
|
+
train_dataloader, val_dataloader, test_dataloader = dg.generate_dataloader(split_ratio=[0.7, 0.1], batch_size=256)
|
|
131
|
+
|
|
132
|
+
model = DeepFM(deep_features=deep_features, fm_features=fm_features, mlp_params={"dims": [256, 128], "dropout": 0.2, "activation": "relu"})
|
|
133
|
+
|
|
134
|
+
ctr_trainer = CTRTrainer(model)
|
|
135
|
+
ctr_trainer.fit(train_dataloader, val_dataloader)
|
|
136
|
+
auc = ctr_trainer.evaluate(ctr_trainer.model, test_dataloader)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 多任务排序
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from torch_rechub.models.multi_task import SharedBottom, ESMM, MMOE, PLE, AITM
|
|
143
|
+
from torch_rechub.trainers import MTLTrainer
|
|
144
|
+
|
|
145
|
+
task_types = ["classification", "classification"]
|
|
146
|
+
model = MMOE(features, task_types, 8, expert_params={"dims": [32,16]}, tower_params_list=[{"dims": [32, 16]}, {"dims": [32, 16]}])
|
|
147
|
+
|
|
148
|
+
mtl_trainer = MTLTrainer(model)
|
|
149
|
+
mtl_trainer.fit(train_dataloader, val_dataloader)
|
|
150
|
+
auc = ctr_trainer.evaluate(ctr_trainer.model, test_dataloader)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 召回模型
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
from torch_rechub.models.matching import DSSM
|
|
157
|
+
from torch_rechub.trainers import MatchTrainer
|
|
158
|
+
from torch_rechub.utils.data import MatchDataGenerator
|
|
159
|
+
|
|
160
|
+
dg = MatchDataGenerator(x y)
|
|
161
|
+
train_dl, test_dl, item_dl = dg.generate_dataloader(test_user, all_item, batch_size=256)
|
|
162
|
+
|
|
163
|
+
model = DSSM(user_features, item_features, temperature=0.02,
|
|
164
|
+
user_params={
|
|
165
|
+
"dims": [256, 128, 64],
|
|
166
|
+
"activation": 'prelu',
|
|
167
|
+
},
|
|
168
|
+
item_params={
|
|
169
|
+
"dims": [256, 128, 64],
|
|
170
|
+
"activation": 'prelu',
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
match_trainer = MatchTrainer(model)
|
|
174
|
+
match_trainer.fit(train_dl)
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
|
|
@@ -1,112 +1,143 @@
|
|
|
1
|
-
# Torch-RecHub
|
|
2
|
-
|
|
3
|
-
<p align="left">
|
|
4
|
-
<img src='https://img.shields.io/badge/python-3.8+-brightgreen'>
|
|
5
|
-
<img src='https://img.shields.io/badge/torch-1.7+-brightgreen'>
|
|
6
|
-
<img src='https://img.shields.io/badge/scikit_learn-0.23.2+-brightgreen'>
|
|
7
|
-
<img src='https://img.shields.io/badge/pandas-1.0.5+-brightgreen'>
|
|
8
|
-
<img src='https://img.shields.io/badge/annoy-1.17.0-brightgreen'>
|
|
9
|
-
<img src="https://img.shields.io/pypi/l/torch-rechub">
|
|
10
|
-
<a href="https://github.com/datawhalechina/torch-rechub"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fdatawhalechina%2Ftorch-rechub&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false"/></a>
|
|
11
|
-
|
|
12
|
-
## 中文Wiki站
|
|
13
|
-
|
|
14
|
-
查看最新研发进度,认领感兴趣的研发任务,学习rechub模型复现心得,加入rechub共建者团队等
|
|
15
|
-
|
|
16
|
-
[点击链接](https://www.wolai.com/rechub/2qjdg3DPy1179e1vpcHZQC)
|
|
17
|
-
|
|
18
|
-
## 安装
|
|
19
|
-
|
|
20
|
-
```python
|
|
21
|
-
#稳定版
|
|
22
|
-
pip install torch-rechub
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
1. git clone https://github.com/datawhalechina/torch-rechub.git
|
|
26
|
-
2. cd torch-rechub
|
|
27
|
-
3. python setup.py install
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## 核心定位
|
|
31
|
-
|
|
32
|
-
易用易拓展,聚焦复现业界实用的推荐模型,以及泛生态化的推荐场景
|
|
33
|
-
|
|
34
|
-
## 主要特性
|
|
35
|
-
|
|
36
|
-
* scikit-learn风格易用的API(fit、predict),即插即用
|
|
37
|
-
|
|
38
|
-
* 模型训练与模型定义解耦,易拓展,可针对不同类型的模型设置不同的训练机制
|
|
39
|
-
|
|
40
|
-
* 接受pandas的DataFrame、Dict数据输入,上手成本低
|
|
41
|
-
|
|
42
|
-
* 高度模块化,支持常见Layer,容易调用组装成新模型
|
|
43
|
-
|
|
44
|
-
* LR、MLP、FM、FFM、CIN
|
|
45
|
-
|
|
46
|
-
* target-attention、self-attention、transformer
|
|
47
|
-
|
|
48
|
-
* 支持常见排序模型
|
|
49
|
-
|
|
50
|
-
* WideDeep、DeepFM、DIN、DCN、xDeepFM等
|
|
51
|
-
|
|
52
|
-
* 支持常见召回模型
|
|
53
|
-
|
|
54
|
-
* DSSM、YoutubeDNN、YoutubeDSSM、FacebookEBR、MIND等
|
|
55
|
-
|
|
56
|
-
* 丰富的多任务学习支持
|
|
57
|
-
|
|
58
|
-
* SharedBottom、ESMM、MMOE、PLE、AITM等模型
|
|
59
|
-
|
|
60
|
-
* GradNorm、UWL、MetaBanlance等动态loss加权机制
|
|
61
|
-
|
|
62
|
-
* 聚焦更生态化的推荐场景
|
|
63
|
-
|
|
64
|
-
- [ ] 冷启动
|
|
65
|
-
|
|
66
|
-
- [ ] 延迟反馈
|
|
67
|
-
|
|
68
|
-
* [ ] 去偏
|
|
69
|
-
|
|
70
|
-
* 支持丰富的训练机制
|
|
71
|
-
|
|
72
|
-
* [ ] 对比学习
|
|
73
|
-
|
|
74
|
-
* [ ] 蒸馏学习
|
|
75
|
-
|
|
76
|
-
* [ ] 第三方高性能开源Trainer支持(Pytorch Lighting)
|
|
77
|
-
|
|
78
|
-
* [ ] 更多模型正在开发中
|
|
79
|
-
|
|
80
|
-
## 快速使用
|
|
81
|
-
|
|
82
|
-
###
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
1
|
+
# Torch-RecHub
|
|
2
|
+
|
|
3
|
+
<p align="left">
|
|
4
|
+
<img src='https://img.shields.io/badge/python-3.8+-brightgreen'>
|
|
5
|
+
<img src='https://img.shields.io/badge/torch-1.7+-brightgreen'>
|
|
6
|
+
<img src='https://img.shields.io/badge/scikit_learn-0.23.2+-brightgreen'>
|
|
7
|
+
<img src='https://img.shields.io/badge/pandas-1.0.5+-brightgreen'>
|
|
8
|
+
<img src='https://img.shields.io/badge/annoy-1.17.0-brightgreen'>
|
|
9
|
+
<img src="https://img.shields.io/pypi/l/torch-rechub">
|
|
10
|
+
<a href="https://github.com/datawhalechina/torch-rechub"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fdatawhalechina%2Ftorch-rechub&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false"/></a>
|
|
11
|
+
|
|
12
|
+
## 中文Wiki站
|
|
13
|
+
|
|
14
|
+
查看最新研发进度,认领感兴趣的研发任务,学习rechub模型复现心得,加入rechub共建者团队等
|
|
15
|
+
|
|
16
|
+
[点击链接](https://www.wolai.com/rechub/2qjdg3DPy1179e1vpcHZQC)
|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
#稳定版
|
|
22
|
+
pip install torch-rechub
|
|
23
|
+
|
|
24
|
+
#最新版(推荐)
|
|
25
|
+
1. git clone https://github.com/datawhalechina/torch-rechub.git
|
|
26
|
+
2. cd torch-rechub
|
|
27
|
+
3. python setup.py install
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 核心定位
|
|
31
|
+
|
|
32
|
+
易用易拓展,聚焦复现业界实用的推荐模型,以及泛生态化的推荐场景
|
|
33
|
+
|
|
34
|
+
## 主要特性
|
|
35
|
+
|
|
36
|
+
* scikit-learn风格易用的API(fit、predict),即插即用
|
|
37
|
+
|
|
38
|
+
* 模型训练与模型定义解耦,易拓展,可针对不同类型的模型设置不同的训练机制
|
|
39
|
+
|
|
40
|
+
* 接受pandas的DataFrame、Dict数据输入,上手成本低
|
|
41
|
+
|
|
42
|
+
* 高度模块化,支持常见Layer,容易调用组装成新模型
|
|
43
|
+
|
|
44
|
+
* LR、MLP、FM、FFM、CIN
|
|
45
|
+
|
|
46
|
+
* target-attention、self-attention、transformer
|
|
47
|
+
|
|
48
|
+
* 支持常见排序模型
|
|
49
|
+
|
|
50
|
+
* WideDeep、DeepFM、DIN、DCN、xDeepFM等
|
|
51
|
+
|
|
52
|
+
* 支持常见召回模型
|
|
53
|
+
|
|
54
|
+
* DSSM、YoutubeDNN、YoutubeDSSM、FacebookEBR、MIND等
|
|
55
|
+
|
|
56
|
+
* 丰富的多任务学习支持
|
|
57
|
+
|
|
58
|
+
* SharedBottom、ESMM、MMOE、PLE、AITM等模型
|
|
59
|
+
|
|
60
|
+
* GradNorm、UWL、MetaBanlance等动态loss加权机制
|
|
61
|
+
|
|
62
|
+
* 聚焦更生态化的推荐场景
|
|
63
|
+
|
|
64
|
+
- [ ] 冷启动
|
|
65
|
+
|
|
66
|
+
- [ ] 延迟反馈
|
|
67
|
+
|
|
68
|
+
* [ ] 去偏
|
|
69
|
+
|
|
70
|
+
* 支持丰富的训练机制
|
|
71
|
+
|
|
72
|
+
* [ ] 对比学习
|
|
73
|
+
|
|
74
|
+
* [ ] 蒸馏学习
|
|
75
|
+
|
|
76
|
+
* [ ] 第三方高性能开源Trainer支持(Pytorch Lighting)
|
|
77
|
+
|
|
78
|
+
* [ ] 更多模型正在开发中
|
|
79
|
+
|
|
80
|
+
## 快速使用
|
|
81
|
+
|
|
82
|
+
### 使用案例
|
|
83
|
+
|
|
84
|
+
- 所有模型使用案例参考 `/examples`
|
|
85
|
+
|
|
86
|
+
- 202206 Datawhale-RecHub推荐课程 组队学习期间notebook教程参考 `/tutorials`
|
|
87
|
+
|
|
88
|
+
### 精排(CTR预测)
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from torch_rechub.models.ranking import DeepFM
|
|
92
|
+
from torch_rechub.trainers import CTRTrainer
|
|
93
|
+
from torch_rechub.utils.data import DataGenerator
|
|
94
|
+
|
|
95
|
+
dg = DataGenerator(x, y)
|
|
96
|
+
train_dataloader, val_dataloader, test_dataloader = dg.generate_dataloader(split_ratio=[0.7, 0.1], batch_size=256)
|
|
97
|
+
|
|
98
|
+
model = DeepFM(deep_features=deep_features, fm_features=fm_features, mlp_params={"dims": [256, 128], "dropout": 0.2, "activation": "relu"})
|
|
99
|
+
|
|
100
|
+
ctr_trainer = CTRTrainer(model)
|
|
101
|
+
ctr_trainer.fit(train_dataloader, val_dataloader)
|
|
102
|
+
auc = ctr_trainer.evaluate(ctr_trainer.model, test_dataloader)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 多任务排序
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from torch_rechub.models.multi_task import SharedBottom, ESMM, MMOE, PLE, AITM
|
|
109
|
+
from torch_rechub.trainers import MTLTrainer
|
|
110
|
+
|
|
111
|
+
task_types = ["classification", "classification"]
|
|
112
|
+
model = MMOE(features, task_types, 8, expert_params={"dims": [32,16]}, tower_params_list=[{"dims": [32, 16]}, {"dims": [32, 16]}])
|
|
113
|
+
|
|
114
|
+
mtl_trainer = MTLTrainer(model)
|
|
115
|
+
mtl_trainer.fit(train_dataloader, val_dataloader)
|
|
116
|
+
auc = ctr_trainer.evaluate(ctr_trainer.model, test_dataloader)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 召回模型
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from torch_rechub.models.matching import DSSM
|
|
123
|
+
from torch_rechub.trainers import MatchTrainer
|
|
124
|
+
from torch_rechub.utils.data import MatchDataGenerator
|
|
125
|
+
|
|
126
|
+
dg = MatchDataGenerator(x y)
|
|
127
|
+
train_dl, test_dl, item_dl = dg.generate_dataloader(test_user, all_item, batch_size=256)
|
|
128
|
+
|
|
129
|
+
model = DSSM(user_features, item_features, temperature=0.02,
|
|
130
|
+
user_params={
|
|
131
|
+
"dims": [256, 128, 64],
|
|
132
|
+
"activation": 'prelu',
|
|
133
|
+
},
|
|
134
|
+
item_params={
|
|
135
|
+
"dims": [256, 128, 64],
|
|
136
|
+
"activation": 'prelu',
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
match_trainer = MatchTrainer(model)
|
|
140
|
+
match_trainer.fit(train_dl)
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[egg_info]
|
|
2
|
-
tag_build =
|
|
3
|
-
tag_date = 0
|
|
4
|
-
|
|
1
|
+
[egg_info]
|
|
2
|
+
tag_build =
|
|
3
|
+
tag_date = 0
|
|
4
|
+
|