nextrec 0.3.6__tar.gz → 0.4.1__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.
- {nextrec-0.3.6 → nextrec-0.4.1}/PKG-INFO +15 -5
- {nextrec-0.3.6 → nextrec-0.4.1}/README.md +14 -4
- {nextrec-0.3.6 → nextrec-0.4.1}/README_zh.md +14 -5
- {nextrec-0.3.6 → nextrec-0.4.1}/docs/rtd/conf.py +1 -1
- nextrec-0.4.1/nextrec/__version__.py +1 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/basic/layers.py +32 -15
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/basic/model.py +435 -187
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/data/data_processing.py +31 -19
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/data/dataloader.py +40 -10
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/generative/hstu.py +3 -2
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/match/dssm.py +0 -1
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/match/dssm_v2.py +0 -1
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/match/mind.py +0 -1
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/match/sdm.py +0 -1
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/match/youtube_dnn.py +0 -1
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/multi_task/esmm.py +5 -7
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/multi_task/mmoe.py +10 -6
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/multi_task/ple.py +10 -6
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/multi_task/poso.py +9 -6
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/multi_task/share_bottom.py +10 -7
- nextrec-0.4.1/nextrec/models/ranking/afm.py +211 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/ranking/autoint.py +15 -9
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/ranking/dcn.py +8 -11
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/ranking/deepfm.py +5 -5
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/ranking/dien.py +4 -4
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/ranking/din.py +4 -4
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/ranking/fibinet.py +4 -4
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/ranking/fm.py +4 -4
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/ranking/masknet.py +4 -5
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/ranking/pnn.py +4 -4
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/ranking/widedeep.py +4 -4
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/ranking/xdeepfm.py +4 -4
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/utils/__init__.py +7 -3
- nextrec-0.4.1/nextrec/utils/device.py +68 -0
- nextrec-0.4.1/nextrec/utils/distributed.py +114 -0
- nextrec-0.4.1/nextrec/utils/synthetic_data.py +413 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/pyproject.toml +1 -1
- {nextrec-0.3.6 → nextrec-0.4.1}/test/test_layers.py +4 -3
- {nextrec-0.3.6 → nextrec-0.4.1}/test/test_losses.py +1 -1
- {nextrec-0.3.6 → nextrec-0.4.1}/test/test_ranking_models.py +3 -3
- {nextrec-0.3.6 → nextrec-0.4.1}/test/test_utils.py +10 -2
- nextrec-0.4.1/tutorials/distributed/example_distributed_training.py +152 -0
- nextrec-0.4.1/tutorials/distributed/example_distributed_training_large_dataset.py +140 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/tutorials/example_match_dssm.py +15 -65
- {nextrec-0.3.6 → nextrec-0.4.1}/tutorials/example_multitask.py +9 -2
- {nextrec-0.3.6 → nextrec-0.4.1}/tutorials/example_ranking_din.py +6 -6
- {nextrec-0.3.6 → nextrec-0.4.1}/tutorials/movielen_match_dssm.py +4 -2
- {nextrec-0.3.6 → nextrec-0.4.1}/tutorials/movielen_ranking_deepfm.py +8 -5
- nextrec-0.4.1/tutorials/run_all_match_models.py +163 -0
- nextrec-0.4.1/tutorials/run_all_multitask_models.py +151 -0
- nextrec-0.4.1/tutorials/run_all_ranking_models.py +162 -0
- nextrec-0.3.6/nextrec/__version__.py +0 -1
- nextrec-0.3.6/nextrec/models/ranking/afm.py +0 -119
- nextrec-0.3.6/nextrec/utils/device.py +0 -38
- nextrec-0.3.6/tutorials/run_all_tutorials.py +0 -59
- {nextrec-0.3.6 → nextrec-0.4.1}/.github/workflows/publish.yml +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/.github/workflows/tests.yml +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/.gitignore +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/.readthedocs.yaml +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/CODE_OF_CONDUCT.md +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/CONTRIBUTING.md +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/LICENSE +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/MANIFEST.in +0 -0
- {nextrec-0.3.6/asserts → nextrec-0.4.1/assets}/Feature Configuration.png +0 -0
- {nextrec-0.3.6/asserts → nextrec-0.4.1/assets}/Model Parameters.png +0 -0
- {nextrec-0.3.6/asserts → nextrec-0.4.1/assets}/Training Configuration.png +0 -0
- {nextrec-0.3.6/asserts → nextrec-0.4.1/assets}/Training logs.png +0 -0
- {nextrec-0.3.6/asserts → nextrec-0.4.1/assets}/logo.png +0 -0
- {nextrec-0.3.6/asserts → nextrec-0.4.1/assets}/mmoe_tutorial.png +0 -0
- {nextrec-0.3.6/asserts → nextrec-0.4.1/assets}/nextrec_diagram_en.png +0 -0
- {nextrec-0.3.6/asserts → nextrec-0.4.1/assets}/nextrec_diagram_zh.png +0 -0
- {nextrec-0.3.6/asserts → nextrec-0.4.1/assets}/test data.png +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/dataset/ctcvr_task.csv +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/dataset/match_task.csv +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/dataset/movielens_100k.csv +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/dataset/multitask_task.csv +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/dataset/ranking_task.csv +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/docs/en/Getting started guide.md +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/docs/rtd/Makefile +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/docs/rtd/index.md +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/docs/rtd/make.bat +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/docs/rtd/modules.rst +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/docs/rtd/nextrec.basic.rst +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/docs/rtd/nextrec.data.rst +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/docs/rtd/nextrec.loss.rst +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/docs/rtd/nextrec.rst +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/docs/rtd/nextrec.utils.rst +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/docs/rtd/requirements.txt +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/docs/zh//345/277/253/351/200/237/344/270/212/346/211/213.md" +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/__init__.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/basic/__init__.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/basic/activation.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/basic/callback.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/basic/features.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/basic/loggers.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/basic/metrics.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/basic/session.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/data/__init__.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/data/batch_utils.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/data/data_utils.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/data/preprocessor.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/loss/__init__.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/loss/listwise.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/loss/loss_utils.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/loss/pairwise.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/loss/pointwise.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/generative/__init__.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/generative/tiger.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/match/__init__.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/multi_task/__init__.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/ranking/__init__.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/models/ranking/dcn_v2.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/utils/embedding.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/utils/feature.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/utils/file.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/utils/initializer.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/utils/model.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/utils/optimizer.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/nextrec/utils/tensor.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/pytest.ini +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/requirements.txt +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/test/__init__.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/test/conftest.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/test/run_tests.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/test/test_match_models.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/test/test_multitask_models.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/test/test_preprocessor.py +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/test_requirements.txt +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/tutorials/notebooks/en/Hands on dataprocessor.ipynb +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/tutorials/notebooks/en/Hands on nextrec.ipynb +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/tutorials/notebooks/zh/Hands on dataprocessor.ipynb +0 -0
- {nextrec-0.3.6 → nextrec-0.4.1}/tutorials/notebooks/zh/Hands on nextrec.ipynb +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nextrec
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: A comprehensive recommendation library with match, ranking, and multi-task learning models
|
|
5
5
|
Project-URL: Homepage, https://github.com/zerolovesea/NextRec
|
|
6
6
|
Project-URL: Repository, https://github.com/zerolovesea/NextRec
|
|
@@ -55,7 +55,7 @@ Requires-Dist: seaborn>=0.12.0; extra == 'dev'
|
|
|
55
55
|
Description-Content-Type: text/markdown
|
|
56
56
|
|
|
57
57
|
<p align="center">
|
|
58
|
-
<img align="center" src="
|
|
58
|
+
<img align="center" src="assets/logo.png" width="40%">
|
|
59
59
|
<p>
|
|
60
60
|
|
|
61
61
|
<div align="center">
|
|
@@ -63,7 +63,7 @@ Description-Content-Type: text/markdown
|
|
|
63
63
|

