View source on GitHub |
A ranking task.
Inherits From: Task
tfrs.tasks.Ranking(
loss: Optional[tf.keras.losses.Loss] = None,
metrics: Optional[List[tf.keras.metrics.Metric]] = None,
prediction_metrics: Optional[List[tf.keras.metrics.Metric]] = None,
label_metrics: Optional[List[tf.keras.metrics.Metric]] = None,
loss_metrics: Optional[List[tf.keras.metrics.Metric]] = None,
name: Optional[Text] = None
) -> None
Used in the notebooks
Used in the tutorials |
---|
Recommender systems are often composed of two components:
- a retrieval model, retrieving O(thousands) candidates from a corpus of O(millions) candidates.
- a ranker model, scoring the candidates retrieved by the retrieval model to return a ranked shortlist of a few dozen candidates.
This task helps with building ranker models. Usually, these will involve predicting signals such as clicks, cart additions, likes, ratings, and purchases.
Methods
call
call(
labels: tf.Tensor,
predictions: tf.Tensor,
sample_weight: Optional[tf.Tensor] = None,
training: bool = False,
compute_metrics: bool = True
) -> tf.Tensor
Computes the task loss and metrics.
Args | |
---|---|
labels
|
Tensor of labels. |
predictions
|
Tensor of predictions. |
sample_weight
|
Tensor of sample weights. |
training
|
Indicator whether training or test loss is being computed. |
compute_metrics
|
Whether to compute metrics. Set this to False during training for faster training. |
Returns | |
---|---|
loss
|
Tensor of loss values. |