nextrec 0.4.20__tar.gz → 0.4.22__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 (178) hide show
  1. {nextrec-0.4.20 → nextrec-0.4.22}/.gitignore +1 -0
  2. {nextrec-0.4.20 → nextrec-0.4.22}/PKG-INFO +8 -6
  3. {nextrec-0.4.20 → nextrec-0.4.22}/README.md +5 -5
  4. {nextrec-0.4.20 → nextrec-0.4.22}/README_en.md +5 -4
  5. {nextrec-0.4.20 → nextrec-0.4.22}/docs/rtd/conf.py +1 -1
  6. {nextrec-0.4.20 → nextrec-0.4.22}/docs/rtd/index.md +2 -2
  7. nextrec-0.4.22/nextrec/__version__.py +1 -0
  8. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/basic/activation.py +9 -4
  9. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/basic/callback.py +39 -87
  10. nextrec-0.4.22/nextrec/basic/features.py +265 -0
  11. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/basic/heads.py +3 -1
  12. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/basic/layers.py +375 -94
  13. nextrec-0.4.22/nextrec/basic/loggers.py +414 -0
  14. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/basic/model.py +259 -326
  15. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/basic/session.py +2 -2
  16. nextrec-0.4.22/nextrec/basic/summary.py +323 -0
  17. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/cli.py +3 -3
  18. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/data/data_processing.py +45 -1
  19. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/data/dataloader.py +2 -2
  20. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/data/preprocessor.py +2 -2
  21. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/loss/__init__.py +0 -4
  22. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/loss/grad_norm.py +3 -3
  23. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/multi_task/esmm.py +4 -6
  24. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/multi_task/mmoe.py +4 -6
  25. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/multi_task/ple.py +6 -8
  26. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/multi_task/poso.py +5 -7
  27. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/multi_task/share_bottom.py +6 -8
  28. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/afm.py +4 -6
  29. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/autoint.py +4 -6
  30. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/dcn.py +8 -7
  31. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/dcn_v2.py +4 -6
  32. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/deepfm.py +5 -7
  33. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/dien.py +8 -7
  34. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/din.py +8 -7
  35. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/eulernet.py +5 -7
  36. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/ffm.py +5 -7
  37. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/fibinet.py +4 -6
  38. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/fm.py +4 -6
  39. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/lr.py +4 -6
  40. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/masknet.py +8 -9
  41. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/pnn.py +4 -6
  42. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/widedeep.py +5 -7
  43. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/xdeepfm.py +8 -7
  44. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/retrieval/dssm.py +4 -10
  45. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/retrieval/dssm_v2.py +0 -6
  46. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/retrieval/mind.py +4 -10
  47. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/retrieval/sdm.py +4 -10
  48. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/retrieval/youtube_dnn.py +4 -10
  49. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/sequential/hstu.py +1 -3
  50. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/utils/__init__.py +17 -15
  51. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/utils/config.py +15 -5
  52. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/utils/console.py +2 -2
  53. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/utils/feature.py +2 -2
  54. nextrec-0.4.20/nextrec/loss/loss_utils.py → nextrec-0.4.22/nextrec/utils/loss.py +21 -36
  55. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/utils/torch_utils.py +57 -112
  56. nextrec-0.4.22/nextrec/utils/types.py +63 -0
  57. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/NextRec-CLI.md +5 -5
  58. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/NextRec-CLI_zh.md +5 -5
  59. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/feature_config.yaml +5 -5
  60. {nextrec-0.4.20 → nextrec-0.4.22}/pyproject.toml +3 -1
  61. {nextrec-0.4.20 → nextrec-0.4.22}/requirements.txt +3 -0
  62. {nextrec-0.4.20 → nextrec-0.4.22}/test/conftest.py +3 -3
  63. {nextrec-0.4.20 → nextrec-0.4.22}/test/test_layers.py +63 -1
  64. {nextrec-0.4.20 → nextrec-0.4.22}/test/test_losses.py +54 -1
  65. {nextrec-0.4.20 → nextrec-0.4.22}/test/test_match_models.py +3 -3
  66. {nextrec-0.4.20 → nextrec-0.4.22}/test/test_ranking_models.py +7 -5
  67. {nextrec-0.4.20 → nextrec-0.4.22}/tutorials/movielen_ranking_deepfm.py +4 -2
  68. nextrec-0.4.22/tutorials/notebooks/en/Hands on nextrec.ipynb +1687 -0
  69. {nextrec-0.4.20 → nextrec-0.4.22}/tutorials/notebooks/zh//344/275/277/347/224/250RQ-VAE/346/236/204/345/273/272/350/257/255/344/271/211ID.ipynb +65 -46
  70. {nextrec-0.4.20 → nextrec-0.4.22}/tutorials/notebooks/zh//345/246/202/344/275/225/344/275/277/347/224/250DataProcessor/350/277/233/350/241/214/351/242/204/345/244/204/347/220/206.ipynb +115 -61
  71. nextrec-0.4.22/tutorials/notebooks/zh//345/277/253/351/200/237/345/205/245/351/227/250nextrec.ipynb +1987 -0
  72. {nextrec-0.4.20 → nextrec-0.4.22}/tutorials/run_all_ranking_models.py +6 -6
  73. nextrec-0.4.20/nextrec/__version__.py +0 -1
  74. nextrec-0.4.20/nextrec/basic/features.py +0 -144
  75. nextrec-0.4.20/nextrec/basic/loggers.py +0 -217
  76. nextrec-0.4.20/tutorials/notebooks/en/Hands on nextrec.ipynb +0 -1652
  77. nextrec-0.4.20/tutorials/notebooks/zh//345/277/253/351/200/237/345/205/245/351/227/250nextrec.ipynb +0 -1647
  78. {nextrec-0.4.20 → nextrec-0.4.22}/.github/workflows/publish.yml +0 -0
  79. {nextrec-0.4.20 → nextrec-0.4.22}/.github/workflows/tests.yml +0 -0
  80. {nextrec-0.4.20 → nextrec-0.4.22}/.readthedocs.yaml +0 -0
  81. {nextrec-0.4.20 → nextrec-0.4.22}/CODE_OF_CONDUCT.md +0 -0
  82. {nextrec-0.4.20 → nextrec-0.4.22}/CONTRIBUTING.md +0 -0
  83. {nextrec-0.4.20 → nextrec-0.4.22}/LICENSE +0 -0
  84. {nextrec-0.4.20 → nextrec-0.4.22}/MANIFEST.in +0 -0
  85. {nextrec-0.4.20 → nextrec-0.4.22}/assets/Feature Configuration.png +0 -0
  86. {nextrec-0.4.20 → nextrec-0.4.22}/assets/Model Parameters.png +0 -0
  87. {nextrec-0.4.20 → nextrec-0.4.22}/assets/Training Configuration.png +0 -0
  88. {nextrec-0.4.20 → nextrec-0.4.22}/assets/Training logs.png +0 -0
  89. {nextrec-0.4.20 → nextrec-0.4.22}/assets/logo.png +0 -0
  90. {nextrec-0.4.20 → nextrec-0.4.22}/assets/mmoe_tutorial.png +0 -0
  91. {nextrec-0.4.20 → nextrec-0.4.22}/assets/nextrec_diagram.png +0 -0
  92. {nextrec-0.4.20 → nextrec-0.4.22}/assets/test data.png +0 -0
  93. {nextrec-0.4.20 → nextrec-0.4.22}/dataset/ctcvr_task.csv +0 -0
  94. {nextrec-0.4.20 → nextrec-0.4.22}/dataset/ecommerce_task.csv +0 -0
  95. {nextrec-0.4.20 → nextrec-0.4.22}/dataset/match_task.csv +0 -0
  96. {nextrec-0.4.20 → nextrec-0.4.22}/dataset/movielens_100k.csv +0 -0
  97. {nextrec-0.4.20 → nextrec-0.4.22}/dataset/multitask_task.csv +0 -0
  98. {nextrec-0.4.20 → nextrec-0.4.22}/dataset/ranking_task.csv +0 -0
  99. {nextrec-0.4.20 → nextrec-0.4.22}/docs/en/Getting started guide.md +0 -0
  100. {nextrec-0.4.20 → nextrec-0.4.22}/docs/rtd/Makefile +0 -0
  101. {nextrec-0.4.20 → nextrec-0.4.22}/docs/rtd/make.bat +0 -0
  102. {nextrec-0.4.20 → nextrec-0.4.22}/docs/rtd/modules.rst +0 -0
  103. {nextrec-0.4.20 → nextrec-0.4.22}/docs/rtd/nextrec.basic.rst +0 -0
  104. {nextrec-0.4.20 → nextrec-0.4.22}/docs/rtd/nextrec.data.rst +0 -0
  105. {nextrec-0.4.20 → nextrec-0.4.22}/docs/rtd/nextrec.loss.rst +0 -0
  106. {nextrec-0.4.20 → nextrec-0.4.22}/docs/rtd/nextrec.rst +0 -0
  107. {nextrec-0.4.20 → nextrec-0.4.22}/docs/rtd/nextrec.utils.rst +0 -0
  108. {nextrec-0.4.20 → nextrec-0.4.22}/docs/rtd/requirements.txt +0 -0
  109. {nextrec-0.4.20 → nextrec-0.4.22}/docs/zh//345/277/253/351/200/237/344/270/212/346/211/213.md" +0 -0
  110. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/__init__.py +0 -0
  111. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/basic/__init__.py +0 -0
  112. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/basic/metrics.py +0 -0
  113. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/data/__init__.py +0 -0
  114. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/data/batch_utils.py +0 -0
  115. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/data/data_utils.py +0 -0
  116. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/loss/listwise.py +0 -0
  117. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/loss/pairwise.py +0 -0
  118. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/loss/pointwise.py +0 -0
  119. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/generative/__init__.py +0 -0
  120. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/generative/tiger.py +0 -0
  121. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/multi_task/__init__.py +0 -0
  122. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/ranking/__init__.py +0 -0
  123. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/representation/__init__.py +0 -0
  124. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/representation/autorec.py +0 -0
  125. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/representation/bpr.py +0 -0
  126. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/representation/cl4srec.py +0 -0
  127. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/representation/lightgcn.py +0 -0
  128. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/representation/mf.py +0 -0
  129. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/representation/rqvae.py +0 -0
  130. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/representation/s3rec.py +0 -0
  131. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/retrieval/__init__.py +0 -0
  132. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/models/sequential/sasrec.py +0 -0
  133. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/utils/data.py +0 -0
  134. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/utils/embedding.py +0 -0
  135. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec/utils/model.py +0 -0
  136. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/afm.yaml +0 -0
  137. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/autoint.yaml +0 -0
  138. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/dcn.yaml +0 -0
  139. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/deepfm.yaml +0 -0
  140. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/din.yaml +0 -0
  141. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/esmm.yaml +0 -0
  142. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/fibinet.yaml +0 -0
  143. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/fm.yaml +0 -0
  144. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/masknet.yaml +0 -0
  145. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/mmoe.yaml +0 -0
  146. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/ple.yaml +0 -0
  147. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/pnn.yaml +0 -0
  148. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/poso.yaml +0 -0
  149. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/share_bottom.yaml +0 -0
  150. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/widedeep.yaml +0 -0
  151. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/model_configs/xdeepfm.yaml +0 -0
  152. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/predict_config.yaml +0 -0
  153. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/predict_config_template.yaml +0 -0
  154. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/train_config.yaml +0 -0
  155. {nextrec-0.4.20 → nextrec-0.4.22}/nextrec_cli_preset/train_config_template.yaml +0 -0
  156. {nextrec-0.4.20 → nextrec-0.4.22}/pytest.ini +0 -0
  157. {nextrec-0.4.20 → nextrec-0.4.22}/scripts/format_code.py +0 -0
  158. {nextrec-0.4.20 → nextrec-0.4.22}/test/__init__.py +0 -0
  159. {nextrec-0.4.20 → nextrec-0.4.22}/test/helpers.py +0 -0
  160. {nextrec-0.4.20 → nextrec-0.4.22}/test/run_tests.py +0 -0
  161. {nextrec-0.4.20 → nextrec-0.4.22}/test/test_base_model_regularization.py +0 -0
  162. {nextrec-0.4.20 → nextrec-0.4.22}/test/test_generative_models.py +0 -0
  163. {nextrec-0.4.20 → nextrec-0.4.22}/test/test_multitask_models.py +0 -0
  164. {nextrec-0.4.20 → nextrec-0.4.22}/test/test_preprocessor.py +0 -0
  165. {nextrec-0.4.20 → nextrec-0.4.22}/test/test_utils_console.py +0 -0
  166. {nextrec-0.4.20 → nextrec-0.4.22}/test/test_utils_data.py +0 -0
  167. {nextrec-0.4.20 → nextrec-0.4.22}/test/test_utils_embedding.py +0 -0
  168. {nextrec-0.4.20 → nextrec-0.4.22}/test_requirements.txt +0 -0
  169. {nextrec-0.4.20 → nextrec-0.4.22}/tutorials/distributed/example_distributed_training.py +0 -0
  170. {nextrec-0.4.20 → nextrec-0.4.22}/tutorials/distributed/example_distributed_training_large_dataset.py +0 -0
  171. {nextrec-0.4.20 → nextrec-0.4.22}/tutorials/example_match.py +0 -0
  172. {nextrec-0.4.20 → nextrec-0.4.22}/tutorials/example_multitask.py +0 -0
  173. {nextrec-0.4.20 → nextrec-0.4.22}/tutorials/example_ranking_din.py +0 -0
  174. {nextrec-0.4.20 → nextrec-0.4.22}/tutorials/movielen_match_dssm.py +0 -0
  175. {nextrec-0.4.20 → nextrec-0.4.22}/tutorials/notebooks/en/Build semantic ID with RQ-VAE.ipynb +0 -0
  176. {nextrec-0.4.20 → nextrec-0.4.22}/tutorials/notebooks/en/Hands on dataprocessor.ipynb +0 -0
  177. {nextrec-0.4.20 → nextrec-0.4.22}/tutorials/run_all_match_models.py +0 -0
  178. {nextrec-0.4.20 → nextrec-0.4.22}/tutorials/run_all_multitask_models.py +0 -0
