nextrec 0.1.1__tar.gz → 0.1.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.
Files changed (95) hide show
  1. {nextrec-0.1.1 → nextrec-0.1.3}/PKG-INFO +7 -41
  2. {nextrec-0.1.1 → nextrec-0.1.3}/README.md +4 -38
  3. {nextrec-0.1.1 → nextrec-0.1.3}/README_zh.md +4 -39
  4. {nextrec-0.1.1 → nextrec-0.1.3}/docs/conf.py +13 -13
  5. nextrec-0.1.3/format_codes.sh +9 -0
  6. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/__init__.py +4 -4
  7. nextrec-0.1.3/nextrec/__version__.py +1 -0
  8. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/basic/activation.py +10 -9
  9. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/basic/callback.py +1 -0
  10. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/basic/dataloader.py +168 -127
  11. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/basic/features.py +24 -27
  12. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/basic/layers.py +328 -159
  13. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/basic/loggers.py +50 -37
  14. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/basic/metrics.py +255 -147
  15. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/basic/model.py +817 -462
  16. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/data/__init__.py +5 -5
  17. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/data/data_utils.py +16 -12
  18. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/data/preprocessor.py +276 -252
  19. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/loss/__init__.py +12 -12
  20. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/loss/loss_utils.py +30 -22
  21. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/loss/match_losses.py +116 -83
  22. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/match/__init__.py +5 -5
  23. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/match/dssm.py +70 -61
  24. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/match/dssm_v2.py +61 -51
  25. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/match/mind.py +89 -71
  26. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/match/sdm.py +93 -81
  27. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/match/youtube_dnn.py +62 -53
  28. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/multi_task/esmm.py +49 -43
  29. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/multi_task/mmoe.py +65 -56
  30. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/multi_task/ple.py +92 -65
  31. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/multi_task/share_bottom.py +48 -42
  32. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/ranking/__init__.py +7 -7
  33. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/ranking/afm.py +39 -30
  34. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/ranking/autoint.py +70 -57
  35. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/ranking/dcn.py +43 -35
  36. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/ranking/deepfm.py +34 -28
  37. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/ranking/dien.py +115 -79
  38. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/ranking/din.py +84 -60
  39. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/ranking/fibinet.py +51 -35
  40. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/ranking/fm.py +28 -26
  41. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/ranking/masknet.py +31 -31
  42. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/ranking/pnn.py +30 -31
  43. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/ranking/widedeep.py +36 -31
  44. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/ranking/xdeepfm.py +46 -39
  45. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/utils/__init__.py +9 -9
  46. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/utils/embedding.py +1 -1
  47. nextrec-0.1.3/nextrec/utils/initializer.py +55 -0
  48. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/utils/optimizer.py +14 -10
  49. {nextrec-0.1.1 → nextrec-0.1.3}/pyproject.toml +3 -3
  50. {nextrec-0.1.1 → nextrec-0.1.3}/requirements.txt +2 -2
  51. {nextrec-0.1.1 → nextrec-0.1.3}/test/conftest.py +61 -55
  52. {nextrec-0.1.1 → nextrec-0.1.3}/test/run_tests.py +44 -54
  53. {nextrec-0.1.1 → nextrec-0.1.3}/test/test_data_preprocessor.py +316 -321
  54. {nextrec-0.1.1 → nextrec-0.1.3}/test/test_dataloader.py +175 -183
  55. {nextrec-0.1.1 → nextrec-0.1.3}/test/test_layers.py +159 -186
  56. {nextrec-0.1.1 → nextrec-0.1.3}/test/test_match_models.py +330 -291
  57. {nextrec-0.1.1 → nextrec-0.1.3}/test/test_multitask_models.py +370 -252
  58. {nextrec-0.1.1 → nextrec-0.1.3}/test/test_ranking_models.py +516 -375
  59. {nextrec-0.1.1 → nextrec-0.1.3}/test/test_utils.py +52 -39
  60. {nextrec-0.1.1 → nextrec-0.1.3}/tutorials/example_match_dssm.py +42 -43
  61. {nextrec-0.1.1 → nextrec-0.1.3}/tutorials/example_multitask.py +35 -45
  62. {nextrec-0.1.1 → nextrec-0.1.3}/tutorials/example_ranking_din.py +30 -31
  63. {nextrec-0.1.1 → nextrec-0.1.3}/tutorials/movielen_match_dssm.py +70 -36
  64. {nextrec-0.1.1 → nextrec-0.1.3}/tutorials/movielen_ranking_deepfm.py +28 -17
  65. nextrec-0.1.1/nextrec/__version__.py +0 -1
  66. nextrec-0.1.1/nextrec/utils/initializer.py +0 -47
  67. {nextrec-0.1.1 → nextrec-0.1.3}/.github/workflows/publish.yml +0 -0
  68. {nextrec-0.1.1 → nextrec-0.1.3}/.github/workflows/tests.yml +0 -0
  69. {nextrec-0.1.1 → nextrec-0.1.3}/.gitignore +0 -0
  70. {nextrec-0.1.1 → nextrec-0.1.3}/.readthedocs.yaml +0 -0
  71. {nextrec-0.1.1 → nextrec-0.1.3}/CODE_OF_CONDUCT.md +0 -0
  72. {nextrec-0.1.1 → nextrec-0.1.3}/CONTRIBUTING.md +0 -0
  73. {nextrec-0.1.1 → nextrec-0.1.3}/LICENSE +0 -0
  74. {nextrec-0.1.1 → nextrec-0.1.3}/MANIFEST.in +0 -0
  75. {nextrec-0.1.1 → nextrec-0.1.3}/dataset/match_task.csv +0 -0
  76. {nextrec-0.1.1 → nextrec-0.1.3}/dataset/movielens_100k.csv +0 -0
  77. {nextrec-0.1.1 → nextrec-0.1.3}/dataset/multitask_task.csv +0 -0
  78. {nextrec-0.1.1 → nextrec-0.1.3}/dataset/ranking_task.csv +0 -0
  79. {nextrec-0.1.1 → nextrec-0.1.3}/docs/Makefile +0 -0
  80. {nextrec-0.1.1 → nextrec-0.1.3}/docs/index.rst +0 -0
  81. {nextrec-0.1.1 → nextrec-0.1.3}/docs/make.bat +0 -0
  82. {nextrec-0.1.1 → nextrec-0.1.3}/docs/modules.rst +0 -0
  83. {nextrec-0.1.1 → nextrec-0.1.3}/docs/nextrec.basic.rst +0 -0
  84. {nextrec-0.1.1 → nextrec-0.1.3}/docs/nextrec.data.rst +0 -0
  85. {nextrec-0.1.1 → nextrec-0.1.3}/docs/nextrec.loss.rst +0 -0
  86. {nextrec-0.1.1 → nextrec-0.1.3}/docs/nextrec.rst +0 -0
  87. {nextrec-0.1.1 → nextrec-0.1.3}/docs/nextrec.utils.rst +0 -0
  88. {nextrec-0.1.1 → nextrec-0.1.3}/docs/requirements.txt +0 -0
  89. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/basic/__init__.py +0 -0
  90. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/generative/hstu.py +0 -0
  91. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/models/generative/tiger.py +0 -0
  92. {nextrec-0.1.1 → nextrec-0.1.3}/nextrec/utils/common.py +0 -0
  93. {nextrec-0.1.1 → nextrec-0.1.3}/pytest.ini +0 -0
  94. {nextrec-0.1.1 → nextrec-0.1.3}/test/__init__.py +0 -0
  95. {nextrec-0.1.1 → nextrec-0.1.3}/test_requirements.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nextrec
