torch-rechub 0.0.3__py3-none-any.whl → 0.0.5__py3-none-any.whl

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.
Files changed (64) hide show
  1. torch_rechub/__init__.py +14 -0
  2. torch_rechub/basic/activation.py +54 -54
  3. torch_rechub/basic/callback.py +33 -33
  4. torch_rechub/basic/features.py +87 -94
  5. torch_rechub/basic/initializers.py +92 -92
  6. torch_rechub/basic/layers.py +994 -720
  7. torch_rechub/basic/loss_func.py +223 -34
  8. torch_rechub/basic/metaoptimizer.py +76 -72
  9. torch_rechub/basic/metric.py +251 -250
  10. torch_rechub/models/generative/__init__.py +6 -0
  11. torch_rechub/models/generative/hllm.py +249 -0
  12. torch_rechub/models/generative/hstu.py +189 -0
  13. torch_rechub/models/matching/__init__.py +13 -11
  14. torch_rechub/models/matching/comirec.py +193 -188
  15. torch_rechub/models/matching/dssm.py +72 -66
  16. torch_rechub/models/matching/dssm_facebook.py +77 -79
  17. torch_rechub/models/matching/dssm_senet.py +28 -16
  18. torch_rechub/models/matching/gru4rec.py +85 -87
  19. torch_rechub/models/matching/mind.py +103 -101
  20. torch_rechub/models/matching/narm.py +82 -76
  21. torch_rechub/models/matching/sasrec.py +143 -140
  22. torch_rechub/models/matching/sine.py +148 -151
  23. torch_rechub/models/matching/stamp.py +81 -83
  24. torch_rechub/models/matching/youtube_dnn.py +75 -71
  25. torch_rechub/models/matching/youtube_sbc.py +98 -98
  26. torch_rechub/models/multi_task/__init__.py +7 -5
  27. torch_rechub/models/multi_task/aitm.py +83 -84
  28. torch_rechub/models/multi_task/esmm.py +56 -55
  29. torch_rechub/models/multi_task/mmoe.py +58 -58
  30. torch_rechub/models/multi_task/ple.py +116 -130
  31. torch_rechub/models/multi_task/shared_bottom.py +45 -45
  32. torch_rechub/models/ranking/__init__.py +14 -11
  33. torch_rechub/models/ranking/afm.py +65 -63
  34. torch_rechub/models/ranking/autoint.py +102 -0
  35. torch_rechub/models/ranking/bst.py +61 -63
  36. torch_rechub/models/ranking/dcn.py +38 -38
  37. torch_rechub/models/ranking/dcn_v2.py +59 -69
  38. torch_rechub/models/ranking/deepffm.py +131 -123
  39. torch_rechub/models/ranking/deepfm.py +43 -42
  40. torch_rechub/models/ranking/dien.py +191 -191
  41. torch_rechub/models/ranking/din.py +93 -91
  42. torch_rechub/models/ranking/edcn.py +101 -117
  43. torch_rechub/models/ranking/fibinet.py +42 -50
  44. torch_rechub/models/ranking/widedeep.py +41 -41
  45. torch_rechub/trainers/__init__.py +4 -3
  46. torch_rechub/trainers/ctr_trainer.py +288 -128
  47. torch_rechub/trainers/match_trainer.py +336 -170
  48. torch_rechub/trainers/matching.md +3 -0
  49. torch_rechub/trainers/mtl_trainer.py +356 -207
  50. torch_rechub/trainers/seq_trainer.py +427 -0
  51. torch_rechub/utils/data.py +492 -360
  52. torch_rechub/utils/hstu_utils.py +198 -0
  53. torch_rechub/utils/match.py +457 -274
  54. torch_rechub/utils/model_utils.py +233 -0
  55. torch_rechub/utils/mtl.py +136 -126
  56. torch_rechub/utils/onnx_export.py +220 -0
  57. torch_rechub/utils/visualization.py +271 -0
  58. torch_rechub-0.0.5.dist-info/METADATA +402 -0
  59. torch_rechub-0.0.5.dist-info/RECORD +64 -0
  60. {torch_rechub-0.0.3.dist-info → torch_rechub-0.0.5.dist-info}/WHEEL +1 -2
  61. {torch_rechub-0.0.3.dist-info → torch_rechub-0.0.5.dist-info/licenses}/LICENSE +21 -21
  62. torch_rechub-0.0.3.dist-info/METADATA +0 -177
  63. torch_rechub-0.0.3.dist-info/RECORD +0 -55
  64. torch_rechub-0.0.3.dist-info/top_level.txt +0 -1
