Modern recommendation systems employ a two-phase architecture consisting of retrieval and ranking phases, where the retrieval phase uses scalable two-tower neural networks to generate candidate items by embedding user and item features in a shared vector space, and the ranking phase employs deep multi-task neural networks to predict user engagement probabilities and rank items for optimal conversion, with reinforcement learning and PID controllers addressing business constraints like exploration-exploitation trade-offs and fairness requirements.
Evolution of Recommendation Systems: Deep Learning Approaches Explained
Added:hey good morning Dr rakes and good morning everyone yeah dear participants back to assist um I would like to introduce our speaker abishek mangoli he's a seasonal data scientist with over seven years of experience holding a master's degree in computer science from Tri hyra he has worked with prominent companies such as Walmart and currently survey as a lead data scientist at Meo abish expertise expans various domains of data science including Supply chain pricing prod analysis recommendation systems and advertising platforms he a through leader in a field regularly sharing his insights on platforms like LinkedIn and medium as well as through his YouTube channel data trick iik also has also delivered guest lectures in prestigious in institution like IIT metas Tri City symbis Pune and Jindal University outside of his professional endeavors he's a fitness Enthusiast and a devoted MMA fan so please you can carry on we are eager to hear you from you thank you uh thank you thank you Dr rakes for inviting me for this conference and uh glad to be here today I will be talking about uh recommendation systems and how deep learning since this conference is for deep learning how deep learning is extensively used in uh Modern Day recommendation systems and we will cover uh a lot of other things as well so with that I will just share my screen let me know if my screen is up and visible is my screen visible yes yes we can see you sir sure so today I will be talking about recommendation systems how uh recommendation systems have evolved with time why these recommendation systems are very important and since uh our focus is on deep learning how deep learning models are playing a vital role in Modern Day recommendation systems we will look at the recommendation systems of uh some teag giants like Twitter Instagram Pinterest uh look at their ranking and retrieval strategies we'll understand what ranking and retrieval strategies are and we will also finally summarize that what are the lessons we can learn from uh the final uh at at the end at the conclusion what are the lessons we can learn from all these uh things so with that uh first I will introduce myself I am abishek mangoli I work as lead data scientist at misho and prior to that I was working as senior data scientist for Walmart and I have done my studies from triple it Hyderabad these are my social media handles and interestingly I started my content creation Journey a year back and uh I've been regularly posting over LinkedIn and whenever I get time I create some videos and post in my YouTube channel data TR my videos are more around industry use cases uh that how would Instagram recommendation system uh works and how can one train a 7 billion uh llama 2 model to solve their task like recently uh I have been working on a video uh where like how can a 7 billion Lama V2 model can be trained to respond like saruk Khan because saruk Khan is known for his wittiness and confidence and the type of replies he gives so whatever we ask him he will uh uh the the the llm will reply in saruk Khan's way of replying so I asked it that what is how is a deep learning model trained it asked it it gave them reference of movies that feeded lot of movies and uh and finally you will get a blockbuster model so so these kind of things I keep doing and I keep uh posting in videos and there are some these are some other social media handles where you can reach out to me now uh starting the today's topic that why why are recommendation systems so important recommendation systems are so important because they are uous and present everywhere from online shopping to social media and entertainment platforms uh these systems use complex algorithm to analyze you users pass data and come up with recommendations which are more inferred towards user preferences and behavior for an Amazon type of app it can be for for Amazon kind of app it can be the item recommendation for the users for Spotify it can be the music recommendation for the user for Facebook it can be the friends recommendation for Netflix it can be the movie recommendation and interestingly when you search something and the rank ordering in which the document comes over Google that is also um a recommendation you can call it the document recommendation and uh how recommendation systems have evolved in looks and feel you can see on the left this is the Amazon page from from 1999 where you can see it's a very simple vanilla page with uh one search box while the recent day 2023 uh Amazon page has lot of widgets like related to the items you have viewed more items to consider recommendation in Kindle books and inspired from the recent shopping Trends and so on so there are multiple widgets multiple recommendations each widget might have the its own recommendation or it can be a global recommendation and items are filtered out based on wiget so these are some of the ways in which they could have implemented it but the point that I'm trying to make you can see that how things have evolved a lot and not just the look and feel the user taste also keeps on evolving we are becoming more of a mature users uh the cringe content want we won't like it much right or sometimes we will like it also for entertainment so even our taste and behavior is keeping uh on changing and recommendation systems have to um uh compete with that as well uh moving on uh in the last slide we saw that how the look and feel of these recommendation systems have evolved now also understands how the algorithms have evolved with time uh with time there used to be traditional methods like rule based collaborative filtering or content based filtering uh where which has now evolved to more complicated ways like metrix factorization based enhancement and so on so first let's understand what collaborative filtering is collaborative filtering can be understand understood in this way that for you can think of it as a bipartite graph where you have users and items and users would have interacted with some items right but not all the items now if you consider this bipartite graph where there are users and there are items and the connections between them there will be many edges which are not connected and edges here means that user would have not seen a product if that edge was connected what would have been the weight of it if weight was higher it means user might have higher propensity towards that item which till now user user has not seen that's the main idea and it can be solved using some rule based methods in past it was solved and then content based filtering looking at the content of the item and recommending similar items to that and then things got better with the Netflix uh famous challenge where Matrix factorization uh people discovered what Matrix factorization does is it takes that user item interaction Matrix and decomposes it into user cross latent features and item cross latent features the main idea is that users latent features and item latent features is kind of a vector space where the the two are comparable and if you multiply them or do a DOT product of them if the output comes to be high means this item is relevant for the user if if the dot product or multiplication value is lesser the item may not be very relevant for the users and some of the algorithms which does it are SVD Matrix factorization and so on but the problem with Matrix factorization was that or is that this is not a very scalable algorithm first you have to multiply to big matric uh Matrix or or decompose a big Matrix into two smaller Matrix and the Matrix can be Spar so there are these scalability memory issues and so on so people came up with better methods to solve it using deep learning embedding based deep learning uh methods which is also called neural cability filtering the idea is simple here also you learn the latent distribution and those latent distribution called are called EMB biddings it's the vector representation and one more enhancement over the metrix factorization is that metrix factorization only decomposes the rating or whatever the U value you have in metrix into latent features and it doesn't take explicit user or item features but in deep learning methods you can give other features as well like for an item what is the click through rate or when was it introduced in the system what is the rating so you can pass uh this kind of user features item features and as well as you can even pass the user ID or or the item id which are called ID based features and the other type of features that I was just talking about the non ID features and together you can learn a latent distribution which you can call as the embedding uh of the entity and the idea is that these embeddings are vector representations and they are comparable and doing a DOT product if it's comes out High means user is more uh interested in that item and if dot product is low it may not be a very relevant item for the user now things have evolved even more now we are also looking at the sequential uh nature of these interactions so in sequential recommendation we look at the order and timing of the interaction not just that whether the user has liked or clicked or rated but the order in which the user interacted with these items he first clicked and then he went to some other item then after a few bunch of clicks he ordered the item so looking at this interaction also we can get lot of information so modern recommendation systems are also looking at the sequential nature uh of these interactions and something that might have come to your mind would be as soon as I said sequential nature something like Transformer or lstm kind of attention mechanism also we can use in this kind of recommendation systems right also we are now it is building context saver recommendation context means that uh for different users the recommendations May differ right this is called personalization or context can also be some other context as in it's say sales day so the context is of sales or or time of the day day of the week so depending on different context your recommendations keeps on changing uh reinforcement learning is also getting used a lot in Modern Day recommendation system reinforcement learning is used Mo mostly for uh two important things one is uh uh to like like we already know what users uh like to browse but once in a while showing them some of the items or categories which they have never explored before so for this exploitation exploration trade-off and as well as and the user Behavior keeps on changing so RL what it does it keeps on changing the recommendations based on users changing interest and lot of research is also going around fairness and explainability of these recommendation systems so in the last slide we looked at how look and fieldwise recommendation systems have evolved and in this slide we looked at algorithmic WISE how the recommendation systems have evolved moving on uh since uh this talk is more around the Modern Day recommendation system we will talk about the some of the uh most sophisticated uh techniques which are used now so basically if you from the algorithm perspective the the the Lower Side ones right which are more latest we will talk about these modern day uh techniques which are used in building scalable recommendation system and when I say scalable I mean that like Instagram is used by billions of users so you need to generate recommendation at that scale so we'll talk about scalable recommendation systems and how Industries build it uh so the recommendation systems as we already saw are indispensable in filtering out items that the user may be interested in out of huge amount of items there are billions or millions of items on the platform and you have to show the most relevant one now uh this could be as I was showing in the first slide this could be the e-commerce product for Amazon or it can be the music for Spotify it can be the music for net uh movies for Netflix or it can be documents for Google so depending on the industry there uh the The Entity on which they operate may change but the idea is same that you have to filter out the most relevant entity for a user the common practice these day is to build these recommendation systems in as a two-phase ARG ecture retrieval phase and ranking phase in retrieval phase what happens is out of millions or billions of items you uh retrieve the most relevant ones for the users and now let's say out of millions of items you have the top thousand items which are uh relevant for users you need also need a rank ordering right how in what rank ordering you should show to the user which items should be shown first second third and so on so the ranking model which uh kicks in after the retrieval phase uh ranks these items in order to maximize the conversion so U there are two stages one is retrieval phase where the out of millions of items the relevant items are retrieved and the ranking phase where these items are ranked in order to better the conversion uh moving on uh so in today's uh lecture we will look at the recommendation system of three major Giants Twitter Instagram and Pinterest and we have already seen that recommendation systems are built uh using two phases retrieval and ranking and we will see how these two phases are used by uh these TCH Giants to uh create highly scalable recommendation systems I will just take a pause if there are any questions yeah if if there are any questions you can just ask and then we can continue with the session [Music] sure so we can take questions at the end maybe uh now uh first we will look at the recommendation system of Instagram we will look at the explore recommendation system of Instagram the explore is the tab in Instagram where you can explore lot of new reals new content and you even you can search for a query and regarding that query also you will get many media recommend this so how the uh explore Instagram recommendation system is built is it has two phases one is retrieval and second is ranking and since Instagram is a big company very matur or they even for them the ranking is in happens in two phases the first stage ranking and second stage ranking where uh the first stage ranking filters out the further some of the irrelevant item so so we'll understand the whole um flow in more details but just giving a brief in this slide so first what happens there is a retrieval phase you can see that there are multiple media sources from which you uh come up with the relevant media for a user now what do we mean by this media Source now if I ask you that for Instagram recommend some item for the user what will you do some media for the user what will you do there are multiple ways you can you can see that what user has interacted recently so similar media to that or you can uh come up with what are the recent Trends which are most popular viral videos show those to the user so you can come up with different algorithms or different types of content to be shown to the user right so each type of fancy algorithms become one of the source so you can have multiple algorithms from which you can find topk items and these topk items will becomes the uh uh retrieved items for the user and how to uh find the best items out of millions of items U we will we will see the algorithms they use in these sources but the idea is that there can be multiple algorithms to find interesting Medias and each one of them is one of the source and then what you do is you just suffle and merge all these medias and pass to the ranking stage now since you have brought out thousand Medias right and we know that like people usually like to browse the top 100 or so on so out of thousand media also you do a light weight ranking where you figure out that which are the top funds through the sorry to disturb you please can you please make a zoom this slides par not able to wa no fine yeah so yeah so the first stage is retrieval second stage is ranking in the first stage ranking uh we filter out again the most relevant ones and then in the second stage ranking the final rank of the items is decided and the rank ordering is also decided using a deep neural network uh deep uh neural network which is uh designed to solve multitask multi-level problem we will we will understand what multitask multi-level problem it's solving and as a end product of it we will get lot of probabilities probabilities as in for a user what is the probability to like that media what is the probability to comment on that media what is the probability to share that uh Media or save that media and once we have all the probabilities what we can do is we can just find how much weights to give given to each of these probabilities and the final expected value will decide the rank ordering of the media for the user so just uh summarizing there's a retrieval phase where you find the most relevant Medias uh bring it all in one place first stage ranking will further um boil down the top relevant items and second stage ranking will have a deep neural network which will find different probabilities and you will have a value function depending on which the items will rank will be ranked so now we will look at all of these stages in more details the first is the retrieval phase in the retrieval phase uh as I was talking just uh before that there are multiple candidates right and each candidates can be considered as one fancy algorithm so each algorithm is called a candidate generator and uh interestingly you can have uh like candidate generators which can be heuristic based or sophisticated ml based you can have candidate generators which are real time or pre-generated ones so we will look in more details so when I say heuristic based you can see that it can be something like the recent media user has followed or liked interacted so similar media to that you if you have liked a cricket reel so so another Cricket re which is very similar and it can also be like if we know that the user is interested on topics like Cricket movies or so on so the content which are very relevant to their interested topics this could be theistic base right we we just know their topics or we know what they have interacted with we are just showing similar content like that while it can be more ml based as well ml based as in it can be based on embeddings like the the enhanc version of metrix sectorization is using neural cability filtering or two Tower neural network so we can use this kind of two Tower neural network to come up with interesting recommendations as well so this is more ml based or it can be graph based as well so a graph algorithm which will figure out that where the user is there in the graph and which Medias are nearby and more relevant to it so it can be juristic based or more ml based and it can be real time or pregenerated real time as in like when I say say that uh uh a media which user interacted with so similar media to it the user might have interacted just a second before right and you see in Instagram that as soon as you like some video you start seeing uh similar videos so it it can be as real real time as that like user just interacted with some media and very soon you start generating candidates which are similar to that or it can be pre-generated we know that the user interest won't change drastically over the day right so you can pre-generate uh during the start of the day uh some reals or some Medias which are more relevant to the interestate topics or something which are more towards the trends and recommend them and uh uh one more thing that uh the twoot tower neural network I will be talking about it in more details because this is um something which is a lot being researched upon and everyday in rexes and all the kdds all the uh influential influential um recommendation system conferences there are lot of papers around 2A neural network where they would have modified the architecture in some way to better capture things so the two Tower neural network it's a very scalable and effective way and IT addresses the constraints of metrix factorization that metrix factorization is not very much scalable it can only look at the latent features not the other features of the entities and also um it's um it it is very generic like different companies may have different type of use cases it it easily fits to different use cases as well we will look into that as well so next we will de understand this two Tower neural network for Instagram and twoot Tower neural network in general why is it so U uh scalable architecture so uh so the Instagram two Tower retrieval model as the name suggests two Tower there are two towers there is a there is a user Tower and there is an item Tower the user Tower takes user features item Tower takes item features and uh there can be even non uh ID based features as well so what do I mean by ID the user features can be something like age gender location and so on right but ID can be user ID and item can be item id how that can be used I will explain that as well so the idea is that you will have two towers one for user one for item you will pass user features item features and come up with embeddings and uh the the idea is that the embedding uh will be in a vector space where they are comparable and if the dot product of user embedding and item embedding is high that means for this item this uh item here uh is relevant and and and I will make one clarification that I am using item media all this synonymously so it means the same thing that content the content to be shown to the user uh now I will explain things in more details so let's say the user Tower what user Tower will have user features like uh age gender location what they have recently posted what they follow their engagement metrics and so on this can be the non ID Fe features and there can be ID features as well ID can be the user ID how you can use ID you can take the user ID and pass it through an embedding layer right so for each user you will pass it through embedding layer and uh as many users in the platform those many uh uh this um like ID to Vector conversion it will be needed so you can pass all the user features you can pass user ID as well if you want to like I've seen people use ID not use ID because as soon as you use the ID your model becomes heavy heavy because there will be many users in the platform right so uh but that can also be used so you can uh if you're using the ID you can pass the ID through embedding layer and other features normally uh and then you can concatenate the two things one is ID based embeddings and the these features and pass it through the user tower now what what what it means by user Tower item Tower what are these towers these towers are nothing but layers of neural network where you you you will have some uh neurons and some nonlinear activations and so on and finally you will have uh here the embeddings let's say the final uh layer neural network has 1 to 28 neurons then you will have 128 dimensional embedding right you can consider that as the embedding so in the in this way you get the embedding representation of user similarly you find the embedding representation of item and the overall idea is that they come up in a vector space where they are comparable and their dot product means something and what it means if it's high the for that user this item is relevant if it's low for this user this item or media is not very relevant and in the media tower or item Tower what kind of features you can pass you can pass features like for this media for this real what what is the caption what are the content details how the engagement metric has been how many users have interacted with it what is the like proportion uh like by view comment by like share by like save by like in this way you can create features and hashtags you can um since there will be many hashtags in the platform what you can do is you can run a clustering on these hashtags and pass the cluster ID of that hashtag as a feature something like that as a categorical feature um or or even that those you can has TXS you can convert into embedding and pass so there lot of uh creativity you can show in the uh uh this items features creation you can also have location time of the media when it was uploaded and aggregate user engagement data is I was talking about how many people people have likeed commented interacted with and so on so that you have a rich media features you have Rich user features and then you are passing it through neural networks come up with iddings which is the vector representation and if they are they are comparable if the dot product is high means they are important for each other the user and this media is important for each other so that's the idea of two Tower uh retrieval model and um uh bit more details about this model how it's used in online serving When U in in real time when the user comes to the platform what you do is after this model is trained you can just chop off right you can chop off from middle you will have the user Tower you will have the item Tower so you can chop off and just uh uh use the item Tower in a offline way so what it means is that uh the items uh properties won't change a lot right it may possible that more users have liked it commented on it but overall the properties won't change a lot so what you do is you generate item embeddings in an offline setup you like morning once in a batch mode you will generate the embeddings for all the items and keep it in a vector database and user like user might have interacted with some media just 2 three seconds back right and user we know that the user Behavior Chang changes very fast so this you can keep in real time as soon as you as soon as user comes to the platform you you get gather all the user features pass it through the user Tower which is the user neural network get the embeddings and from this Vector DB you can do a fast approximate nearest neighbor search and you get the candidates candid means these are the top items which can be shown to the user uh so this is uh the two Tower neural network and one of the uh candidate generators one of the candidate generators in the Instagram explore recommendation system there are other candidate generators as well but this is very important as uh like if you see the vitage of media coming from all the candidate sources it might be high for this and many companies are using 2A neural network and they are finding it very useful uh we will uh also understand why this neural networks are very uh like giving very good candidates uh in upcoming slides but that's the overall idea and one more thing uh you don't always have to use the two towers together like what you can do is you can use the item Tower independently as well because when I was saying in the last slide we can also show Media which similar to what user has interacted so what you can do is you can just take the item embeddings and find similarity between them that with this reel which other reel or which other post is similar so Instagram also also uses item embeddings directly to retrieve similar items to those for a users interaction history so in that way you can either use just one Tower and find similar items within it or you can use the user embedding uh and find which media are relevant by doing a DOT product and sewing it so it's actually not or its end because both are two different candidate sources right so in that way you get more Medias to be shown to the user now I will take a slight detour from Instagram recommendation system and I will uh come back to it shortly just uh to tell you the importance of this two Tower retrieval model why is it so important so what is a two Tower model it's just a deep learning neural network where you have two entities you pass you gather their features pass it through the neural network which you call as Tower you get the embeddings and the idea is that they become comparable in the vector space their and their dot product means something High means they are um relevant for each other low means they are not relevant so why is it so generic uh it's so generic because it's used for a variety of task for a e-commerce prod company like Amazon or misho it can be something like U user Tower and e-commerce product Tower right but for Instagram it can be user Tower and media like post video Rel for LinkedIn or Twitter it can be user and user for this user which other for this user which other users are relevant so for LinkedIn and Twitter it can be used for friend recommendation for for Wikipedia or Google kind of uh search uh companies it can be query Tower and document Tower so in that way uh the two Tower uh uh retrieval model or or two Tower model is very generic where the two towers can be any entities and the idea is same that we bring them in a vectory space where they are comparable uh moving on so coming back to Instagram's recommendation system uh we have shown that uh the uh in the initial slides that there is a retrieval phase and ranking phase we have covered the retrieval phase where we looked at multiple media sources different type of CGS now we will look at the ranking stage and it happens in two stages right so moving to the ranking stage of Rec uh Instagram uh in the first stage ranking they out of the let's say thousands of items they further filter down to the top 100 items and they again use a twoot tower neural network for uh first stage ranking but it's clearly mentioned in their blog that even though the first stage model is a twoot tower uh architecture the objectives are completely different as in here we are trying to predict the probability of like like we are trying to predict whe the whether for this item the user will like it or not or user will comment it or not something like that so objectives are very different and the reason this two Tower is used because it's lightweight and they want to just uh filter out some of the not so relevant items from the relevant thousands of items and in the uh Second Stage ranking is where a deep heavy mtml neural network is used what is mtml it's multitask multi-level now multitask means the same neural network will be uh solving multiple tasks predicting the probability of like comment shave share and so on so and uh and it's a very heavy architecture as in there will be multiple layers and also it will uh take into account the uh powerful cross features which is user cross item features which has not been used still now so I want to emphasize a bit on that like this cross features so what happens in uh the two Tower model which is the retrieval phase we know that we will finally chop it off and use it in this way right so we pass the user features we pass the item features but we never get to pass user cross item features that for this user depending on the media category how relevant that media categories that this user may be more interested in cricket uh category we never get to use those kind of cross features because the user and item features are kept separate the two towers are separate but in case of ranker you can use the powerful cross features which we missing so let me explain these cross features so uh for user we we won't have the media features right because the user might have not seen this media but we can have the media category features as in this media will belong to some broader category it can be Cricket or it can be news it can be uh it can be something uh like TCH or so on right for this user how much relevant this category is and you can have features around user cross category similarly this user may not have interacted with the media but you know that you user belong to which cohort of users and for this cohort of users how the interaction with this media has been so you can have media cross user cohort features in two Tower model where you don't have the capability to add this cross features because it will just blow up and you don't know that which uh user can come in user Tower which media can come in media tower but here since you know that these are the hundred of items and you can have a very heavy and more uh powerful uh deep learning neural network you can have this kind of cross features as well which will learn help you learn the task better and task here is like predicting the probability of Click predicting the probability of like uh and so on and uh it's multitask multi multitask we have already seen multi-label means that even for like you can have like or not like one zero and also if the user spends time you can consider it as partial like so there can be multiple labels or uh values 0 1 two for a task so in that way it's a powerful heavier multitask multi- deep neural network model which uses even the cross features a part of the definitely using the uh entity features so this is how the ranking happens it will give you different probabilities and then you can calculate a function expected value is equal to you can give some uh weighted combination of different probabilities and come up with a value and uh you can rank order items in descending order of this value and this that is how your Instagram uh media recommendation works from retrieval phase the relevant media comes and in ranking stage in the first stage you further uh filter out the most relevant ones and then the rank ordering comes from this neural network which will give you probabilities and that will be waited uh to come up with the final function so with that we have uh so with that we have covered the uh like uh the in Instagram uh explore recommendation system next uh I will talk about before before uh jumping to Twitter and Pinterest recommendation system which are like very smaller part uh not as big as the Instagram recommendation system I will talk about one more thing the and I think this is very relevant for this particular conference that why deep learning based rankers and with ranker I mean this kind of ranker model right why deep learning based rankers are outperforming tree based rankers in case of recommendation system and if you think about it uh and if you do uh more research around it there are mainly three reasons why deep learning uh models are overpowering these three based models the reason being the first is use of embeddings these deep learning models are taking maybe the ID based features and calculating the embeddings embeddings can be added in your model in two ways either you can use already the pre-trained embeddings as a feature or fine tune it in the process or you can learn embedding in the ranking process ranking model only right but one thing is that they use these embeddings which are capturing the latent features for ID based features and non ID based features as as well so embeddings provides that extra Edge to these deep learning neural network ranker models second is that I was talking in the beginning that even the sequential pattern of the interactions are used like those clicks views uh or uh for e-commerce company the uh product add to card uh click and ordering how the flow is coming we also look at the sequential pattern that how this interactions are coming the order in which they are coming and we apply this attention mechanism or Transformer module to it to learn more richer representation so another advantage that this deep neural network have is the use of this attention mechanism to learn more richer representation or more richer embeddings and finally uh also the goodness comes from multitask multi-levels so you are having one neural network which is finding probability of like click um and command share and so on so the neural network has exposed has been exposed to more Vari pattern data right so it has that uh ability to learn from multiple task and each task may have multiple labels so model learns multiple task and that introduces it to more VAR pattern in the data and learn stronger representation compared to a treebase model so these are the main reasons why these deep neural networks are winning over a tree based model but still if you are starting a startup and you don't have a lot of data I will suggest you start with simpler models and when you become a bigger company and you have uh more user data available more interaction data available then you can shft to this deep neural network models which will give you an extra Edge and uh gains over your previous models next we'll quickly look at uh Twitter's uh recommendation system for Twitter recommendation system we will just look at the retrieval phase we want go to the rank in model so for Twitter we will look at the who to follow recommendation that is account recommendation you can also uh draw similarity between this and Facebook friend uh suggestion where it ask give you suggestion that add friend request give send friend request to these persons right so how does Twitter suggest that which are the users to follow so it's called account recommendations who to follow is a critical uh piece that helps people connect with accounts relevant to their personalized interest so for the retrieval phase uh what they do is they use they again use a two Tower model but here the two towers are user cross user right and uh like it makes a lot of sense when I explain it so they are what they are doing is for the same user uh we will have a consumer Tower and a producer Tower the idea is that uh the consumer Tower will will analyze users consumption Behavior while the product Tower or producer Tower will um gather the users production behavior and it makes lot of sense I will give an example as a content creator I create content around data science so as a producer my uh content is more around data science but once it comes to consumption I consume data science I consume Tech I consume movies related post and I am a big martial arts fan so I consume what's going in the UFC world or mix martial arts word so as a consumer my pattern are different and when I produce things my producer I only produce in data science uh content so my produce Sy features are different so that's the main idea that for a user we will have it have their consumption behavior for the consumer Tower the personalized features of the users will be used for example what they are interested in what they likeed recently which location they belong to what are the topics they are interested in this kind of personalized user features and for the producer Tower we look at what they have produced right and as well as whatever they have produced we can do an aggregate over the audience which have liked it so so what is the properties of the audience which are liking the comment they have which liking the content they are uh producing and some follower Aggregates features so that is what we have joted it down producer Tower leverages aggregate audience characteristics and incorporates graph based features to more effectively capture user producer attributes and the idea is same that once you have for all the users their consumption and uh producer uh features you can have their consumer embedding and producer embedding you do a Dr product if for a user consumption pattern is very similar to what if other user is producing then you can recommend them as a follow uh person that you can follow this person so that's the idea and how to train this model you can take the follow follow following relationship from historical data and use those labels to train your uh model and uh you would know where the user followed and some random uh follow some random users you can also use for label zero that they didn't follow each other right because those are just random uh users you can use a zero level and the actual follow follow following relationship of the historical data as one label and chain your model and see in the out of time uh that uh validation that how good your model is performing so this is how the Twitter who to follow recommendation works you have the consumer embedding and prod producer embedding and consumer which are most likely to uh convert to a producer because of similarity in their embeddings are recommended recommended in the uh accounts recommendation and uh then once we have all the retrieved uh users which can be recommended there will be a ranking phase which will just rank order them in terms of conversion uh enough of recommendation system ranking and retrieval now we'll look at a slightly different uh part of the game uh which is satisfying the business constraint so so let me explain it this way uh the the scalable recommendation systems are built using retrieval and ranking phase to optimize for conversion but sometimes business may have different objectives and those objectives also have to be satisfied these business objectives can be something like uh also give visibility to Fresh content or new users or something like you have a platform form till now you only had images but now you are moving towards videos as well and you have limited videos so how can you boost your video content by B percentage like at least b% of the views should go to your video video content and in the last example the fresh content should get at least a percentage of the views similarly sometimes what happens there are deals between companies and you see that um like uh for for some of the sale Amazon would have sponsored with uh SP would have sponsored recommendation for a particular brand and so on so when there are this kind of collaboration with a group we uh there are uh needs that at least C percentage of the views have to be provided to them sorry yeah so uh this business object constraints can come on top of your recommendation systems like fresh content has to be given a percentage of views some specific type of content has to be given B percentage of views or sometimes some specific group has to be given C percentage of the views now how to achieve this exactly this percentage of view contribution uh or give these uh uh go this type of groups uh exactly this much percentage of views share in your platform one way is that you can um give them slots right but uh as your object Ives increases it becomes impossible to give slots to everyone right and uh let's say you have 10 such constraints how would you manage slotting so what companies usually do is after you have that um uh after your recommendation system once you have the rank ordering of the items uh that this is the rank ordering in which user will be shown this item what you can do is you can boost and debost boost and OTE the ranking scores so so basically I will give an example U like this is your final value right this is your final output or final score value you have after this calculation what you can do is you can make some adjustment in that score you can either increase for some item for some item you can decrease it in such a way that these constraints are satisfied and what is that more structured way of boosting and deboosting there are some um uh ways in which you can implement controllable distribution and one such way is PID which is which stands for proportional integral derivative the idea is very simple uh if you have to give a percentage of the views you can start with some views and if you are giving more views you will uh reduce the score for that group so that the views reduces over the time so with time you continuously have a feedback mechanism which is based on P ID p is TS for proportional proportional to the error in um actual views you need to give and what is the views you are currently giving I integration so you look at the cumulative error till now the sum of Errors till now and D is derivative you look at the rate of change of error and what is error error is just that how many views percentage has to be provided and what is the current views going on so in that way you can come up with simple error and have this feedback mechanism which at every time period will boost or demote the scores in such a way that finally all your constraints are uh closely satisfied so and and it works great companies use it a lot this kind of cont controllable Distribution on top of your recommendation systems score to uh to satisfy the business objectives uh so uh with that like I would like to conclude whatever we learned in uh today's session or the I would say the main highlights that I would like you to remember one is that the modern day scalable recommendation systems are built in two phases retrieval phase and ranking phase retri phase retrieves the relevant item out of millions of items and ranking phase rank them in order to better the conversion and secondly second highlight would be for retrieval phase two Tower based neural networks are used a lot due to its genric natur and cable properties cable properties means the as I was showing the two towers can be chopped off one can be offline one can be online right and also you can do fast approximate nearest neighbor search so because of this this two Tower based retrieval models are very popular now coming to the ranking phase deep learning models are bringing stateof art performance and why these deep learning models are bringing state of art performance and beating traditional ml algorithms like tree based and all because of these three things one is use of embeddings used of sequential nature in the interaction data the order in which the user interacts and also the goodness of multitask multi-label data makes this deep learning models a winner uh over uh the tree based models and finally on top of the recommendation system scores which are built to maximize the conversion when you have to satisfy additional business constraints you can Implement a controllable distribution something like PID uh to uh satisfy uh the business constraints which can be around a specific group or content or some other business ask so with that I would like to conclude my session and I am I would be happy to take any question s if there so what is the type of uh I I can see I can see some questions on the chat window the first question is what is the type of input for model like images text and number yeah that's a good question like uh for uh so uh for different type of content you can come up with the features right and image can be one of the features so what you can use what you can do is you can use image embedding uh along in the media tower or in the uh as as a image or media feature so for image you can use the embeddings of it and for text what you can do is as I was saying like for Instagram kind of profile I will just stop sharing uh for for for Instagram kind of U company where you have lot of hashtags now you can't convert each hashtag into uh categorical VAR I mean it can be one categorical variable but converting back into one hot encoding may not be possible right so what you can do is you can uh cluster these hashtags and provide the cluster ID as uh as one of the features or other thing that you can do is even for the hashtags or description you can pass it through the embedding uh some pre-trained embedding and use this pre-trained embedding as a feature so for text and images you can use embedding and for number you can just pass the numerical features as it is and uh uh and finally you have all the features for that uh that particular entity and also I would like to say that people are using this cross entity features as well right user cross media cohort and media cross user cohort is input in do CSV file for user Tower uh it like like it depends how you are implementing it right like you have lot of data you can you can batch stream it and all so it depends on how you are implementing it and mostly what I have seen is that like in this scalable systems like all the features are kept in redis which is uh like a u very fast cable database you just as soon as the user come to the platform you have just some milliseconds to show recommendations so you quickly retrieve the uh features from this Rish and other this kind of databases and then you pass it through the model and model is also exposed as an API you quickly pass it through the model uh and get the probabilities get the final bunch of items that needs to be shown to the user in the same order in which they has to be shown and push it to the app in which they will be visible which user engagement metrics are considered most important in refining recommendation Instagram yeah I would uh like this question is very good uh so uh I think I should have a slide around that as well uh maybe I will talk about it how will you analyze how good your recommendation system is right so there can be uh two ways one is that I would say there can be three ways while training the recommendation System model you can look at the ml metrics which is uh accuracy pron recall for recommendation systems there are uh metrics like ndcg um and mean uh M mean average pron and so on so you can look at this uh this ml metrics but when you are designing designing this recommendation systems for companies industry you also need to look at business metrics like uh daily active user monthly active user how's the gmv of the platform trending how the revenue of the platform trending and how your slot utilization is whether you are able to utilize all the slots or not so these are some of the business metrics you can look at and also with time is are your recommendations doing okay or not what you can do is you can look at uh you can look at the drift in performance with time um and you can also look at some other metrics like diversity and so on that how diverse your recommendations are uh for for for a Instagram kind of app there will be lot of Medias right so it should not happen that only uh 20% of the media are getting lot of user attention remaining 80% are are not getting so a good recommendation system is one which is more democratized as in uh the 80% or 90% of you share is going to good percentage of media so in these kind of metrics also you can uh judge the performance of your recommendation system so summarizing it you need to look at ml metric business metrics and and some fairness or good to have metrics in recommendation system like diversity stivity um freshness how fresh your recommendations are and so on and also you need to look at the drift whether the system is performing well with time or not would love to take if there are any more questions and anyways you guys can connect with me over LinkedIn and I have a channel
Up Next

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

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

HTTP Requests Explained: GET, POST, PUT, DELETE
@codecademy
103.1K views•2021-10-07

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








![[DS시리즈*] 10. MLP (Multi Layer Perceptron) | 10. 딥러닝](https://i.ytimg.com/vi/k8n3gH5R8Hs/maxresdefault.jpg)












![[ИТ-лекторий] Рекомендательные системы: от простого к сложному и обратно](https://i.ytimg.com/vi/kTWVGOvws8Q/maxresdefault.jpg)

















