replay-rec 0.18.0__py3-none-any.whl → 0.18.1__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.
- replay/__init__.py +1 -1
- replay/data/dataset.py +27 -1
- replay/data/dataset_utils/dataset_label_encoder.py +6 -3
- replay/data/nn/schema.py +37 -16
- replay/data/nn/sequence_tokenizer.py +313 -165
- replay/data/nn/torch_sequential_dataset.py +17 -8
- replay/data/nn/utils.py +14 -7
- replay/data/schema.py +10 -6
- replay/metrics/offline_metrics.py +2 -2
- replay/models/__init__.py +1 -0
- replay/models/base_rec.py +18 -21
- replay/models/lin_ucb.py +407 -0
- replay/models/nn/sequential/bert4rec/dataset.py +17 -4
- replay/models/nn/sequential/bert4rec/lightning.py +121 -54
- replay/models/nn/sequential/bert4rec/model.py +21 -0
- replay/models/nn/sequential/callbacks/prediction_callbacks.py +5 -1
- replay/models/nn/sequential/compiled/__init__.py +5 -0
- replay/models/nn/sequential/compiled/base_compiled_model.py +261 -0
- replay/models/nn/sequential/compiled/bert4rec_compiled.py +152 -0
- replay/models/nn/sequential/compiled/sasrec_compiled.py +145 -0
- replay/models/nn/sequential/postprocessors/postprocessors.py +27 -1
- replay/models/nn/sequential/sasrec/dataset.py +17 -1
- replay/models/nn/sequential/sasrec/lightning.py +126 -50
- replay/models/nn/sequential/sasrec/model.py +3 -4
- replay/preprocessing/__init__.py +7 -1
- replay/preprocessing/discretizer.py +719 -0
- replay/preprocessing/label_encoder.py +384 -52
- replay/splitters/cold_user_random_splitter.py +1 -1
- replay/utils/__init__.py +1 -0
- replay/utils/common.py +7 -8
- replay/utils/session_handler.py +3 -4
- replay/utils/spark_utils.py +15 -1
- replay/utils/types.py +8 -0
- {replay_rec-0.18.0.dist-info → replay_rec-0.18.1.dist-info}/METADATA +73 -60
- {replay_rec-0.18.0.dist-info → replay_rec-0.18.1.dist-info}/RECORD +37 -31
- {replay_rec-0.18.0.dist-info → replay_rec-0.18.1.dist-info}/LICENSE +0 -0
- {replay_rec-0.18.0.dist-info → replay_rec-0.18.1.dist-info}/WHEEL +0 -0
|
@@ -57,8 +57,8 @@ class SasRecModel(torch.nn.Module):
|
|
|
57
57
|
self.padding_idx = item_count
|
|
58
58
|
|
|
59
59
|
assert schema.item_id_feature_name
|
|
60
|
+
self.schema = schema
|
|
60
61
|
self.item_feature_name = schema.item_id_feature_name
|
|
61
|
-
self.register_buffer("candidates_to_score", torch.LongTensor(list(range(self.item_count))))
|
|
62
62
|
|
|
63
63
|
# Model blocks
|
|
64
64
|
self.masking = SasRecMasks(
|
|
@@ -205,7 +205,6 @@ class SasRecMasks:
|
|
|
205
205
|
:param padding_idx: Padding indices.
|
|
206
206
|
"""
|
|
207
207
|
assert schema.item_id_feature_name
|
|
208
|
-
self.schema = schema
|
|
209
208
|
self.item_feature_name = schema.item_id_feature_name
|
|
210
209
|
self.padding_idx = padding_idx
|
|
211
210
|
|
|
@@ -223,8 +222,8 @@ class SasRecMasks:
|
|
|
223
222
|
input_sequence = feature_tensor[self.item_feature_name]
|
|
224
223
|
|
|
225
224
|
attention_mask = ~torch.tril(
|
|
226
|
-
torch.ones((input_sequence.shape[1], input_sequence.shape[1]), dtype=torch.bool)
|
|
227
|
-
)
|
|
225
|
+
torch.ones((input_sequence.shape[1], input_sequence.shape[1]), dtype=torch.bool, device=padding_mask.device)
|
|
226
|
+
)
|
|
228
227
|
|
|
229
228
|
output_feature_tensor = dict(feature_tensor)
|
|
230
229
|
output_feature_tensor[self.item_feature_name] = input_sequence.masked_fill(
|
replay/preprocessing/__init__.py
CHANGED
|
@@ -6,11 +6,17 @@ This module contains tools for preprocessing data including:
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
from .converter import CSRConverter
|
|
9
|
+
from .discretizer import (
|
|
10
|
+
Discretizer,
|
|
11
|
+
GreedyDiscretizingRule,
|
|
12
|
+
HandleInvalidStrategies,
|
|
13
|
+
QuantileDiscretizingRule,
|
|
14
|
+
)
|
|
9
15
|
from .history_based_fp import (
|
|
10
16
|
ConditionalPopularityProcessor,
|
|
11
17
|
EmptyFeatureProcessor,
|
|
12
18
|
HistoryBasedFeaturesProcessor,
|
|
13
19
|
LogStatFeaturesProcessor,
|
|
14
20
|
)
|
|
15
|
-
from .label_encoder import LabelEncoder, LabelEncodingRule
|
|
21
|
+
from .label_encoder import LabelEncoder, LabelEncoderPartialFitWarning, LabelEncodingRule, SequenceEncodingRule
|
|
16
22
|
from .sessionizer import Sessionizer
|