|
|
64
64
|

|
|
65
65
|

|
|
66
|
-

|
|
67
67
|
|
|
68
68
|
English | [中文文档](README_zh.md)
|
|
69
69
|
|
|
@@ -86,7 +86,7 @@ NextRec is a modern recommendation framework built on PyTorch, delivering a unif
|
|
|
86
86
|
|
|
87
87
|
NextRec adopts a modular and low-coupling engineering design, enabling full-pipeline reusability and scalability across data processing → model construction → training & evaluation → inference & deployment. Its core components include: a Feature-Spec-driven Embedding architecture, the BaseModel abstraction, a set of independent reusable Layers, a unified DataLoader for both training and inference, and a ready-to-use Model Zoo.
|
|
88
88
|
|
|
89
|
-

|
|
90
90
|
|
|
91
91
|
> The project borrows ideas from excellent open-source rec libraries. Early layers referenced [torch-rechub](https://github.com/datawhalechina/torch-rechub) but have been replaced with in-house implementations. torch-rechub remains mature in architecture and models; the author contributed a bit there—feel free to check it out.
|
|
92
92
|
|
|
@@ -110,7 +110,7 @@ To dive deeper, Jupyter notebooks are available:
|
|
|
110
110
|
- [Hands on the NextRec framework](/tutorials/notebooks/en/Hands%20on%20nextrec.ipynb)
|
|
111
111
|
- [Using the data processor for preprocessing](/tutorials/notebooks/en/Hands%20on%20dataprocessor.ipynb)
|
|
112
112
|
|
|
113
|
-
> Current version [0.
|
|
113
|
+
> Current version [0.4.1]: the matching module is not fully polished yet and may have compatibility issues or unexpected errors. Please raise an issue if you run into problems.
|
|
114
114
|
|
|
115
115
|
## 5-Minute Quick Start
|
|
116
116
|
|
|
@@ -196,6 +196,16 @@ metrics = model.evaluate(
|
|
|
196
196
|
)
|
|
197
197
|
```
|
|
198
198
|
|
|
199
|
+
## Platform Compatibility
|
|
200
|
+
|
|
201
|
+
The current version is 0.4.1. All models and test code have been validated on the following platforms. If you encounter compatibility issues, please report them in the issue tracker with your system version:
|
|
202
|
+
|
|
203
|
+
| Platform | Configuration |
|
|
204
|
+
|----------|---------------|
|
|
205
|
+
| MacOS latest | MacBook Pro M4 Pro 24GB RAM |
|
|
206
|
+
| Ubuntu latest | AutoDL 4070D Dual GPU |
|
|
207
|
+
| CentOS 7 | Intel Xeon 5138Y 96 cores 377GB RAM |
|
|
208
|
+
|
|
199
209
|
---
|
|
200
210
|
|
|
201
211
|
## Supported Models
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img align="center" src="
|
|
2
|
+
<img align="center" src="assets/logo.png" width="40%">
|
|
3
3
|
<p>
|
|
4
4
|
|
|
5
5
|
<div align="center">
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|

|
|
8
8
|

|
|
9
9
|

|
|
10
|
-

|
|
11
11
|
|
|
12
12
|
English | [中文文档](README_zh.md)
|
|
13
13
|
|
|
@@ -30,7 +30,7 @@ NextRec is a modern recommendation framework built on PyTorch, delivering a unif
|
|
|
30
30
|
|
|
31
31
|
NextRec adopts a modular and low-coupling engineering design, enabling full-pipeline reusability and scalability across data processing → model construction → training & evaluation → inference & deployment. Its core components include: a Feature-Spec-driven Embedding architecture, the BaseModel abstraction, a set of independent reusable Layers, a unified DataLoader for both training and inference, and a ready-to-use Model Zoo.
|
|
32
32
|
|
|
33
|
-

|
|
34
34
|
|
|
35
35
|
> The project borrows ideas from excellent open-source rec libraries. Early layers referenced [torch-rechub](https://github.com/datawhalechina/torch-rechub) but have been replaced with in-house implementations. torch-rechub remains mature in architecture and models; the author contributed a bit there—feel free to check it out.
|
|
36
36
|
|
|
@@ -54,7 +54,7 @@ To dive deeper, Jupyter notebooks are available:
|
|
|
54
54
|
- [Hands on the NextRec framework](/tutorials/notebooks/en/Hands%20on%20nextrec.ipynb)
|
|
55
55
|
- [Using the data processor for preprocessing](/tutorials/notebooks/en/Hands%20on%20dataprocessor.ipynb)
|
|
56
56
|
|
|
57
|
-
> Current version [0.
|
|
57
|
+
> Current version [0.4.1]: the matching module is not fully polished yet and may have compatibility issues or unexpected errors. Please raise an issue if you run into problems.
|
|
58
58
|
|
|
59
59
|
## 5-Minute Quick Start
|
|
60
60
|
|
|
@@ -140,6 +140,16 @@ metrics = model.evaluate(
|
|
|
140
140
|
)
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
+
## Platform Compatibility
|
|
144
|
+
|
|
145
|
+
The current version is 0.4.1. All models and test code have been validated on the following platforms. If you encounter compatibility issues, please report them in the issue tracker with your system version:
|
|
146
|
+
|
|
147
|
+
| Platform | Configuration |
|
|
148
|
+
|----------|---------------|
|
|
149
|
+
| MacOS latest | MacBook Pro M4 Pro 24GB RAM |
|
|
150
|
+
| Ubuntu latest | AutoDL 4070D Dual GPU |
|
|
151
|
+
| CentOS 7 | Intel Xeon 5138Y 96 cores 377GB RAM |
|
|
152
|
+
|
|
143
153
|
---
|
|
144
154
|
|
|
145
155
|
## Supported Models
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img align="center" src="
|
|
2
|
+
<img align="center" src="assets/logo.png" width="40%">
|
|
3
3
|
<p>
|
|
4
4
|
|
|
5
5
|
<div align="center">
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|

|
|
8
8
|

|
|
9
9
|

|
|
10
|
-

|
|
11
11
|
|
|
12
12
|
[English Version](README.md) | 中文文档
|
|
13
13
|
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
## 简介
|
|
19
19
|
|
|
20
|
-
NextRec 是一个基于 PyTorch
|
|
20
|
+
NextRec 是一个基于 PyTorch 构建的现代推荐系统框架,为研究人员与工程团队提供统一的建模、训练与评估体验。框架采用模块化设计,内置丰富的模型实现、数据处理工具和工程化训练组件,可快速覆盖多种推荐场景,主要面向Spark集群下,基于大数据量parquet离线特征训练的工业推荐召回算法场景。
|
|
21
21
|
|
|
22
22
|
## Why NextRec
|
|
23
23
|
|
|
@@ -30,7 +30,7 @@ NextRec 是一个基于 PyTorch 构建的现代推荐系统框架,为研究人
|
|
|
30
30
|
|
|
31
31
|
NextRec采用模块化、低耦合的工程设计,使得推荐系统从数据处理 → 模型构建 → 训练评估 → 推理部署 全链路都具备复用性与可扩展性。其中的核心组件包括:Feature Spec驱动的Embedding架构;模型基类BaseModel;独立Layer模块;支持训练和推理的统一的DataLoader;开箱即用的模型库。
|
|
32
32
|
|
|
33
|
-

|
|
34
34
|
|
|
35
35
|
> 项目的架构借鉴了一些优秀的开源推荐算法库,其中最初版的layer层借鉴了DataWhaleChina社区的[torch-rechub](https://github.com/datawhalechina/torch-rechub),现已替换为了自有实现。torch-rechub在开发架构和模型实现上相对成熟,本人也参与了其中一小部分的维护,欢迎感兴趣的开发者前往了解。
|
|
36
36
|
|
|
@@ -54,7 +54,7 @@ NextRec采用模块化、低耦合的工程设计,使得推荐系统从数据
|
|
|
54
54
|
- [如何上手NextRec框架](/tutorials/notebooks/zh/Hands%20on%20nextrec.ipynb)
|
|
55
55
|
- [如何使用数据处理器进行数据预处理](/tutorials/notebooks/zh/Hands%20on%20dataprocessor.ipynb)
|
|
56
56
|
|
|
57
|
-
> 当前版本[0.
|
|
57
|
+
> 当前版本[0.4.1],召回模型模块尚不完善,可能存在一些兼容性问题或意外报错,如果遇到问题,欢迎开发者在Issue区提出问题。
|
|
58
58
|
|
|
59
59
|
## 5分钟快速上手
|
|
60
60
|
|
|
@@ -138,6 +138,15 @@ metrics = model.evaluate(
|
|
|
138
138
|
user_id_column='user_id'
|
|
139
139
|
)
|
|
140
140
|
```
|
|
141
|
+
## 兼容平台
|
|
142
|
+
|
|
143
|
+
当前最新版本为0.4.1,所有模型和测试代码均已在以下平台通过验证,如果开发者在使用中遇到兼容问题,请在issue区提出错误报告及系统版本:
|
|
144
|
+
|
|
145
|
+
| 平台 | 配置 |
|
|
146
|
+
|------|------|
|
|
147
|
+
| MacOS latest| MacBook Pro M4 Pro 24G内存 |
|
|
148
|
+
| Ubuntu latest| AutoDL 4070D 双卡 |
|
|
149
|
+
| CentOS 7 | Intel Xeon 5138Y 96核 377G内存 |
|
|
141
150
|
|
|
142
151
|
## 支持模型
|
|
143
152
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.4.1"
|
|
@@ -80,9 +80,7 @@ class PredictionLayer(nn.Module):
|
|
|
80
80
|
else:
|
|
81
81
|
raise ValueError(f"[PredictionLayer Error]: Unsupported task_type '{task_type}'.")
|
|
82
82
|
outputs.append(activation(task_logits))
|
|
83
|
-
result = torch.cat(outputs, dim=-1)
|
|
84
|
-
if result.shape[-1] == 1:
|
|
85
|
-
result = result.squeeze(-1)
|
|
83
|
+
result = torch.cat(outputs, dim=-1) # single: (N,1), multi-task/multi-class: (N,total_dim)
|
|
86
84
|
return result
|
|
87
85
|
|
|
88
86
|
class EmbeddingLayer(nn.Module):
|
|
@@ -235,14 +233,28 @@ class InputMask(nn.Module):
|
|
|
235
233
|
super().__init__()
|
|
236
234
|
|
|
237
235
|
def forward(self, x: dict[str, torch.Tensor], feature: SequenceFeature, seq_tensor: torch.Tensor | None = None):
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
mask = (values.long() != feature.padding_idx)
|
|
236
|
+
if seq_tensor is not None:
|
|
237
|
+
values = seq_tensor
|
|
241
238
|
else:
|
|
242
|
-
|
|
239
|
+
values = x[feature.name]
|
|
240
|
+
values = values.long()
|
|
241
|
+
padding_idx = feature.padding_idx if feature.padding_idx is not None else 0
|
|
242
|
+
mask = (values != padding_idx)
|
|
243
|
+
|
|
243
244
|
if mask.dim() == 1:
|
|
244
|
-
|
|
245
|
-
|
|
245
|
+
# [B] -> [B, 1, 1]
|
|
246
|
+
mask = mask.unsqueeze(1).unsqueeze(2)
|
|
247
|
+
elif mask.dim() == 2:
|
|
248
|
+
# [B, L] -> [B, 1, L]
|
|
249
|
+
mask = mask.unsqueeze(1)
|
|
250
|
+
elif mask.dim() == 3:
|
|
251
|
+
# [B, 1, L]
|
|
252
|
+
# [B, L, 1] -> [B, L] -> [B, 1, L]
|
|
253
|
+
if mask.size(1) != 1 and mask.size(2) == 1:
|
|
254
|
+
mask = mask.squeeze(-1).unsqueeze(1)
|
|
255
|
+
else:
|
|
256
|
+
raise ValueError(f"InputMask only supports 1D/2D/3D tensors, got shape {values.shape}")
|
|
257
|
+
return mask.float()
|
|
246
258
|
|
|
247
259
|
class LR(nn.Module):
|
|
248
260
|
def __init__(
|
|
@@ -299,20 +311,25 @@ class MLP(nn.Module):
|
|
|
299
311
|
super().__init__()
|
|
300
312
|
if dims is None:
|
|
301
313
|
dims = []
|
|
302
|
-
layers =
|
|
314
|
+
layers = []
|
|
315
|
+
current_dim = input_dim
|
|
316
|
+
|
|
303
317
|
for i_dim in dims:
|
|
304
|
-
layers.append(nn.Linear(
|
|
318
|
+
layers.append(nn.Linear(current_dim, i_dim))
|
|
305
319
|
layers.append(nn.BatchNorm1d(i_dim))
|
|
306
320
|
layers.append(activation_layer(activation))
|
|
307
321
|
layers.append(nn.Dropout(p=dropout))
|
|
308
|
-
|
|
322
|
+
current_dim = i_dim
|
|
323
|
+
|
|
309
324
|
if output_layer:
|
|
310
|
-
layers.append(nn.Linear(
|
|
325
|
+
layers.append(nn.Linear(current_dim, 1))
|
|
326
|
+
self.output_dim = 1
|
|
327
|
+
else:
|
|
328
|
+
self.output_dim = current_dim
|
|
311
329
|
self.mlp = nn.Sequential(*layers)
|
|
312
|
-
|
|
313
330
|
def forward(self, x):
|
|
314
331
|
return self.mlp(x)
|
|
315
|
-
|
|
332
|
+
|
|
316
333
|
class FM(nn.Module):
|
|
317
334
|
def __init__(self, reduce_sum: bool = True):
|
|
318
335
|
super().__init__()
|