Open bellicapelli0 opened 3 years ago
You can find it in the prediction section of the basic retieval tutorial.
Correct me if I'm wrong, but doesn't that only apply to the retrieval part of the multi-task model? How can this be extended to include the ranking part?
To get just the ranking predictions you could add the following method to the model:
def ranking_predictions(self, features: Dict[Text, tf.Tensor]) -> tf.Tensor:
# We pick out the user features and pass them into the user model.
user_embeddings = self.user_model(features["user_id"])
# And pick out the movie features and pass them into the movie model.
movie_embeddings = self.movie_model(features["movie_title"])
return self.rating_model(
tf.concat([user_embeddings, movie_embeddings], axis=1)
)
You could wrap this in @tf.function
for efficiency and SavedModel
exportability.
Note that to score multiple candidates for a given user you'll need to pass multiple (user, candidate rows here) or else modify the ranking_predictions
function to do user representation broadcasting.
@bellicapelli0 I have the same issue as yours. I want to predict the ranking in the ranking part. Have you found any solution for that?
I'm following the tutorial here and I am wondering how to get a prediction for a given user. Once training is done, how can I pass a user_id string and receive a list of ranked recommendations? Thanks in advance for the help.