3
- Version: 0.1.1
3
+ Version: 0.1.3
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
@@ -20,8 +20,8 @@ Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
21
  Requires-Python: >=3.10
22
22
  Requires-Dist: fastparquet>=2023.4.0
23
- Requires-Dist: numpy>=1.24.0
24
- Requires-Dist: pandas>=2.0.0
23
+ Requires-Dist: numpy>=1.23.0
24
+ Requires-Dist: pandas<2.3.0,>=2.1.0
25
25
  Requires-Dist: pyarrow>=12.0.0
26
26
  Requires-Dist: scikit-learn>=1.3.0
27
27
  Requires-Dist: scipy>=1.10.0
@@ -72,47 +72,13 @@ NextRec is a modern recommendation system framework built on PyTorch, providing
72
72
 
73
73
  ## Installation
74
74
 
75
- NextRec supports installation via **UV** or traditional **pip/source installation**.
76
-
77
- ### Option 1: Using UV (Recommended)
78
-
79
- UV is a modern, high-performance Python package manager offering fast dependency resolution and installation.
80
-
81
- ```bash
82
- git clone https://github.com/zerolovesea/NextRec.git
83
- cd NextRec
84
-
85
- # Install UV if not already installed
86
- pip install uv
87
-
88
- # Create virtual environment and install dependencies
89
- uv sync
90
-
91
- # Activate the virtual environment
92
- source .venv/bin/activate # macOS/Linux
93
- # or
94
- .venv\Scripts\activate # Windows
95
-
96
- # Install the package in editable mode
97
- uv pip install -e .
98
- ```
99
-
100
- **Note**: Make sure to deactivate any other conda/virtual environments before running `uv sync` to avoid environment conflicts.
101
-
102
- ### Option 2: Using pip/source installation
103
-
104
75
  ```bash
105
- git clone https://github.com/zerolovesea/NextRec.git
106
- cd NextRec
107
-
108
- # Install dependencies
109
- pip install -r requirements.txt
110
- pip install -r test_requirements.txt
76
+ # release version
77
+ pip install nextrec
111
78
 
112
- # Install the package in editable mode
113
- pip install -e .
79
+ # pre-release version
80
+ pip install -i https://test.pypi.org/simple/ nextrec
114
81
  ```