@@ -1,177 +0,0 @@
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,55 +0,0 @@
1
- torch_rechub/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- torch_rechub/basic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- torch_rechub/basic/activation.py,sha256=MjqWIXKhOygkwxVpuCNPaqgmP_gB13tHBgANyFoPh8k,1658
4
- torch_rechub/basic/callback.py,sha256=GzAOfW-xWOJNdZhxE21crFX6-GbKinYApdPtdz4WwNQ,985
5
- torch_rechub/basic/features.py,sha256=3SqSQ0uRj6lwr3j7OXIlLeS05jt5v9nlkkgilWfALL0,3777
6
- torch_rechub/basic/initializers.py,sha256=AfJd0mqQqGqzk12IC_N2qZgRzz4LyP8n9FcmWzWTmH4,3292
7
- torch_rechub/basic/layers.py,sha256=rOdbvpPxp3GbQ4lgZSZgWeOuhbDgjVOpHe-rbha_fyk,30484
8
- torch_rechub/basic/loss_func.py,sha256=EeqYUClS3CVv3EEx2XnzK0vWAULZAw_Lr0mjf9XN6U4,1170
9
- torch_rechub/basic/metaoptimizer.py,sha256=AmG-LrkDKhSnI2kK7qzVVJS0eQ3aMWHS1nEqeRXWFgU,3138
10
- torch_rechub/basic/metric.py,sha256=m8fKjRVja6PyllV5OrHXwbpNntK73jFv-QzA94pNAIU,7508
11
- torch_rechub/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- torch_rechub/models/matching/__init__.py,sha256=gR9csAI1ataaIVRqdlBSpsEYmLotq3UNc-YUV9PvAf4,336
13
- torch_rechub/models/matching/comirec.py,sha256=-i3bb9ovcyEtGl8wqpLVo0EIwADjd3Ui7jn3b3pX7ps,9620
14
- torch_rechub/models/matching/dssm.py,sha256=FuWhH-lGtqAfe6vm_Pi1K0l-wLkqTVYwtIxFrwISsXo,3042
15
- torch_rechub/models/matching/dssm_facebook.py,sha256=n8nqHk2RFm_qUuBEqiu5leMSFj6giGibanru0yPk7Rk,3679
16
- torch_rechub/models/matching/dssm_senet.py,sha256=AhY298J8kHjtubmJkHht8QpXnH5QC1ArPrDBYA2q4KE,3967
17
- torch_rechub/models/matching/gru4rec.py,sha256=RzbVrTV-LkLB8g7vwpsUXd7viyz6ZPf0BBv3IK1bs_I,4136
18
- torch_rechub/models/matching/mind.py,sha256=pnlvqYXU5sKYpzIs-ktmMBFTEUgNIfNjoXXgurFbwz4,5029
19
- torch_rechub/models/matching/narm.py,sha256=UTsIuCSoMPzVDlnB6eOF-vEF5SYV-VET9pMalFYDT4I,3244
20
- torch_rechub/models/matching/sasrec.py,sha256=9_4vO9Kz25Wj19i0SPsOfhbQWMJKtGQneNRMUQV0w6Y,5865
21
- torch_rechub/models/matching/sine.py,sha256=uglxLI4r5JU0CnFdKZdSPcnkvmeE6b9vr2N5sBoP_qw,7089
22
- torch_rechub/models/matching/stamp.py,sha256=8N7Zl527QvqARtrwf8niP86djnMy4YYqT_EPp-7UhTY,3556
23
- torch_rechub/models/matching/youtube_dnn.py,sha256=ZIQY4nQFRi73QWYVALgFaApaiJQCxLQoeHzk0O2BBxg,3453
24
- torch_rechub/models/matching/youtube_sbc.py,sha256=L5xfgxEvDTlBmK09GNRXiZVfFAf4v2WyKltRE18CVX8,4945
25
- torch_rechub/models/multi_task/__init__.py,sha256=1dAe4mo8kRjsCAUx6Cs3jzw-PrlI2y0B5q6BK-THgZM,133
26
- torch_rechub/models/multi_task/aitm.py,sha256=dcXDBXwYEHNlBlGv-gbY6lZ6Nba3Wi6iqYuYP1SGR40,3454
27
- torch_rechub/models/multi_task/esmm.py,sha256=WYUiuhLxeBx9QpgJS6RawPvz9n0WWff0q7jEX4xnbDI,2789
28
- torch_rechub/models/multi_task/mmoe.py,sha256=e3_0tO9dbH831y0kRdpy8hDQhFSpM7gI9GTspYCAZeA,2926
29
- torch_rechub/models/multi_task/ple.py,sha256=3S5ufr320BOl41hUYxez6tKPcKKQoHq7yW1j7q-tNQk,7005
30
- torch_rechub/models/multi_task/shared_bottom.py,sha256=EgLIF1Hb6u-S83pLeX-DlXAbZWu92KSS4kTl5CKQllw,1913
31
- torch_rechub/models/ranking/__init__.py,sha256=Hj9_4RghDB0yzc8EGP9wwBb7VMpgogQN71NCtcOj6MI,293
32
- torch_rechub/models/ranking/afm.py,sha256=HK1ww6g38vKEhEj9M0UPEVnTQ_OQKggv5qxxkrpjlLA,2323
33
- torch_rechub/models/ranking/bst.py,sha256=mSISHGSYsNwjdPDOsxyXPuDXsR1qxYrVNUZBx03XDw4,3815
34
- torch_rechub/models/ranking/dcn.py,sha256=OB0seU6YZRV9nGSSpV3aZWTWSXJlY0f45sfBtleaMV0,1339
35
- torch_rechub/models/ranking/dcn_v2.py,sha256=yUAncBAEAEjkzPbZFKDWoSQFa4Ogo48qkHVnpprB8JQ,3182
36
- torch_rechub/models/ranking/deepffm.py,sha256=mrA-tOHhNsqoaO1lgd6mg-nVMNScOt8fW1dKOjYyeT0,6429
37
- torch_rechub/models/ranking/deepfm.py,sha256=g_RbTY0oWz6Bu1XyU6B0BXLznXKroIVjFrOzw5InVXU,1815
38
- torch_rechub/models/ranking/dien.py,sha256=r0Wjm3MINAI3q0E82mQIGN1Q8Y6B4ZA9-uax6xfvjEg,9164
39
- torch_rechub/models/ranking/din.py,sha256=mSmohL7DHlqppo8aSNFYKA8FmpBww8Cxjn-U476Ag7I,4715
40
- torch_rechub/models/ranking/edcn.py,sha256=XJQ9vSYRgQMyJlGFAJH95OfIl5UAzvinmvtBYD-sHCU,5673
41
- torch_rechub/models/ranking/fibinet.py,sha256=dLfDGdBbhlgz5JmgzBCKRrvYHgkAjP3VfcMsa5Sv3Tg,2294
42
- torch_rechub/models/ranking/widedeep.py,sha256=tSFqeTsg-vjz-6_Av18GZqRVh3NBs7HlumE8-uV9-88,1675
43
- torch_rechub/trainers/__init__.py,sha256=TPdNJp7UjHrmJE5Jq3YfM0OZ71Kfd6tDmBS-HhTdtxU,113
44
- torch_rechub/trainers/ctr_trainer.py,sha256=Hd87UEV4cOOMTvXJnEp3ZXFXAqryTpjgp0TSSFpwcM8,6026
45
- torch_rechub/trainers/match_trainer.py,sha256=Q8OiwCQKm8-aBrCy7qbgII6zOk38qZaJetiis2oPr-0,7988
46
- torch_rechub/trainers/mtl_trainer.py,sha256=tOKO7iQ0CJ4M_AAwzjnH5m6dizWrhdED41oRub6ueBY,10006
47
- torch_rechub/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
- torch_rechub/utils/data.py,sha256=vuRigwbrpXtEBn47zwzqWTtSC4FXihOTk-4hPEUp0OU,14787
49
- torch_rechub/utils/match.py,sha256=diXjN3mDaRSDc24oJpZxWPaXL6pkR6iAaiurfzmJdG8,11908
50
- torch_rechub/utils/mtl.py,sha256=JpRobRgNyCFtDkVVhbQkLdMT4pFrPihJ1cm4QJogddE,5911
51
- torch_rechub-0.0.3.dist-info/LICENSE,sha256=B_RpxT4MtHbioKj8jkv1yhBWs4Zlcd8I4vMS8GH5Gwg,1087
52
- torch_rechub-0.0.3.dist-info/METADATA,sha256=i8JZFLp3YQVZY-awer1MLWwSCJAmJAgJof-ylPptGpI,5833
53
- torch_rechub-0.0.3.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
54
- torch_rechub-0.0.3.dist-info/top_level.txt,sha256=_RPvAnlLHdll9u2d74aFr_oOAj_NxgfLpH02Uifz_YY,13
55
- torch_rechub-0.0.3.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- torch_rechub