@@ -72,6 +72,7 @@ uv.lock
72
72
  logs/
73
73
  *.log
74
74
  nextrec_logs/
75
+ swanlog/
75
76
 
76
77
  # Checkpoints
77
78
  checkpoints/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nextrec
3
- Version: 0.4.20
3
+ Version: 0.4.22
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
@@ -42,9 +42,11 @@ Requires-Dist: scipy<1.12,>=1.8; sys_platform == 'linux' and python_version < '3
42
42
  Requires-Dist: scipy>=1.10.0; sys_platform == 'darwin'
43
43
  Requires-Dist: scipy>=1.10.0; sys_platform == 'win32'
44
44
  Requires-Dist: scipy>=1.11.0; sys_platform == 'linux' and python_version >= '3.12'
45
+ Requires-Dist: swanlab>=0.7.2
45
46
  Requires-Dist: torch>=2.0.0
46
47
  Requires-Dist: torchvision>=0.15.0
47
48
  Requires-Dist: transformers>=4.38.0
49
+ Requires-Dist: wandb>=0.23.1
48
50
  Provides-Extra: dev
49
51
  Requires-Dist: jupyter>=1.0.0; extra == 'dev'
50
52
  Requires-Dist: matplotlib>=3.7.0; extra == 'dev'
@@ -63,11 +65,11 @@ Description-Content-Type: text/markdown
63
65
 