115
-
116
82
  ---
117
83
 
118
84
  ## 5-Minute Quick Start
@@ -30,47 +30,13 @@ NextRec is a modern recommendation system framework built on PyTorch, providing
30
30
 
31
31
  ## Installation
32
32
 
33
- NextRec supports installation via **UV** or traditional **pip/source installation**.
34
-
35
- ### Option 1: Using UV (Recommended)
36
-
37
- UV is a modern, high-performance Python package manager offering fast dependency resolution and installation.
38
-
39
- ```bash
40
- git clone https://github.com/zerolovesea/NextRec.git
41
- cd NextRec
42
-
43
- # Install UV if not already installed
44
- pip install uv
45
-
46
- # Create virtual environment and install dependencies
47
- uv sync
48
-
49
- # Activate the virtual environment
50
- source .venv/bin/activate # macOS/Linux
51
- # or
52
- .venv\Scripts\activate # Windows
53
-
54
- # Install the package in editable mode
55
- uv pip install -e .
56
- ```
57
-
58
- **Note**: Make sure to deactivate any other conda/virtual environments before running `uv sync` to avoid environment conflicts.
59
-
60
- ### Option 2: Using pip/source installation
61
-
62
33
  ```bash
63
- git clone https://github.com/zerolovesea/NextRec.git
64
- cd NextRec
65
-
66
- # Install dependencies
67
- pip install -r requirements.txt
68
- pip install -r test_requirements.txt
34
+ # release version
35
+ pip install nextrec
69
36
 
70
- # Install the package in editable mode
71
- pip install -e .
37
+ # pre-release version
38
+ pip install -i https://test.pypi.org/simple/ nextrec
72
39
  ```
73
-
74
40
  ---
75
41
 
76
42
  ## 5-Minute Quick Start
@@ -31,47 +31,12 @@ NextRec 是一个基于 PyTorch 构建的现代推荐系统框架,为研究人
31
31
 
32
32
  ## 安装
33
33
 
34
- NextRec 提供两种主流的安装方式UV与传统 pip/source 安装。
35
-
36
- #### 方法一:使用 UV(推荐)
37
-
38
- UV 是一款高速、现代化的 Python 包管理器,能够带来更快的依赖解析与安装体验。
39
-
40
34
  ```bash
41
- git clone https://github.com/zerolovesea/NextRec.git
42
- cd NextRec
43
-
44
- # 如果尚未安装 UV,先安装它
45
- pip install uv
46
-
47
- # 创建虚拟环境并安装依赖
48
- uv sync
49
-
50
- # 激活虚拟环境
51
- source .venv/bin/activate # macOS/Linux
52
- # 或
53
- .venv\Scripts\activate # Windows
54
-
55
- # 以可编辑模式安装包
56
- uv pip install -e .
57
- ```
58
-
59
- **注意**: 在运行 `uv sync` 之前,请确保退出其他 conda/虚拟环境,以避免环境冲突。
60
-
61
-
62
-
63
- #### 方法二:使用 pip/source
64
-
65
- ```bash
66
- git clone https://github.com/zerolovesea/NextRec.git
67
- cd NextRec
68
-
69
- # 安装依赖
70
- pip install -r requirements.txt
71
- pip install -r test_requirements.txt
35
+ # 正式版
36
+ pip install nextrec
72
37
 
73
- # 以可编辑模式安装包
74
- pip install -e .
38
+ # 测试版
39
+ pip install -i https://test.pypi.org/simple/ nextrec
75
40
  ```
76
41
 
77
42
  ## 5分钟快速上手
@@ -7,29 +7,29 @@
7
7
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
8
  import os
9
9
  import sys
10
- sys.path.insert(0, os.path.abspath('../nextrec'))
11
10
 
12
- project = 'NextRec'
13
- copyright = '2025, Yang Zhou'
14
- author = 'Yang Zhou'
15
- release = '0.1.1'
11
+ sys.path.insert(0, os.path.abspath("../nextrec"))
12
+
13
+ project = "NextRec"
14
+ copyright = "2025, Yang Zhou"
15
+ author = "Yang Zhou"
16
+ release = "0.1.3"
16
17
 
17
18
  # -- General configuration ---------------------------------------------------
18
19
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
19
20
 
