merlin.models.tf.NextItemPredictionTask

merlin.models.tf.NextItemPredictionTask(schema: merlin.schema.schema.Schema, loss: Optional[Union[str, keras.losses.Loss]] = 'categorical_crossentropy', metrics=[RecallAt(   (total): <tf.Variable 'total:0' shape=() dtype=float32, numpy=0.0>   (count): <tf.Variable 'count:0' shape=() dtype=float32, numpy=0.0>   (_fn_kwargs): Dict() ), MRRAt(   (total): <tf.Variable 'total:0' shape=() dtype=float32, numpy=0.0>   (count): <tf.Variable 'count:0' shape=() dtype=float32, numpy=0.0>   (_fn_kwargs): Dict() ), NDCGAt(   (total): <tf.Variable 'total:0' shape=() dtype=float32, numpy=0.0>   (count): <tf.Variable 'count:0' shape=() dtype=float32, numpy=0.0>   (_fn_kwargs): Dict() ), AvgPrecisionAt(   (total): <tf.Variable 'total:0' shape=() dtype=float32, numpy=0.0>   (count): <tf.Variable 'count:0' shape=() dtype=float32, numpy=0.0>   (_fn_kwargs): Dict() ), PrecisionAt(   (total): <tf.Variable 'total:0' shape=() dtype=float32, numpy=0.0>   (count): <tf.Variable 'count:0' shape=() dtype=float32, numpy=0.0>   (_fn_kwargs): Dict() )], weight_tying: bool = True, masking: bool = True, extra_pre_call: Optional[merlin.models.tf.blocks.core.base.Block] = None, target_name: Optional[str] = None, task_name: Optional[str] = None, task_block: Optional[tensorflow.python.keras.legacy_tf_layers.base.Layer] = None, logits_temperature: float = 1.0, normalize: bool = True, sampled_softmax: bool = False, num_sampled: int = 100, min_sampled_id: int = 0)merlin.models.tf.prediction_tasks.classification.MultiClassClassificationTask[source]

Function to create the NextItemPrediction task with the right parameters. :param schema: The schema object including features to use and their properties. :type schema: Schema :param loss: Loss function.

Defaults to sparse_categorical_crossentropy.

Parameters
  • metrics (MetricOrMetrics) – List of top-k ranking metrics. Defaults to ranking_metrics(top_ks=[10]).

  • weight_tying (bool) – The item_id embedding weights are shared with the prediction network layer. Defaults to True

  • masking (bool) – Whether masking is used to transform inputs and targets or not Defaults to True

  • extra_pre_call (Optional[PredictionBlock]) – Optional extra pre-call block. Defaults to None.

  • target_name (Optional[str]) – If specified, name of the target tensor to retrieve from dataloader. Defaults to None.

  • task_name (Optional[str]) – name of the task. Defaults to None.

  • task_block (Block) – The Block that applies additional layers op to inputs. Defaults to None.

  • logits_temperature (float) – Parameter used to reduce the model overconfidence, so that logits / T. Defaults to 1.

  • normalize (bool) – Apply L2 normalization before computing dot interactions. Defaults to True.

  • sampled_softmax (bool) – Compute the logits scores over all items of the catalog or generate a subset of candidates Defaults to False

  • num_sampled (int) – When sampled_softmax is enabled, specify the number of negative candidates to generate for each batch Defaults to 100

  • min_sampled_id (int) – The minimum id value to be sampled. Useful to ignore the first categorical encoded ids, which are usually reserved for <nulls>, out-of-vocabulary or padding. Defaults to 0.

Returns

The next item prediction task

Return type

PredictionTask