nextrec 0.4.31__py3-none-any.whl → 0.4.32__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 (46) hide show
  1. nextrec/__version__.py +1 -1
  2. nextrec/basic/model.py +48 -4
  3. nextrec/cli.py +16 -10
  4. nextrec/data/batch_utils.py +2 -2
  5. nextrec/data/preprocessor.py +53 -1
  6. nextrec/models/multi_task/[pre]aitm.py +3 -3
  7. nextrec/models/multi_task/[pre]snr_trans.py +3 -3
  8. nextrec/models/multi_task/[pre]star.py +3 -3
  9. nextrec/models/multi_task/apg.py +3 -3
  10. nextrec/models/multi_task/cross_stitch.py +3 -3
  11. nextrec/models/multi_task/escm.py +3 -3
  12. nextrec/models/multi_task/esmm.py +3 -3
  13. nextrec/models/multi_task/hmoe.py +3 -3
  14. nextrec/models/multi_task/mmoe.py +3 -3
  15. nextrec/models/multi_task/pepnet.py +4 -4
  16. nextrec/models/multi_task/ple.py +3 -3
  17. nextrec/models/multi_task/poso.py +3 -3
  18. nextrec/models/multi_task/share_bottom.py +3 -3
  19. nextrec/models/ranking/afm.py +3 -2
  20. nextrec/models/ranking/autoint.py +3 -2
  21. nextrec/models/ranking/dcn.py +3 -2
  22. nextrec/models/ranking/dcn_v2.py +3 -2
  23. nextrec/models/ranking/deepfm.py +3 -2
  24. nextrec/models/ranking/dien.py +3 -2
  25. nextrec/models/ranking/din.py +3 -2
  26. nextrec/models/ranking/eulernet.py +3 -2
  27. nextrec/models/ranking/ffm.py +3 -2
  28. nextrec/models/ranking/fibinet.py +3 -2
  29. nextrec/models/ranking/fm.py +3 -2
  30. nextrec/models/ranking/lr.py +3 -2
  31. nextrec/models/ranking/masknet.py +3 -2
  32. nextrec/models/ranking/pnn.py +3 -2
  33. nextrec/models/ranking/widedeep.py +3 -2
  34. nextrec/models/ranking/xdeepfm.py +3 -2
  35. nextrec/models/tree_base/__init__.py +15 -0
  36. nextrec/models/tree_base/base.py +693 -0
  37. nextrec/models/tree_base/catboost.py +97 -0
  38. nextrec/models/tree_base/lightgbm.py +69 -0
  39. nextrec/models/tree_base/xgboost.py +61 -0
  40. nextrec/utils/config.py +1 -0
  41. nextrec/utils/types.py +2 -0
  42. {nextrec-0.4.31.dist-info → nextrec-0.4.32.dist-info}/METADATA +5 -5
  43. {nextrec-0.4.31.dist-info → nextrec-0.4.32.dist-info}/RECORD +46 -41
  44. {nextrec-0.4.31.dist-info → nextrec-0.4.32.dist-info}/licenses/LICENSE +1 -1
  45. {nextrec-0.4.31.dist-info → nextrec-0.4.32.dist-info}/WHEEL +0 -0
  46. {nextrec-0.4.31.dist-info → nextrec-0.4.32.dist-info}/entry_points.txt +0 -0
nextrec/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.4.31"
1
+ __version__ = "0.4.32"
nextrec/basic/model.py CHANGED
@@ -13,7 +13,7 @@ import sys
13
13
  import pickle
14
14
  import socket
15
15
  from pathlib import Path
16
- from typing import Any, Literal
16
+ from typing import Any, Literal, cast, overload
17
17
 
18
18
  import numpy as np
19
19
  import pandas as pd
@@ -97,6 +97,7 @@ from nextrec.utils.types import (
97
97
  SchedulerName,
98
98
  TrainingModeName,
99
99
  TaskTypeName,
100
+ TaskTypeInput,
100
101
  MetricsName,
101
102
  )
102
103
 
@@ -119,7 +120,7 @@ class BaseModel(SummarySet, FeatureSet, nn.Module):
119
120
  sequence_features: list[SequenceFeature] | None = None,
120
121
  target: list[str] | str | None = None,
121
122
  id_columns: list[str] | str | None = None,
122
- task: TaskTypeName | list[TaskTypeName] | None = None,
123
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
123
124
  training_mode: TrainingModeName | list[TrainingModeName] | None = None,
