This video demonstrates how to build a ranking model using TensorFlow Recommenders, which takes user-item pairs and predicts explicit ratings (like movie ratings) by combining user and movie embeddings through dense layers, using mean squared error loss and ranking tasks provided by the library; unlike retrieval models that focus on efficiency, ranking models can afford deeper architectures to produce precise rating predictions that help rank candidate items from thousands to hundreds.
Building a TensorFlow Ranking Model with TF Recommenders
Added:hi there welcome back to our video series of building recommendation systems with tensorflow my name is wei and i'm a developer advocate at google in our last video we introduced the tensorflow recommenders a powerful and elegant library for building recommenders to you and we demoed how to build a two tower retrieval system using tfrs in this video we'll be discussing how to build a ranking model with tensorflow recommenders you may recall that in our very first episode we highlighted that modern recommenders usually have multiple components to do retrieval ranking and post ranking in our last video we demonstrated building a two tower retrieval model now is a good time to learn how to build a ranking model using tensorflow recommenders so that we can filter thousands of candidate items down to hundreds at the ranking stage we start off by preparing the data set as we did for the retrieval stage using tensorflow datasets api but unlike in the retrieval stage we are going to keep the movie ratings at this time as you can see here in the map function the ratings are considered explicit feedback since we can tell roughly how much the users like the movies based on the rating numbers next we shuffle the data set and split it into training and test the data sets lastly we gather a vocabulary for the movie titles and user ids this is exactly the same as we did for our retrieval model last time after preparing the data set we are going to implement the actual model we first create a ranking model class as a subclass of tf.keras.model in the init method we start by creating the user embeddings this is the same as we did in the last video for our retrieval model we're doing the same for the movie embeddings as well next we define a ratings model using a few dense layers to produce the predicted ratings this is pretty straightforward ranking models do not face the same efficiency constraints as retrieval models do so we have a little bit more freedom in our choice of architectures here we're using a deeper model for ranking now in the call method we concatenate the user and movie embeddings into a single vector and pass that vector through the ratings model we just built in the previous slide to get the prediction overall our ranking model takes in a user id and a movie title and outputs a predicted rating as you can see here using our on trend model user 42 is predicted to give one flew over the cuckoo's nest a rating of 0.037 we can now put them together into a model movie lens model exposes a base model class tfrs.models.model which streamlines building models all we need to do is to set up the components in the init method and implement the compute loss method taking in the raw features and returning a loss value in the init method we make use of the tfrs.tasks.rankingtask object which is a convenience wrapper that bundles together the loss function and magic computation and we use the mean squared error keras loss in order to predict the ratings now we can compile and train the model using the feed method you can see that the loss is falling and the rmse metric is improving you can also evaluate the model after training is down but i'm going to skip that part since you are already familiar with keras api finally let's take five movies from the tesla sets and see how user number 42 would rank them here we get the predicted ratings for those five movies and then we sort them in descending order in practice you would be sorting the candidates generated from the retrieval stage but you get the idea so this is it our end-to-end workflow for building a ranking system structurally it is very similar to our retrieval model but with some components unique to ranking just to summarize today we covered how to build a ranking model using tensorflow recommenders this gives us a decent start towards building a ranking system but of course it takes a lot more effort to build a practical ranking system in the next few episodes we'll be discussing how we can improve what we have built with site features and multi-task learning stay tuned see you next time [Music] you
Up Next

Deploying TensorFlow Models in Production With TensorFlow Serving
@GoogleDevelopers
41.5K views•2017-02-16

BitTorrent Protocol Explained: Piece Selection & Peer Choking
@StevenGordonAU
481 views•2013-02-22

Building Recommender Systems with TensorFlow Recommenders | A Comprehensive Guide
@TensorFlow
56K views•2021-07-13

Enigma Machine Mechanics: WWII Encryption Explained
@JaredOwen
13.2M views•2021-12-11
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Computer Science
























![Deep & Cross ⚔️ Networks[Paper Explained]](https://i.ytimg.com/vi/sxC7CrrqsUY/maxresdefault.jpg)













