tfrs.tasks.Ranking

A ranking task.

Inherits From: Task

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.

loss Loss function. Defaults to BinaryCrossentropy.
metrics List of Keras metrics to be evaluated.
prediction_metrics List of Keras metrics used to summarize the predictions.
label_metrics List of Keras metrics used to summarize the labels.
name Optional task name.

Methods

call

View source

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.