nextrec 0.4.13__py3-none-any.whl → 0.4.14__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.
nextrec/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.4.13"
1
+ __version__ = "0.4.14"
nextrec/basic/model.py CHANGED
@@ -341,7 +341,7 @@ class BaseModel(FeatureSet, nn.Module):
341
341
  )
342
342
  else:
343
343
  raise TypeError(
344
- f"[BaseModel-validation Error] train_data must be a pandas DataFrame or a dict, got {type(train_data)}"
344
+ f"[BaseModel-validation Error] If you want to use validation_split, train_data must be a pandas DataFrame or a dict instead of {type(train_data)}"
345
345
  )
346
346
  rng = np.random.default_rng(42)
347
347
  indices = rng.permutation(total_length)
@@ -481,7 +481,7 @@ class BaseModel(FeatureSet, nn.Module):
481
481
  "[BaseModel-compile Error] loss_weights list must have exactly one element for single-task setup."
482
482
  )
483
483
  loss_weights = loss_weights[0]
484
- self.loss_weights = [float(loss_weights)]
484
+ self.loss_weights = [float(loss_weights)] # type: ignore
485
485
  else:
486
486
  if isinstance(loss_weights, (int, float)):
487
487
  weights = [float(loss_weights)] * self.nums_task
@@ -555,13 +555,13 @@ class BaseModel(FeatureSet, nn.Module):
555
555
 
556
556
  def prepare_data_loader(
557
557
  self,
558
- data: dict | pd.DataFrame | DataLoader,
558
+ data,
559
559
  batch_size: int = 32,
560
560
  shuffle: bool = True,
561
561
  num_workers: int = 0,
562
562
  sampler=None,
563
563
  return_dataset: bool = False,
564
- ) -> DataLoader | tuple[DataLoader, TensorDictDataset | None]:
564
+ ):
565
565
  """
566
566
  Prepare a DataLoader from input data. Only used when input data is not a DataLoader.
567
567
  """
@@ -591,8 +591,8 @@ class BaseModel(FeatureSet, nn.Module):
591
591
 
592
592
  def fit(
593
593
  self,
594
- train_data: dict | pd.DataFrame | DataLoader,
595
- valid_data: dict | pd.DataFrame | DataLoader | None = None,
594
+ train_data = None,
595
+ valid_data = None,
596
596
  metrics: (
597
597
  list[str] | dict[str, list[str]] | None
598
598
  ) = None, # ['auc', 'logloss'] or {'target1': ['auc', 'logloss'], 'target2': ['mse']}
@@ -1943,6 +1943,12 @@ class BaseModel(FeatureSet, nn.Module):
1943
1943
  logger.info(f"Loss Function: {self.loss_config}")
1944
1944
  if hasattr(self, "loss_weights"):
1945
1945
  logger.info(f"Loss Weights: {self.loss_weights}")
1946
+ if hasattr(self, "grad_norm"):
1947
+ logger.info(f"GradNorm Enabled: {self.grad_norm is not None}")
1948
+ if self.grad_norm is not None:
1949
+ grad_lr = self.grad_norm.optimizer.param_groups[0].get("lr")
1950
+ logger.info(f" GradNorm alpha: {self.grad_norm.alpha}")
1951
+ logger.info(f" GradNorm lr: {grad_lr}")
1946
1952
 
1947
1953
  logger.info("Regularization:")
1948
1954
  logger.info(f" Embedding L1: {self.embedding_l1_reg}")
@@ -186,6 +186,7 @@ class RecDataLoader(FeatureSet):
186
186
  | list[str]
187
187
  | list[os.PathLike]
188
188
  | DataLoader
189
+ | None
189
190
  ),
190
191
  batch_size: int = 32,
191
192
  shuffle: bool = True,
nextrec/utils/config.py CHANGED
@@ -28,19 +28,19 @@ if TYPE_CHECKING:
28
28
  from nextrec.data.preprocessor import DataProcessor
29
29
 
30
30
 
31
- def resolve_path(path_str: str | Path, base_dir: Path) -> Path:
31
+ def resolve_path(path_str: str | Path | None = None, base_dir: Path | None = None) -> Path:
32
+ if path_str is None:
33
+ return Path.cwd()
32
34
  path = Path(path_str).expanduser()
33
35
  if path.is_absolute():
34
36
  return path
35
37
  # Prefer resolving relative to current working directory when the path (or its parent)
36
38
  # already exists there; otherwise fall back to the config file's directory.
37
- cwd_path = (Path.cwd() / path).resolve()
38
- if cwd_path.exists() or cwd_path.parent.exists():
39
- return cwd_path
40
- base_dir_path = (base_dir / path).resolve()
41
- if base_dir_path.exists() or base_dir_path.parent.exists():
42
- return base_dir_path
43
- return cwd_path
39
+ candidates = ((Path.cwd() / path).resolve(), ((base_dir or Path.cwd()) / path).resolve())
40
+ return next(
41
+ (candidate for candidate in candidates if candidate.exists() or candidate.parent.exists()),
42
+ candidates[0],
43
+ )
44
44
 