124
125
  embedding_l1_reg: float = 0.0,
125
126
  dense_l1_reg: float = 0.0,
@@ -193,7 +194,7 @@ class BaseModel(SummarySet, FeatureSet, nn.Module):
193
194
  dense_features, sparse_features, sequence_features, target, id_columns
194
195
  )
195
196
 
196
- self.task = task or self.default_task
197
+ self.task = cast(TaskTypeName | list[TaskTypeName], task or self.default_task)
197
198
  self.nums_task = len(self.task) if isinstance(self.task, list) else 1
198
199
 
199
200
  training_mode = training_mode or "pointwise"
@@ -1623,6 +1624,49 @@ class BaseModel(SummarySet, FeatureSet, nn.Module):
1623
1624
  )
1624
1625
  return metrics_dict
1625
1626
 
1627
+ @overload
1628
+ def predict(
1629
+ self,
1630
+ data: str | dict | pd.DataFrame | DataLoader,
1631
+ batch_size: int = 32,
1632
+ save_path: str | os.PathLike | None = None,
1633
+ save_format: str = "csv",
1634
+ include_ids: bool | None = None,
1635
+ id_columns: str | list[str] | None = None,
1636
+ return_dataframe: Literal[True] = True,
1637
+ stream_chunk_size: int = 10000,
1638
+ num_workers: int = 0,
1639
+ ) -> pd.DataFrame: ...
1640
+
1641
+ @overload
1642
+ def predict(
1643
+ self,
1644
+ data: str | dict | pd.DataFrame | DataLoader,
1645
+ batch_size: int = 32,
1646
+ save_path: None = None,
1647
+ save_format: str = "csv",
1648
+ include_ids: bool | None = None,
1649
+ id_columns: str | list[str] | None = None,
1650
+ return_dataframe: Literal[False] = False,
1651
+ stream_chunk_size: int = 10000,
1652
+ num_workers: int = 0,
1653
+ ) -> np.ndarray: ...
1654
+
1655
+ @overload
1656
+ def predict(
1657
+ self,
1658
+ data: str | dict | pd.DataFrame | DataLoader,
1659
+ batch_size: int = 32,
1660
+ *,
1661
+ save_path: str | os.PathLike,
1662
+ save_format: str = "csv",
1663
+ include_ids: bool | None = None,
1664
+ id_columns: str | list[str] | None = None,
1665
+ return_dataframe: Literal[False] = False,
1666
+ stream_chunk_size: int = 10000,
1667
+ num_workers: int = 0,
1668
+ ) -> Path: ...
1669
+
1626
1670
  def predict(
1627
1671
  self,
1628
1672
  data: str | dict | pd.DataFrame | DataLoader,
@@ -2225,7 +2269,7 @@ class BaseMatchModel(BaseModel):
2225
2269
  dense_l2_reg: float = 0.0,
2226
2270
  target: list[str] | str | None = "label",
2227
2271
  id_columns: list[str] | str | None = None,
2228
- task: str | list[str] | None = None,
2272
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
2229
2273
  session_id: str | None = None,
2230
2274
  distributed: bool = False,
2231
2275
  rank: int | None = None,
nextrec/cli.py CHANGED
@@ -682,16 +682,22 @@ Examples:
682
682
  if not args.mode:
683
683
  parser.error("[NextRec CLI Error] --mode is required (train|predict)")
684
684
 
685
- if args.mode == "train":
686
- config_path = args.train_config
687
- if not config_path:
688
- parser.error("[NextRec CLI Error] train mode requires --train_config")
689
- train_model(config_path)
690
- else:
691
- config_path = args.predict_config
692
- if not config_path:
693
- parser.error("[NextRec CLI Error] predict mode requires --predict_config")
694
- predict_model(config_path)
685
+ try:
686
+ if args.mode == "train":
687
+ config_path = args.train_config
688
+ if not config_path:
689
+ parser.error("[NextRec CLI Error] train mode requires --train_config")
690
+ train_model(config_path)
691
+ else:
692
+ config_path = args.predict_config
693
+ if not config_path:
694
+ parser.error(
695
+ "[NextRec CLI Error] predict mode requires --predict_config"
696
+ )
697
+ predict_model(config_path)
698
+ except Exception:
699
+ logging.getLogger(__name__).exception("[NextRec CLI Error] Unhandled exception")
700
+ raise
695
701
 
696
702
 
697
703
  if __name__ == "__main__":
@@ -12,7 +12,7 @@ import torch
12
12
 
13
13
 
14
14
  def stack_section(batch: list[dict], section: Literal["features", "labels", "ids"]):
15
- """
15
+ """
16
16
  input example:
17
17
  batch = [
18
18
  {"features": {"f1": tensor1, "f2": tensor2}, "labels": {"label": tensor3}},
@@ -24,7 +24,7 @@ def stack_section(batch: list[dict], section: Literal["features", "labels", "ids
24
24
  "f1": torch.stack([tensor1, tensor4], dim=0),
25
25
  "f2": torch.stack([tensor2, tensor5], dim=0),
26
26
  }
27
-
27
+
28
28
  """
29
29
  entries = [item.get(section) for item in batch if item.get(section) is not None]
30
30
  if not entries:
@@ -13,7 +13,7 @@ import logging
13
13
  import os
14
14
  import pickle
15
15
  from pathlib import Path
16
- from typing import Any, Dict, Literal, Optional, Union
16
+ from typing import Any, Dict, Literal, Optional, Union, overload
17
17
 
18
18
  import numpy as np
19
19
  import pandas as pd
@@ -895,6 +895,28 @@ class DataProcessor(FeatureSet):
895
895
  )
896
896
  return self
897
897
 
898
+ @overload
899
+ def transform_in_memory(
900
+ self,
901
+ data: Union[pd.DataFrame, Dict[str, Any]],
902
+ return_dict: Literal[True],
903
+ persist: bool,
904
+ save_format: Optional[str],
905
+ output_path: Optional[str],
906
+ warn_missing: bool = True,
907
+ ) -> Dict[str, np.ndarray]: ...
908
+
909
+ @overload
910
+ def transform_in_memory(
911
+ self,
912
+ data: Union[pd.DataFrame, Dict[str, Any]],
913
+ return_dict: Literal[False],
914
+ persist: bool,
915
+ save_format: Optional[str],
916
+ output_path: Optional[str],
917
+ warn_missing: bool = True,
918
+ ) -> pd.DataFrame: ...
919
+
898
920
  def transform_in_memory(
899
921
  self,
900
922
  data: Union[pd.DataFrame, Dict[str, Any]],
@@ -1238,6 +1260,36 @@ class DataProcessor(FeatureSet):
1238
1260
  self.is_fitted = True
1239
1261
  return self
1240
1262
 
1263
+ @overload
1264
+ def transform(
1265
+ self,
1266
+ data: Union[pd.DataFrame, Dict[str, Any]],
1267
+ return_dict: Literal[True] = True,
1268
+ save_format: Optional[str] = None,
1269
+ output_path: Optional[str] = None,
1270
+ chunk_size: int = 200000,
1271
+ ) -> Dict[str, np.ndarray]: ...
1272
+
1273
+ @overload
1274
+ def transform(
1275
+ self,
1276
+ data: Union[pd.DataFrame, Dict[str, Any]],
1277
+ return_dict: Literal[False] = False,
1278
+ save_format: Optional[str] = None,
1279
+ output_path: Optional[str] = None,
1280
+ chunk_size: int = 200000,
1281
+ ) -> pd.DataFrame: ...
1282
+
1283
+ @overload
1284
+ def transform(
1285
+ self,
1286
+ data: str | os.PathLike,
1287
+ return_dict: Literal[False] = False,
1288
+ save_format: Optional[str] = None,
1289
+ output_path: Optional[str] = None,
1290
+ chunk_size: int = 200000,
1291
+ ) -> list[str]: ...
1292
+
1241
1293
  def transform(
1242
1294
  self,
1243
1295
  data: Union[pd.DataFrame, Dict[str, Any], str, os.PathLike],
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 01/01/2026 - prerelease version: need to overwrite compute_loss later
3
- Checkpoint: edit on 01/01/2026
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou, zyaztec@gmail.com
5
5
  Reference:
6
6
  - [1] Xi D, Chen Z, Yan P, Zhang Y, Zhu Y, Zhuang F, Chen Y. Modeling the Sequential Dependence among Audience Multi-step Conversions with Multi-task Learning in Targeted Display Advertising. Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining (KDD ’21), 2021, pp. 3745–3755.
@@ -20,7 +20,7 @@ from nextrec.basic.layers import MLP, EmbeddingLayer
20
20
  from nextrec.basic.heads import TaskHead
21
21
  from nextrec.basic.model import BaseModel
22
22
  from nextrec.utils.model import get_mlp_output_dim
23
- from nextrec.utils.types import TaskTypeName
23
+ from nextrec.utils.types import TaskTypeInput
24
24
 
25
25
 
26
26
  class AITMTransfer(nn.Module):
@@ -76,7 +76,7 @@ class AITM(BaseModel):
76
76
  tower_mlp_params_list: list[dict] | None = None,
77
77
  calibrator_alpha: float = 0.1,
78
78
  target: list[str] | str | None = None,
79
- task: list[TaskTypeName] | None = None,
79
+ task: list[TaskTypeInput] | None = None,
80
80
  **kwargs,
81
81
  ):
82
82
  dense_features = dense_features or []
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 01/01/2026 - prerelease version: still need to align with the source paper
3
- Checkpoint: edit on 01/01/2026
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou, zyaztec@gmail.com
5
5
  Reference:
6
6
  - [1] Ma J, Zhao Z, Chen J, Li A, Hong L, Chi EH. SNR: Sub-Network Routing for Flexible Parameter Sharing in Multi-Task Learning in E-Commerce by Exploiting Task Relationships in the Label Space. Proceedings of the 33rd AAAI Conference on Artificial Intelligence (AAAI 2019), 2019, pp. 216-223.
@@ -22,7 +22,7 @@ from nextrec.basic.features import DenseFeature, SequenceFeature, SparseFeature
22
22
  from nextrec.basic.layers import EmbeddingLayer, MLP
23
23
  from nextrec.basic.heads import TaskHead
24
24
  from nextrec.basic.model import BaseModel
25
- from nextrec.utils.types import TaskTypeName
25
+ from nextrec.utils.types import TaskTypeInput, TaskTypeName
26
26
 
27
27
 
28
28
  class SNRTransGate(nn.Module):
@@ -101,7 +101,7 @@ class SNRTrans(BaseModel):
101
101
  num_experts: int = 4,
102
102
  tower_mlp_params_list: list[dict] | None = None,
103
103
  target: list[str] | str | None = None,
104
- task: TaskTypeName | list[TaskTypeName] | None = None,
104
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
105
105
  **kwargs,
106
106
  ) -> None:
107
107
  dense_features = dense_features or []
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 01/01/2026 - prerelease version: still need to align with the source paper
3
- Checkpoint: edit on 01/01/2026
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou, zyaztec@gmail.com
5
5
  Reference:
6
6
  - [1] Sheng XR, Zhao L, Zhou G, Ding X, Dai B, Luo Q, Yang S, Lv J, Zhang C, Deng H, Zhu X. One Model to Serve All: Star Topology Adaptive Recommender for Multi-Domain CTR Prediction. arXiv preprint arXiv:2101.11427, 2021.
@@ -22,7 +22,7 @@ from nextrec.basic.features import DenseFeature, SequenceFeature, SparseFeature
22
22
  from nextrec.basic.heads import TaskHead
23
23
  from nextrec.basic.layers import DomainBatchNorm, EmbeddingLayer
24
24
  from nextrec.basic.model import BaseModel
25
- from nextrec.utils.types import TaskTypeName
25
+ from nextrec.utils.types import TaskTypeInput, TaskTypeName
26
26
 
27
27
 
28
28
  class SharedSpecificLinear(nn.Module):
@@ -73,7 +73,7 @@ class STAR(BaseModel):
73
73
  sparse_features: list[SparseFeature] | None = None,
74
74
  sequence_features: list[SequenceFeature] | None = None,
75
75
  target: list[str] | str | None = None,
76
- task: TaskTypeName | list[TaskTypeName] | None = None,
76
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
77
77
  mlp_params: dict | None = None,
78
78
  use_shared: bool = True,
79
79
  **kwargs,
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 01/01/2026
3
- Checkpoint: edit on 01/01/2026
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou, zyaztec@gmail.com
5
5
  Reference:
6
6
  - [1] Yan B, Wang P, Zhang K, Li F, Deng H, Xu J, Zheng B. APG: Adaptive Parameter Generation Network for Click-Through Rate Prediction. Advances in Neural Information Processing Systems 35 (NeurIPS 2022), 2022.
@@ -20,7 +20,7 @@ from nextrec.basic.layers import EmbeddingLayer, MLP
20
20
  from nextrec.basic.heads import TaskHead
21
21
  from nextrec.basic.model import BaseModel
22
22
  from nextrec.utils.model import select_features
23
- from nextrec.utils.types import ActivationName, TaskTypeName
23
+ from nextrec.utils.types import ActivationName, TaskTypeInput, TaskTypeName
24
24
 
25
25
 
26
26
  class APGLayer(nn.Module):
@@ -233,7 +233,7 @@ class APG(BaseModel):
233
233
  sparse_features: list[SparseFeature] | None = None,
234
234
  sequence_features: list[SequenceFeature] | None = None,
235
235
  target: list[str] | str | None = None,
236
- task: TaskTypeName | list[TaskTypeName] | None = None,
236
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
237
237
  mlp_params: dict | None = None,
238
238
  inner_activation: ActivationName | None = None,
239
239
  generate_activation: ActivationName | None = None,
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 01/01/2026
3
- Checkpoint: edit on 01/01/2026
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou, zyaztec@gmail.com
5
5
  Reference:
6
6
  - [1] Misra I, Shrivastava A, Gupta A, Hebert M. Cross-Stitch Networks for Multi-Task Learning. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR 2016), 2016, pp. 3994–4003.
@@ -21,7 +21,7 @@ from nextrec.basic.features import DenseFeature, SequenceFeature, SparseFeature
21
21
  from nextrec.basic.layers import EmbeddingLayer, MLP
22
22
  from nextrec.basic.heads import TaskHead
23
23
  from nextrec.basic.model import BaseModel
24
- from nextrec.utils.types import TaskTypeName
24
+ from nextrec.utils.types import TaskTypeInput, TaskTypeName
25
25
 
26
26
 
27
27
  class CrossStitchLayer(nn.Module):
@@ -76,7 +76,7 @@ class CrossStitch(BaseModel):
76
76
  sparse_features: list[SparseFeature] | None = None,
77
77
  sequence_features: list[SequenceFeature] | None = None,
78
78
  target: list[str] | str | None = None,
79
- task: TaskTypeName | list[TaskTypeName] | None = None,
79
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
80
80
  shared_mlp_params: dict | None = None,
81
81
  task_mlp_params: dict | None = None,
82
82
  tower_mlp_params: dict | None = None,
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 01/01/2026
3
- Checkpoint: edit on 01/01/2026
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou, zyaztec@gmail.com
5
5
  Reference:
6
6
  - [1] Wang H, Chang T-W, Liu T, Huang J, Chen Z, Yu C, Li R, Chu W. ESCM²: Entire Space Counterfactual Multi-Task Model for Post-Click Conversion Rate Estimation. Proceedings of the 45th International ACM SIGIR Conference on Research and Development in Information Retrieval (SIGIR ’22), 2022:363–372.
@@ -23,7 +23,7 @@ from nextrec.basic.layers import EmbeddingLayer, MLP
23
23
  from nextrec.basic.model import BaseModel
24
24
  from nextrec.loss.grad_norm import get_grad_norm_shared_params
25
25
  from nextrec.utils.model import compute_ranking_loss
26
- from nextrec.utils.types import TaskTypeName
26
+ from nextrec.utils.types import TaskTypeInput, TaskTypeName
27
27
 
28
28
 
29
29
  class ESCM(BaseModel):
@@ -52,7 +52,7 @@ class ESCM(BaseModel):
52
52
  imp_mlp_params: dict | None = None,
53
53
  use_dr: bool = False,
54
54
  target: list[str] | str | None = None,
55
- task: TaskTypeName | list[TaskTypeName] | None = None,
55
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
56
56
  **kwargs,
57
57
  ) -> None:
58
58
  dense_features = dense_features or []
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 09/11/2025
3
- Checkpoint: edit on 23/12/2025
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou,zyaztec@gmail.com
5
5
  Reference:
6
6
  - [1] Ma X, Zhao L, Huang G, Wang Z, Hu Z, Zhu X, Gai K. Entire Space Multi-Task Model: An Effective Approach for Estimating Post-Click Conversion Rate. In: Proceedings of the 41st International ACM SIGIR Conference on Research and Development in Information Retrieval (SIGIR ’18), 2018, pp. 1137–1140.
@@ -46,7 +46,7 @@ from nextrec.basic.features import DenseFeature, SequenceFeature, SparseFeature
46
46
  from nextrec.basic.layers import MLP, EmbeddingLayer
47
47
  from nextrec.basic.heads import TaskHead
48
48
  from nextrec.basic.model import BaseModel
49
- from nextrec.utils.types import TaskTypeName
49
+ from nextrec.utils.types import TaskTypeInput
50
50
 
51
51
 
52
52
  class ESMM(BaseModel):
@@ -76,7 +76,7 @@ class ESMM(BaseModel):
76
76
  sequence_features: list[SequenceFeature],
77
77
  ctr_mlp_params: dict,
78
78
  cvr_mlp_params: dict,
79
- task: list[TaskTypeName] | None = None,
79
+ task: list[TaskTypeInput] | None = None,
80
80
  target: list[str] | None = None, # Note: ctcvr = ctr * cvr
81
81
  **kwargs,
82
82
  ):
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 01/01/2026
3
- Checkpoint: edit on 01/01/2026
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou, zyaztec@gmail.com
5
5
  [1] Zhao Z, Liu Y, Jin R, Zhu X, He X. HMOE: Improving Multi-Scenario Learning to Rank in E-commerce by Exploiting Task Relationships in the Label Space. Proceedings of the 29th ACM International Conference on Information & Knowledge Management (CIKM ’20), 2020, pp. 2069–2078.
6
6
  URL: https://dl.acm.org/doi/10.1145/3340531.3412713
@@ -23,7 +23,7 @@ from nextrec.basic.layers import MLP, EmbeddingLayer
23
23
  from nextrec.basic.heads import TaskHead
24
24
  from nextrec.basic.model import BaseModel
25
25
  from nextrec.utils.model import get_mlp_output_dim
26
- from nextrec.utils.types import TaskTypeName
26
+ from nextrec.utils.types import TaskTypeInput, TaskTypeName
27
27
 
28
28
 
29
29
  class HMOE(BaseModel):
@@ -53,7 +53,7 @@ class HMOE(BaseModel):
53
53
  tower_mlp_params_list: list[dict] | None = None,
54
54
  task_weight_mlp_params: list[dict] | None = None,
55
55
  target: list[str] | str | None = None,
56
- task: TaskTypeName | list[TaskTypeName] | None = None,
56
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
57
57
  **kwargs,
58
58
  ) -> None:
59
59
  dense_features = dense_features or []
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 09/11/2025
3
- Checkpoint: edit on 23/12/2025
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou,zyaztec@gmail.com
5
5
  Reference:
6
6
  - [1] Ma J, Zhao Z, Yi X, Chen J, Hong L, Chi E H. Modeling Task Relationships in Multi-task Learning with Multi-gate Mixture-of-Experts. In: Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD ’18), 2018, pp. 1930–1939.
@@ -48,7 +48,7 @@ from nextrec.basic.features import DenseFeature, SequenceFeature, SparseFeature
48
48
  from nextrec.basic.layers import MLP, EmbeddingLayer
49
49
  from nextrec.basic.heads import TaskHead
50
50
  from nextrec.basic.model import BaseModel
51
- from nextrec.utils.types import TaskTypeName
51
+ from nextrec.utils.types import TaskTypeInput
52
52
 
53
53
 
54
54
  class MMOE(BaseModel):
@@ -81,7 +81,7 @@ class MMOE(BaseModel):
81
81
  num_experts: int = 3,
82
82
  tower_mlp_params_list: list[dict] | None = None,
83
83
  target: list[str] | str | None = None,
84
- task: TaskTypeName | list[TaskTypeName] | None = None,
84
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
85
85
  **kwargs,
86
86
  ):
87
87
 
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 01/01/2026
3
- Checkpoint: edit on 01/01/2026
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou, zyaztec@gmail.com
5
5
  Reference:
6
6
  - [1] Chang J, Zhang C, Hui Y, Leng D, Niu Y, Song Y, Gai K. PEPNet: Parameter and Embedding Personalized Network for Infusing with Personalized Prior Information. In: Proceedings of the 29th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD ’23), 2023.
@@ -58,7 +58,7 @@ from nextrec.basic.layers import EmbeddingLayer, GateMLP
58
58
  from nextrec.basic.heads import TaskHead
59
59
  from nextrec.basic.model import BaseModel
60
60
  from nextrec.utils.model import select_features
61
- from nextrec.utils.types import TaskTypeName
61
+ from nextrec.utils.types import TaskTypeInput, TaskTypeName
62
62
 
63
63
 
64
64
  class PPNet(nn.Module):
@@ -184,7 +184,7 @@ class PEPNet(BaseModel):
184
184
  sparse_features: list[SparseFeature] | None = None,
185
185
  sequence_features: list[SequenceFeature] | None = None,
186
186
  target: list[str] | str | None = None,
187
- task: TaskTypeName | list[TaskTypeName] | None = None,
187
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
188
188
  mlp_params: dict | None = None,
189
189
  feature_gate_mlp_params: dict | None = None,
190
190
  gate_mlp_params: dict | None = None,
@@ -334,7 +334,7 @@ class PEPNet(BaseModel):
334
334
 
335
335
  task_logits = []
336
336
  for block in self.ppnet_blocks:
337
- task_logits.append(block(o_ep=dnn_input, o_prior=task_sf_emb))
337
+ task_logits.append(block(o_ep=dnn_input, o_prior=task_sf_emb))
338
338
 
339
339
  y = torch.cat(task_logits, dim=1)
340
340
  return self.prediction_layer(y)
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 09/11/2025
3
- Checkpoint: edit on 23/12/2025
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou,zyaztec@gmail.com
5
5
  Reference:
6
6
  - [1] Tang H, Liu J, Zhao M, Gong X. Progressive Layered Extraction (PLE): A Novel Multi-Task Learning (MTL) Model for Personalized Recommendations. In: Proceedings of the 14th ACM Conference on Recommender Systems (RecSys ’20), 2020, pp. 269–278.
@@ -52,7 +52,7 @@ from nextrec.basic.layers import MLP, EmbeddingLayer
52
52
  from nextrec.basic.heads import TaskHead
53
53
  from nextrec.basic.model import BaseModel
54
54
  from nextrec.utils.model import get_mlp_output_dim
55
-
55
+ from nextrec.utils.types import TaskTypeInput
56
56
 
57
57
  class CGCLayer(nn.Module):
58
58
  """
@@ -202,7 +202,7 @@ class PLE(BaseModel):
202
202
  num_levels: int = 2,
203
203
  tower_mlp_params_list: list[dict] | None = None,
204
204
  target: list[str] | None = None,
205
- task: str | list[str] | None = None,
205
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
206
206
  **kwargs,
207
207
  ):
208
208
 
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 28/11/2025
3
- Checkpoint: edit on 23/12/2025
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou,zyaztec@gmail.com
5
5
  Reference:
6
6
  - [1] Dai S, Lin H, Zhao Z, Lin J, Wu H, Wang Z, Yang S, Liu J. POSO: Personalized Cold Start Modules for Large-scale Recommender Systems. arXiv preprint arXiv:2108.04690, 2021.
@@ -50,7 +50,7 @@ from nextrec.basic.layers import MLP, EmbeddingLayer
50
50
  from nextrec.basic.heads import TaskHead
51
51
  from nextrec.basic.model import BaseModel
52
52
  from nextrec.utils.model import select_features
53
- from nextrec.utils.types import TaskTypeName
53
+ from nextrec.utils.types import TaskTypeInput
54
54
 
55
55
 
56
56
  class POSOGate(nn.Module):
@@ -310,7 +310,7 @@ class POSO(BaseModel):
310
310
  pc_sequence_features: list[str] | None,
311
311
  tower_mlp_params_list: list[dict],
312
312
  target: list[str] | None = None,
313
- task: TaskTypeName | list[TaskTypeName] | None = None,
313
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
314
314
  architecture: Literal["mlp", "mmoe"] = "mlp",
315
315
  # POSO gating defaults
316
316
  gate_hidden_dim: int = 32,
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 09/11/2025
3
- Checkpoint: edit on 23/12/2025
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou,zyaztec@gmail.com
5
5
 
6
6
  Shared-Bottom is the classic hard-parameter-sharing baseline for multi-task learning.
@@ -43,7 +43,7 @@ from nextrec.basic.features import DenseFeature, SequenceFeature, SparseFeature
43
43
  from nextrec.basic.layers import MLP, EmbeddingLayer
44
44
  from nextrec.basic.heads import TaskHead
45
45
  from nextrec.basic.model import BaseModel
46
-
46
+ from nextrec.utils.types import TaskTypeInput
47
47
 
48
48
  class ShareBottom(BaseModel):
49
49
  @property
@@ -65,7 +65,7 @@ class ShareBottom(BaseModel):
65
65
  bottom_mlp_params: dict,
66
66
  tower_mlp_params_list: list[dict],
67
67
  target: list[str],
68
- task: str | list[str] | None = None,
68
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
69
69
  **kwargs,
70
70
  ):
71
71
 
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 09/11/2025
3
- Checkpoint: edit on 23/12/2025
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou, zyaztec@gmail.com
5
5
  Reference:
6
6
  - [1] Xiao J, Ye H, He X, et al. Attentional Factorization Machines: Learning the Weight of Feature Interactions via Attention Networks
@@ -43,6 +43,7 @@ from nextrec.basic.features import DenseFeature, SequenceFeature, SparseFeature
43
43
  from nextrec.basic.layers import EmbeddingLayer, InputMask
44
44
  from nextrec.basic.heads import TaskHead
45
45
  from nextrec.basic.model import BaseModel
46
+ from nextrec.utils.types import TaskTypeInput
46
47
 
47
48
 
48
49
  class AFM(BaseModel):
@@ -60,7 +61,7 @@ class AFM(BaseModel):
60
61
  sparse_features: list[SparseFeature] | None = None,
61
62
  sequence_features: list[SequenceFeature] | None = None,
62
63
  target: str | list[str] | None = None,
63
- task: str | list[str] | None = None,
64
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
64
65
  attention_dim: int = 32,
65
66
  attention_dropout: float = 0.0,
66
67
  **kwargs,
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 09/11/2025
3
- Checkpoint: edit on 23/12/2025
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou, zyaztec@gmail.com
5
5
  Reference:
6
6
  - [1] Song W, Shi C, Xiao Z, et al. AutoInt: Automatic feature interaction learning via self-attentive neural networks. In: Proceedings of the 28th ACM International Conference on Information and Knowledge Management (CIKM ’19), 2019, pp. 1161–1170.
@@ -59,6 +59,7 @@ from nextrec.basic.features import DenseFeature, SequenceFeature, SparseFeature
59
59
  from nextrec.basic.layers import EmbeddingLayer, MultiHeadSelfAttention
60
60
  from nextrec.basic.heads import TaskHead
61
61
  from nextrec.basic.model import BaseModel
62
+ from nextrec.utils.types import TaskTypeInput
62
63
 
63
64
 
64
65
  class AutoInt(BaseModel):
@@ -76,7 +77,7 @@ class AutoInt(BaseModel):
76
77
  sparse_features: list[SparseFeature],
77
78
  sequence_features: list[SequenceFeature],
78
79
  target: str | list[str] | None = None,
79
- task: str | list[str] | None = None,
80
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
80
81
  att_layer_num: int = 3,
81
82
  att_embedding_dim: int = 8,
82
83
  att_head_num: int = 2,
@@ -1,6 +1,6 @@
1
1
  """
2
2
  Date: create on 09/11/2025
3
- Checkpoint: edit on 23/12/2025
3
+ Checkpoint: edit on 01/14/2026
4
4
  Author: Yang Zhou, zyaztec@gmail.com
5
5
  Reference:
6
6
  - [1] Wang R, Fu B, Fu G, et al. Deep & cross network for ad click predictions[C] //Proceedings of the ADKDD'17. 2017: 1-7.
@@ -56,6 +56,7 @@ from nextrec.basic.features import DenseFeature, SequenceFeature, SparseFeature
56
56
  from nextrec.basic.layers import MLP, EmbeddingLayer
57
57
  from nextrec.basic.heads import TaskHead
58
58
  from nextrec.basic.model import BaseModel
59
+ from nextrec.utils.types import TaskTypeInput
59
60
 
60
61
 
61
62
  class CrossNetwork(nn.Module):
@@ -94,7 +95,7 @@ class DCN(BaseModel):
94
95
  sparse_features: list[SparseFeature] | None = None,
95
96
  sequence_features: list[SequenceFeature] | None = None,
96
97
  target: str | list[str] | None = None,
97
- task: str | list[str] | None = None,
98
+ task: TaskTypeInput | list[TaskTypeInput] | None = None,
98
99
  cross_num: int = 3,
99
100
  mlp_params: dict | None = None,
100
101
  **kwargs,