20
21
  extensions = [
21
- 'sphinx.ext.autodoc',
22
- 'sphinx.ext.napoleon',
23
- 'sphinx_rtd_theme',
22
+ "sphinx.ext.autodoc",
23
+ "sphinx.ext.napoleon",
24
+ "sphinx_rtd_theme",
24
25
  ]
25
26
 
26
- templates_path = ['_templates']
27
- exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
28
-
27
+ templates_path = ["_templates"]
28
+ exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
29
29
 
30
30
 
31
31
  # -- Options for HTML output -------------------------------------------------
32
32
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
33
33
 
34
- html_theme = 'sphinx_rtd_theme'
35
- html_static_path = ['_static']
34
+ html_theme = "sphinx_rtd_theme"
35
+ html_static_path = ["_static"]
@@ -0,0 +1,9 @@
1
+ #!/bin/zsh
2
+
3
+ pip install -q black flake8
4
+
5
+ echo "Using black to format and lint Python files."
6
+ black .
7
+
8
+ echo "Using flake8 to lint all Python files..."
9
+ flake8 .
@@ -12,18 +12,18 @@ Quick Start
12
12
  -----------
13
13
  >>> from nextrec.basic.features import DenseFeature, SparseFeature
14
14
  >>> from nextrec.models.ranking.deepfm import DeepFM
15
- >>>
15
+ >>>
16
16
  >>> # Define features
17
17
  >>> dense_features = [DenseFeature('age')]
18
18
  >>> sparse_features = [SparseFeature('category', vocab_size=100, embedding_dim=16)]
19
- >>>
19
+ >>>
20
20
  >>> # Build model
21
21
  >>> model = DeepFM(
22
22
  ... dense_features=dense_features,
23
23
  ... sparse_features=sparse_features,
24
24
  ... targets=['label']
25
25
  ... )
26
- >>>
26
+ >>>
27
27
  >>> # Train model
28
28
  >>> model.fit(train_data=df_train, valid_data=df_valid)
29
29
  """
@@ -31,7 +31,7 @@ Quick Start
31
31
  from nextrec.__version__ import __version__
32
32
 
33
33
  __all__ = [
34
- '__version__',
34
+ "__version__",
35
35
  ]
36
36
 
37
37
  # Package metadata
@@ -0,0 +1 @@
1
+ __version__ = "0.1.3"
@@ -14,40 +14,41 @@ class Dice(nn.Module):
14
14
  """
15
15
  Dice activation function from the paper:
16
16
  "Deep Interest Network for Click-Through Rate Prediction" (Zhou et al., 2018)
17
-
17
+
18
18
  Dice(x) = p(x) * x + (1 - p(x)) * alpha * x
19
19
  where p(x) = sigmoid((x - E[x]) / sqrt(Var[x] + epsilon))
20
20
  """
21
+
21
22
  def __init__(self, emb_size: int, epsilon: float = 1e-9):
22
23
  super(Dice, self).__init__()
23
24
  self.epsilon = epsilon
24
25
  self.alpha = nn.Parameter(torch.zeros(emb_size))
25
26
  self.bn = nn.BatchNorm1d(emb_size)
26
-
27
+
27
28
  def forward(self, x):
28
29
  # x shape: (batch_size, emb_size) or (batch_size, seq_len, emb_size)
29
30
  original_shape = x.shape
30
-
31
+
31
32
  if x.dim() == 3:
32
33
  # For 3D input (batch_size, seq_len, emb_size), reshape to 2D
33
34
  batch_size, seq_len, emb_size = x.shape
34
35
  x = x.view(-1, emb_size)
35
-
36
+
36
37
  x_norm = self.bn(x)
37
38
  p = torch.sigmoid(x_norm)
38
39
  output = p * x + (1 - p) * self.alpha * x
39
-
40
+
40
41
  if len(original_shape) == 3:
41
42
  output = output.view(original_shape)
42
-
43
+
43
44
  return output
44
45
 
45
46
 
46
47
  def activation_layer(activation: str, emb_size: int | None = None):
47
48
  """Create an activation layer based on the given activation name."""
48
-
49
+
49
50
  activation = activation.lower()
50
-
51
+
51
52
  if activation == "dice":
52
53
  if emb_size is None:
53
54
  raise ValueError("emb_size is required for Dice activation")
@@ -89,4 +90,4 @@ def activation_layer(activation: str, emb_size: int | None = None):
89
90
  elif activation in ["none", "linear", "identity"]:
90
91
  return nn.Identity()
91
92
  else:
92
- raise ValueError(f"Unsupported activation function: {activation}")
93
+ raise ValueError(f"Unsupported activation function: {activation}")
@@ -8,6 +8,7 @@ Author:
8
8
 
9
9
  import copy
10
10
 
11
+
11
12
  class EarlyStopper(object):
12
13
  def __init__(self, patience: int = 20, mode: str = "max"):
13
14
  self.patience = patience