45
45
 
46
46
  def select_features(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nextrec
3
- Version: 0.4.13
3
+ Version: 0.4.14
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
@@ -66,7 +66,7 @@ Description-Content-Type: text/markdown
66
66
  ![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)
67
67
  ![PyTorch](https://img.shields.io/badge/PyTorch-1.10+-ee4c2c.svg)
68
68
  ![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)
69
- ![Version](https://img.shields.io/badge/Version-0.4.13-orange.svg)
69
+ ![Version](https://img.shields.io/badge/Version-0.4.14-orange.svg)
70
70
 
71
71
  中文文档 | [English Version](README_en.md)
72
72
 
@@ -99,7 +99,8 @@ NextRec是一个基于PyTorch的现代推荐系统框架,旨在为研究工程
99
99
 
100
100
  ## NextRec近期进展
101
101
 
102
- - **12/12/2025** 在v0.4.13中加入了[RQ-VAE](/nextrec/models/representation/rqvae.py)模块。配套的[数据集](/dataset/ecommerce_task.csv)和[代码](tutorials/notebooks/zh/使用RQ-VAE构建语义ID.ipynb)已经同步在仓库中
102
+ - **21/12/2025** 在v0.4.14中加入了对[GradNorm](/nextrec/loss/grad_norm.py)的支持,通过compile的`loss_weight='grad_norm'`进行配置
103
+ - **12/12/2025** 在v0.4.9中加入了[RQ-VAE](/nextrec/models/representation/rqvae.py)模块。配套的[数据集](/dataset/ecommerce_task.csv)和[代码](tutorials/notebooks/zh/使用RQ-VAE构建语义ID.ipynb)已经同步在仓库中
103
104
  - **07/12/2025** 发布了NextRec CLI命令行工具,它允许用户根据配置文件进行一键训练和推理,我们提供了相关的[教程](/nextrec_cli_preset/NextRec-CLI_zh.md)和[教学代码](/nextrec_cli_preset)
104
105
  - **03/12/2025** NextRec获得了100颗🌟!感谢大家的支持
105
106
  - **06/12/2025** 在v0.4.1中支持了单机多卡的分布式DDP训练,并且提供了配套的[代码](tutorials/distributed)
@@ -240,11 +241,11 @@ nextrec --mode=train --train_config=path/to/train_config.yaml
240
241
  nextrec --mode=predict --predict_config=path/to/predict_config.yaml
241
242
  ```
242
243
 
243
- > 截止当前版本0.4.13,NextRec CLI支持单机训练,分布式训练相关功能尚在开发中。
244
+ > 截止当前版本0.4.14,NextRec CLI支持单机训练,分布式训练相关功能尚在开发中。
244
245
 
245
246
  ## 兼容平台
246
247
 
247
- 当前最新版本为0.4.13,所有模型和测试代码均已在以下平台通过验证,如果开发者在使用中遇到兼容问题,请在issue区提出错误报告及系统版本:
248
+ 当前最新版本为0.4.14,所有模型和测试代码均已在以下平台通过验证,如果开发者在使用中遇到兼容问题,请在issue区提出错误报告及系统版本:
248
249
 
249
250
  | 平台 | 配置 |
250
251
  |------|------|
@@ -1,5 +1,5 @@
1
1
  nextrec/__init__.py,sha256=_M3oUqyuvQ5k8Th_3wId6hQ_caclh7M5ad51XN09m98,235
2
- nextrec/__version__.py,sha256=ARFl7G-gCe12exBb-FIsJnbsUD5V9okxkHUUdQqb0RA,23
2
+ nextrec/__version__.py,sha256=kBEbn8dkCFa3vKochkZqeCl78cbsUbutSFlOYZrn__w,23
3
3
  nextrec/cli.py,sha256=6nBY8O8-0931h428eQS8CALkKn1FmizovJme7Q1c_O0,23978
4
4
  nextrec/basic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  nextrec/basic/activation.py,sha256=uzTWfCOtBSkbu_Gk9XBNTj8__s241CaYLJk6l8nGX9I,2885
@@ -8,13 +8,13 @@ nextrec/basic/features.py,sha256=GyCUzGPuizUofrZSSOdqHK84YhnX4MGTdu7Cx2OGhUA,465
8
8
  nextrec/basic/layers.py,sha256=ZM3Nka3e2cit3e3peL0ukJCMgKZK1ovNFfAWvVOwlos,28556
9
9
  nextrec/basic/loggers.py,sha256=Zh1A5DVAFqlGglyaQ4_IMgvFbWAcXX5H3aHbCWA82nE,6524
10
10
  nextrec/basic/metrics.py,sha256=saNgM7kuHk9xqDxZF6x33irTaxeXCU-hxYTUQauuGgg,23074
11
- nextrec/basic/model.py,sha256=b_O81WSv1XxBAS5oQk92DlLdYAtnikr_epaV5T9RSxs,102570
11
+ nextrec/basic/model.py,sha256=wzz2yMnzls7zxJmCNt2z51k0ZNTKRJ1HQdk3HQ61ObU,102854
12
12
  nextrec/basic/session.py,sha256=UOG_-EgCOxvqZwCkiEd8sgNV2G1sm_HbzKYVQw8yYDI,4483
13
13
  nextrec/data/__init__.py,sha256=YZQjpty1pDCM7q_YNmiA2sa5kbujUw26ObLHWjMPjKY,1194
14
14
  nextrec/data/batch_utils.py,sha256=0bYGVX7RlhnHv_ZBaUngjDIpBNw-igCk98DgOsF7T6o,2879
15
15
  nextrec/data/data_processing.py,sha256=lKXDBszrO5fJMAQetgSPr2mSQuzOluuz1eHV4jp0TDU,5538
16
16
  nextrec/data/data_utils.py,sha256=0Ls1cnG9lBz0ovtyedw5vwp7WegGK_iF-F8e_3DEddo,880
17
- nextrec/data/dataloader.py,sha256=xTORNbaQVa20sk2S3kyV0SSngscvq8bNqHr0AmYjFqM,18768
17
+ nextrec/data/dataloader.py,sha256=As2AvO2IGc-ofVl98HM7CIwSuzIvQtxJrSfvpJ2gamA,18787
18
18
  nextrec/data/preprocessor.py,sha256=K-cUP-YdlQx1VJ2m1CXuprncpjDJe2ERVO5xCSoxHKI,44470
19
19
  nextrec/loss/__init__.py,sha256=ZCgsfyR5YAecv6MdOsnUjkfacvZg2coQVjuKAfPvmRo,923
20
20
  nextrec/loss/grad_norm.py,sha256=91Grspx95Xu_639TkL_WZRX1xt5QOTZCzBeJWbUGPiE,8385
@@ -64,15 +64,15 @@ nextrec/models/retrieval/youtube_dnn.py,sha256=xtGPV6_5LeSZBKkrTaU1CmtxlhgYLvZmj
64
64
  nextrec/models/sequential/hstu.py,sha256=P2Kl7HEL3afwiCApGKQ6UbUNO9eNXXrB10H7iiF8cI0,19735
65
65
  nextrec/models/sequential/sasrec.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
66
66
  nextrec/utils/__init__.py,sha256=C-1l-suSsN_MlPlj_5LApyCRQLOao5l7bO0SccwKHw4,2598
67
- nextrec/utils/config.py,sha256=0HOeMyTlx8g6BZVpXzo2lEOkb-mzNwhbigQuUomsYnY,19934
67
+ nextrec/utils/config.py,sha256=2zcjK4TeN8ow-JSXbWpqyh9C1vFeKnEsYHPg1x564KU,19969
68
68
  nextrec/utils/console.py,sha256=e94SiwA0gKn2pfpP94mY_jl-kFok3TCjxo298KdFuP4,11696
69
69
  nextrec/utils/data.py,sha256=alruiWZFbmwy3kO12q42VXmtHmXFFjVULpHa43fx_mI,21098
70
70
  nextrec/utils/embedding.py,sha256=akAEc062MG2cD7VIOllHaqtwzAirQR2gq5iW7oKpGAU,1449
71
71
  nextrec/utils/feature.py,sha256=rsUAv3ELyDpehVw8nPEEsLCCIjuKGTJJZuFaWB_wrPk,633
72
72
  nextrec/utils/model.py,sha256=3B85a0IJCggI26dxv25IX8R_5yQPo7wXI0JIAns6bkQ,1727
73
73
  nextrec/utils/torch_utils.py,sha256=AKfYbSOJjEw874xsDB5IO3Ote4X7vnqzt_E0jJny0o8,13468
74
- nextrec-0.4.13.dist-info/METADATA,sha256=BcBFpd0l4OdNRlXtG5R1UT-jMcAdloQJjOAG33E4KRE,20958
75
- nextrec-0.4.13.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
76
- nextrec-0.4.13.dist-info/entry_points.txt,sha256=NN-dNSdfMRTv86bNXM7d3ZEPW2BQC6bRi7QP7i9cIps,45
77
- nextrec-0.4.13.dist-info/licenses/LICENSE,sha256=2fQfVKeafywkni7MYHyClC6RGGC3laLTXCNBx-ubtp0,1064
78
- nextrec-0.4.13.dist-info/RECORD,,
74
+ nextrec-0.4.14.dist-info/METADATA,sha256=HDpc5CcuuuVeBhmTwZTCEJw1T_w0GgA7K5CaL-N1Kq8,21103
75
+ nextrec-0.4.14.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
76
+ nextrec-0.4.14.dist-info/entry_points.txt,sha256=NN-dNSdfMRTv86bNXM7d3ZEPW2BQC6bRi7QP7i9cIps,45
77
+ nextrec-0.4.14.dist-info/licenses/LICENSE,sha256=2fQfVKeafywkni7MYHyClC6RGGC3laLTXCNBx-ubtp0,1064
78
+ nextrec-0.4.14.dist-info/RECORD,,