64
66
  <div align="center">
65
67
 
66
- [![PyPI Downloads](https://static.pepy.tech/personalized-badge/nextrec?period=total&units=NONE&left_color=BLACK&right_color=GREEN&left_text=PyPI-downloads)](https://pypistats.org/packages/nextrec)
68
+ [![PyPI Downloads](https://static.pepy.tech/personalized-badge/nextrec?period=total&units=NONE&left_color=grey&right_color=GREEN&left_text=PyPI-downloads)](https://pypistats.org/packages/nextrec)
67
69
  ![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)
68
70
  ![PyTorch](https://img.shields.io/badge/PyTorch-1.10+-ee4c2c.svg)
69
71
  ![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)
70
- ![Version](https://img.shields.io/badge/Version-0.4.20-orange.svg)
72
+ ![Version](https://img.shields.io/badge/Version-0.4.22-orange.svg)
71
73
  [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/zerolovesea/NextRec)
72
74
 
73
75
  中文文档 | [English Version](README_en.md)
@@ -100,7 +102,7 @@ NextRec是一个基于PyTorch的现代推荐系统框架,旨在为研究工程
100
102
  - **高效训练与评估**:内置多种优化器、学习率调度、早停、模型检查点与详细的日志管理,开箱即用。
101
103
 
102
104
  ## NextRec近期进展
103
-
105
+ - **28/12/2025** 在v0.4.21中加入了对SwanLab和Wandb的支持,通过model的`fit`方法进行配置:`use_swanlab=True, swanlab_kwargs={"project": "NextRec","name":"tutorial_movielens_deepfm"},`
104
106
  - **21/12/2025** 在v0.4.16中加入了对[GradNorm](/nextrec/loss/grad_norm.py)的支持,通过compile的`loss_weight='grad_norm'`进行配置
105
107
  - **12/12/2025** 在v0.4.9中加入了[RQ-VAE](/nextrec/models/representation/rqvae.py)模块。配套的[数据集](/dataset/ecommerce_task.csv)和[代码](tutorials/notebooks/zh/使用RQ-VAE构建语义ID.ipynb)已经同步在仓库中
106
108
  - **07/12/2025** 发布了NextRec CLI命令行工具,它允许用户根据配置文件进行一键训练和推理,我们提供了相关的[教程](/nextrec_cli_preset/NextRec-CLI_zh.md)和[教学代码](/nextrec_cli_preset)
@@ -245,11 +247,11 @@ nextrec --mode=predict --predict_config=path/to/predict_config.yaml
245
247
 
246
248
  预测结果固定保存到 `{checkpoint_path}/predictions/{name}.{save_data_format}`。
247
249
 
248
- > 截止当前版本0.4.20,NextRec CLI支持单机训练,分布式训练相关功能尚在开发中。
250
+ > 截止当前版本0.4.22,NextRec CLI支持单机训练,分布式训练相关功能尚在开发中。
249
251
 
250
252
  ## 兼容平台
251
253
 
252
- 当前最新版本为0.4.20,所有模型和测试代码均已在以下平台通过验证,如果开发者在使用中遇到兼容问题,请在issue区提出错误报告及系统版本:
254
+ 当前最新版本为0.4.22,所有模型和测试代码均已在以下平台通过验证,如果开发者在使用中遇到兼容问题,请在issue区提出错误报告及系统版本:
253
255
 
254
256
  | 平台 | 配置 |
255
257
  |------|------|
@@ -4,11 +4,11 @@
4
4
 
5
5
  <div align="center">
6
6
 
7
- [![PyPI Downloads](https://static.pepy.tech/personalized-badge/nextrec?period=total&units=NONE&left_color=BLACK&right_color=GREEN&left_text=PyPI-downloads)](https://pypistats.org/packages/nextrec)
7
+ [![PyPI Downloads](https://static.pepy.tech/personalized-badge/nextrec?period=total&units=NONE&left_color=grey&right_color=GREEN&left_text=PyPI-downloads)](https://pypistats.org/packages/nextrec)
8
8
  ![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)
9
9
  ![PyTorch](https://img.shields.io/badge/PyTorch-1.10+-ee4c2c.svg)
10
10
  ![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)
11
- ![Version](https://img.shields.io/badge/Version-0.4.20-orange.svg)
11
+ ![Version](https://img.shields.io/badge/Version-0.4.22-orange.svg)
12
12
  [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/zerolovesea/NextRec)
13
13
 
14
14
  中文文档 | [English Version](README_en.md)
@@ -41,7 +41,7 @@ NextRec是一个基于PyTorch的现代推荐系统框架,旨在为研究工程
41
41
  - **高效训练与评估**:内置多种优化器、学习率调度、早停、模型检查点与详细的日志管理,开箱即用。
42
42
 
43
43
  ## NextRec近期进展
44
-
44
+ - **28/12/2025** 在v0.4.21中加入了对SwanLab和Wandb的支持,通过model的`fit`方法进行配置:`use_swanlab=True, swanlab_kwargs={"project": "NextRec","name":"tutorial_movielens_deepfm"},`
45
45
  - **21/12/2025** 在v0.4.16中加入了对[GradNorm](/nextrec/loss/grad_norm.py)的支持,通过compile的`loss_weight='grad_norm'`进行配置
46
46
  - **12/12/2025** 在v0.4.9中加入了[RQ-VAE](/nextrec/models/representation/rqvae.py)模块。配套的[数据集](/dataset/ecommerce_task.csv)和[代码](tutorials/notebooks/zh/使用RQ-VAE构建语义ID.ipynb)已经同步在仓库中
47
47
  - **07/12/2025** 发布了NextRec CLI命令行工具,它允许用户根据配置文件进行一键训练和推理,我们提供了相关的[教程](/nextrec_cli_preset/NextRec-CLI_zh.md)和[教学代码](/nextrec_cli_preset)
@@ -186,11 +186,11 @@ nextrec --mode=predict --predict_config=path/to/predict_config.yaml
186
186
 
187
187
  预测结果固定保存到 `{checkpoint_path}/predictions/{name}.{save_data_format}`。
188
188
 
189
- > 截止当前版本0.4.20,NextRec CLI支持单机训练,分布式训练相关功能尚在开发中。
189
+ > 截止当前版本0.4.22,NextRec CLI支持单机训练,分布式训练相关功能尚在开发中。
190
190
 
191
191
  ## 兼容平台
192
192
 
193
- 当前最新版本为0.4.20,所有模型和测试代码均已在以下平台通过验证,如果开发者在使用中遇到兼容问题,请在issue区提出错误报告及系统版本:
193
+ 当前最新版本为0.4.22,所有模型和测试代码均已在以下平台通过验证,如果开发者在使用中遇到兼容问题,请在issue区提出错误报告及系统版本:
194
194
 
195
195
  | 平台 | 配置 |
196
196
  |------|------|
@@ -4,11 +4,11 @@
4
4
 
5
5
  <div align="center">
6
6
 
7
- [![PyPI Downloads](https://static.pepy.tech/personalized-badge/nextrec?period=total&units=NONE&left_color=BLACK&right_color=GREEN&left_text=PyPI-downloads)](https://pypistats.org/packages/nextrec)
7
+ [![PyPI Downloads](https://static.pepy.tech/personalized-badge/nextrec?period=total&units=NONE&left_color=grey&right_color=GREEN&left_text=PyPI-downloads)](https://pypistats.org/packages/nextrec)
8
8
  ![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)
9
9
  ![PyTorch](https://img.shields.io/badge/PyTorch-1.10+-ee4c2c.svg)
10
10
  ![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)
11
- ![Version](https://img.shields.io/badge/Version-0.4.20-orange.svg)
11
+ ![Version](https://img.shields.io/badge/Version-0.4.22-orange.svg)
12
12
  [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/zerolovesea/NextRec)
13
13
 
14
14
  English | [中文文档](README.md)
@@ -44,6 +44,7 @@ NextRec is a modern recommendation framework built on PyTorch, delivering a unif
44
44
 
45
45
  ## NextRec Progress
46
46
 
47
+ - **28/12/2025** Added support for SwanLab and Weights & Biases in v0.4.21, configurable via the model `fit` method: `use_swanlab=True, swanlab_kwargs={"project": "NextRec","name":"tutorial_movielens_deepfm"},`
47
48
  - **21/12/2025** Added support for [GradNorm](/nextrec/loss/grad_norm.py) in v0.4.16, configurable via `loss_weight='grad_norm'` in the compile method
48
49
  - **12/12/2025** Added [RQ-VAE](/nextrec/models/representation/rqvae.py), a common module for generative retrieval in v0.4.9. Paired [dataset](/dataset/ecommerce_task.csv) and [notebook code](tutorials/notebooks/en/Build%20semantic%20ID%20with%20RQ-VAE.ipynb) are available.
49
50
  - **07/12/2025** Released the NextRec CLI tool to run training/inference from configs. See the [guide](/nextrec_cli_preset/NextRec-CLI.md) and [reference code](/nextrec_cli_preset).
@@ -190,11 +191,11 @@ nextrec --mode=predict --predict_config=path/to/predict_config.yaml
190
191
 
191
192
  Prediction outputs are saved under `{checkpoint_path}/predictions/{name}.{save_data_format}`.
192
193
 
193
- > As of version 0.4.20, NextRec CLI supports single-machine training; distributed training features are currently under development.
194
+ > As of version 0.4.22, NextRec CLI supports single-machine training; distributed training features are currently under development.
194
195
 
195
196
  ## Platform Compatibility
196
197
 
197
- The current version is 0.4.20. 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:
198
+ The current version is 0.4.22. 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:
198
199
 
199
200
  | Platform | Configuration |
200
201
  |----------|---------------|
@@ -11,7 +11,7 @@ sys.path.insert(0, str(PROJECT_ROOT / "nextrec"))
11
11
  project = "NextRec"
12
12
  copyright = "2025, Yang Zhou"
13
13
  author = "Yang Zhou"
14
- release = "0.4.20"
14
+ release = "0.4.22"
15
15
 
16
16
  extensions = [
17
17
  "myst_parser",
@@ -70,7 +70,7 @@ model.fit(
70
70
  batch_size=512,
71
71
  shuffle=True,
72
72
  verbose=1,
73
- validation_split=0.1,
73
+ valid_split=0.1,
74
74
  )
75
75
 
76
76
  preds = model.predict(df)
@@ -121,7 +121,7 @@ model.fit(
121
121
  batch_size=256,
122
122
  shuffle=True,
123
123
  verbose=1,
124
- validation_split=0.1, # auto split when valid_data is None
124
+ valid_split=0.1, # auto split when valid_data is None
125
125
  )
126
126
 
127
127
  scores = model.evaluate(valid_df_or_loader) # returns metric dict
@@ -0,0 +1 @@
1
+ __version__ = "0.4.22"
@@ -1,8 +1,8 @@
1
1
  """
2
- Activation function definitions
2
+ Activation function definitions for NextRec models.
3
3
 
4
4
  Date: create on 27/10/2025
5
- Checkpoint: edit on 29/11/2025
5
+ Checkpoint: edit on 28/12/2025
6
6
  Author: Yang Zhou, zyaztec@gmail.com
7
7
  """
8
8
 
@@ -10,6 +10,9 @@ import torch
10
10
  import torch.nn as nn
11
11
 
12
12
 
13
+ from nextrec.utils.types import ActivationName
14
+
15
+
13
16
  class Dice(nn.Module):
14
17
  """
15
18
  Dice activation function from the paper:
@@ -41,9 +44,11 @@ class Dice(nn.Module):
41
44
  return output
42
45
 
43
46
 
44
- def activation_layer(activation: str, emb_size: int | None = None):
47
+ def activation_layer(
48
+ activation: ActivationName = "none",
49
+ emb_size: int | None = None,
50
+ ):
45
51
  """Create an activation layer based on the given activation name."""
46
- activation = activation.lower()
47
52
  if activation == "dice":
48
53
  if emb_size is None:
49
54
  raise ValueError(
@@ -2,7 +2,7 @@
2
2
  Callback System for Training Process
3
3
 
4
4
  Date: create on 27/10/2025
5
- Checkpoint: edit on 19/12/2025
5
+ Checkpoint: edit on 27/12/2025
6
6
  Author: Yang Zhou, zyaztec@gmail.com
7
7
  """
8
8
 
@@ -61,16 +61,16 @@ class Callback:
61
61
  self.params = params
62
62
 
63
63
  def should_run(self) -> bool:
64
- if not getattr(self, "run_on_main_process_only", False):
64
+ if not self.run_on_main_process_only:
65
65
  return True
66
- model = getattr(self, "model", None)
67
- if model is None:
68
- return True
69
- return bool(getattr(model, "is_main_process", True))
66
+ model = self.model
67
+ return bool(model.is_main_process)
70
68
 
71
69
 
72
70
  class CallbackList:
73
- """Generates a list of callbacks"""
71
+ """
72
+ Generates a list of callbacks
73
+ """
74
74
 
75
75
  def __init__(self, callbacks: Optional[list[Callback]] = None):
76
76
  self.callbacks = callbacks or []
@@ -85,7 +85,8 @@ class CallbackList:
85
85
  getattr(callback, fn_name)(*args, **kwargs)
86
86
 
87
87
  def set_model(self, model):
88
- self.call("set_model", model)
88
+ for callback in self.callbacks:
89
+ callback.set_model(model)
89
90
 
90
91
  def set_params(self, params: dict):
91
92
  self.call("set_params", params)
@@ -194,9 +195,8 @@ class EarlyStopper(Callback):
194
195
  self.wait += 1
195
196
  if self.wait >= self.patience:
196
197
  self.stopped_epoch = epoch
197
- if hasattr(self.model, "stop_training"):
198
- self.model.stop_training = True
199
- if self.verbose > 0:
198
+ self.model.stop_training = True
199
+ if self.verbose == 1:
200
200
  logging.info(
201
201
  f"Early stopping triggered at epoch {epoch + 1}. "
202
202
  f"Best {self.monitor}: {self.best_value:.6f} at epoch {self.best_epoch + 1}"
@@ -218,14 +218,15 @@ class EarlyStopper(Callback):
218
218
 
219
219
 
220
220
  class CheckpointSaver(Callback):
221
- """Callback to save model checkpoints during training.
221
+ """
222
+ Callback to save model checkpoints during training.
222
223
 
223
224
  Args:
224
225
  save_path: Path to save checkpoints.
225
226
  monitor: Metric name to monitor for saving best model.
226
227
  mode: One of {'min', 'max'}.
227
228
  save_best_only: If True, only save when the model is considered the "best".
228
- save_freq: Frequency of checkpoint saving ('epoch' or integer for every N epochs).
229
+ save_freq: Frequency of checkpoint saving (integer for every N epochs).
229
230
  verbose: Verbosity mode.
230
231
  run_on_main_process_only: Whether to run this callback only on the main process in DDP.
231
232
  """
@@ -237,7 +238,7 @@ class CheckpointSaver(Callback):
237
238
  monitor: str = "val_auc",
238
239
  mode: str = "max",
239
240
  save_best_only: bool = False,
240
- save_freq: str | int = "epoch",
241
+ save_freq: int = 1,
241
242
  verbose: int = 1,
242
243
  run_on_main_process_only: bool = True,
243
244
  ):
@@ -272,7 +273,7 @@ class CheckpointSaver(Callback):
272
273
  logs = logs or {}
273
274
 
274
275
  should_save = False
275
- if self.save_freq == "epoch":
276
+ if self.save_freq == 1:
276
277
  should_save = True
277
278
  elif isinstance(self.save_freq, int) and (epoch + 1) % self.save_freq == 0:
278
279
  should_save = True
@@ -306,12 +307,10 @@ class CheckpointSaver(Callback):
306
307
 
307
308
  def save_checkpoint(self, path: Path, epoch: int, logs: dict):
308
309
 
309
- # Get the actual model (unwrap DDP if needed)
310
- model_to_save = (
311
- self.model.ddp_model.module
312
- if getattr(self.model, "ddp_model", None) is not None
313
- else self.model
314
- )
310
+ if hasattr(self.model, "ddp_model") and self.model.ddp_model is not None:
311
+ model_to_save = self.model.ddp_model.module
312
+ else:
313
+ model_to_save = self.model
315
314
 
316
315
  # Save only state_dict to match BaseModel.save_model() format
317
316
  torch.save(model_to_save.state_dict(), path)
@@ -328,12 +327,13 @@ class CheckpointSaver(Callback):
328
327
  with open(config_path, "wb") as f:
329
328
  pickle.dump(features_config, f)
330
329
 
331
- if self.verbose > 1:
330
+ if self.verbose == 1:
332
331
  logging.info(f"Saved checkpoint to {path}")
333
332
 
334
333
 
335
334
  class LearningRateScheduler(Callback):
336
- """Callback for learning rate scheduling.
335
+ """
336
+ Callback for learning rate scheduling.
337
337
 
338
338
  Args:
339
339
  scheduler: Learning rate scheduler instance or name.
@@ -346,73 +346,25 @@ class LearningRateScheduler(Callback):
346
346
  self.verbose = verbose
347
347
 
348
348
  def on_train_begin(self, logs: Optional[dict] = None):
349
- if self.scheduler is None and hasattr(self.model, "scheduler_fn"):
349
+ if self.scheduler is None:
350
350
  self.scheduler = self.model.scheduler_fn
351
351
 
352
352
  def on_epoch_end(self, epoch: int, logs: Optional[dict] = None):
353
353
  if self.scheduler is not None:
354
- # Get current lr before step
355
- if hasattr(self.model, "optimizer_fn"):
356
- old_lr = self.model.optimizer_fn.param_groups[0]["lr"]
357
-
358
- # Step the scheduler
359
- if hasattr(self.scheduler, "step"):
360
- # Some schedulers need metrics
361
- if logs is None:
362
- logs = {}
363
- if "val_loss" in logs and hasattr(self.scheduler, "mode"):
364
- self.scheduler.step(logs["val_loss"])
365
- else:
366
- self.scheduler.step()
354
+ old_lr = self.model.optimizer_fn.param_groups[0]["lr"]
355
+ if logs is None:
356
+ logs = {}
367
357
 
368
- # Log new lr
369
- if self.verbose > 0 and hasattr(self.model, "optimizer_fn"):
370
- if getattr(self.model, "is_main_process", True):
371
- new_lr = self.model.optimizer_fn.param_groups[0]["lr"]
372
- if new_lr != old_lr:
373
- logging.info(
374
- f"Learning rate changed from {old_lr:.6e} to {new_lr:.6e}"
375
- )
358
+ # step for ReduceLROnPlateau
359
+ if "val_loss" in logs and hasattr(self.scheduler, "mode"):
360
+ self.scheduler.step(logs["val_loss"])
361
+ else:
362
+ self.scheduler.step()
376
363
 
377
-
378
- class MetricsLogger(Callback):
379
- """Callback for logging training metrics.
380
-
381
- Args:
382
- log_freq: Frequency of logging ('epoch', 'batch', or integer for every N epochs/batches).
383
- verbose: Verbosity mode.
384
- """
385
-
386
- def __init__(self, log_freq: str | int = "epoch", verbose: int = 1):
387
- super().__init__()
388
- self.run_on_main_process_only = True
389
- self.log_freq = log_freq
390
- self.verbose = verbose
391
-
392
- def on_epoch_end(self, epoch: int, logs: Optional[dict] = None):
393
- if self.verbose > 0 and (
394
- self.log_freq == "epoch"
395
- or (isinstance(self.log_freq, int) and (epoch + 1) % self.log_freq == 0)
396
- ):
397
- logs = logs or {}
398
- metrics_str = " - ".join(
399
- [
400
- f"{k}: {v:.6f}" if isinstance(v, float) else f"{k}: {v}"
401
- for k, v in logs.items()
402
- ]
403
- )
404
- logging.info(f"Epoch {epoch + 1}: {metrics_str}")
405
-
406
- def on_batch_end(self, batch: int, logs: Optional[dict] = None):
407
- if self.verbose > 1 and (
408
- self.log_freq == "batch"
409
- or (isinstance(self.log_freq, int) and (batch + 1) % self.log_freq == 0)
410
- ):
411
- logs = logs or {}
412
- metrics_str = " - ".join(
413
- [
414
- f"{k}: {v:.6f}" if isinstance(v, float) else f"{k}: {v}"
415
- for k, v in logs.items()
416
- ]
417
- )
418
- logging.info(f"Batch {batch}: {metrics_str}")
364
+ # Log new lr
365
+ if self.verbose == 1:
366
+ new_lr = self.model.optimizer_fn.param_groups[0]["lr"]
367
+ if new_lr != old_lr:
368
+ logging.info(
369
+ f"Learning rate changed from {old_lr:.6e} to {new_lr:.6e}"
370
+ )