Zero Labs
Industry News / AI

How Recommendation System Works on Youtube

Source · Towards AI By Vaishnavibhovi

From the publisher’s feed, collected in the ZeroLabs newsroom.

Youtube represents one of the largest scale and most sophisticated industrial recommendation system. This paper explores how video platforms use machine learning techniques to personalize recommendations. The study explains two stage recommendation processes and analyzes key factors such as time engagement and user behavior.INTRODUCTIONWith the rapid development of the digital world , video platforms have become the main source for information and entertainment. Youtube is one of the most advanced real time personalization system ever built. Youtube recommendations are responsible for helping more than a billion users discover personalized content.Three major perspectives :1. Scale : Youtube has large number of users and videos. The system has to handle a large amount of data.2. Freshness : Millions of videos are uploaded every second. It is important for a system to include new content and recent user activity.3. Noise : It is hard to understand user behavior . Instead of clear feedback, the system depends on indirect signals like watch time and engagement.Youtube recommendation is a complex integral of Artificial Intelligence(AI) , Deep learning , collaborative filtering and data mining. The system uses deep neural networks trained on huge datasets to understand user preferences and video features .The system analyzes search history, watch history , likes , dislikes and satisfaction surveys .2.SYSTEM OVERVIEWThe overall structure of the recommendation system is illustrated in figure 2. The system contains two neural networks :1. candidate generation 2. ranking.Figure 2 : Recommendation system architectureCandidate generation is the first stage in the recommendation system. It filters millions of videos and selects about hundreds likely to interest the user. It uses fast methods like content based filtering or collaborative filtering.Ranking is the second stage in the recommendation system . It involves sorting and selecting top recommendation candidates .It is a slower but more precise approach that allows for the inclusion of additional features.User Activity↓Candidate Generation↓Ranking Algorithm↓Recommended VideosCANDIDATE GENERATIONCandidate generation is responsible for quickly and cheaply narrowing the set of possible candidates down to a small enough set that can be ranked. It is classified into two types : content based filtering and collaborative filtering.1. CONTENT BASED FILTERINGContent-based filtering is a type of recommendation system that suggests items to users based on the similarity between the features of items and the user’s preferences. In other words, it recommends items that are similar to those a user has liked or interacted with in the past. The model doesn’t need any data about other users, since the recommendations are specific to this user. This makes it easier to scale to a large number of users.The model can capture the specific interests of a user, and can recommend niche items that very few other users are interested in.Input:A matrix representing user interactions with items (e.g., ratings, likes).Features of the items (e.g., genres, actors for movies).Output :A list of recommended items for each user.Content based filtering works on two components :1. Item representation : Each item is described by the set of features or attributes .Text — Description, keywordsVisuals — Thumbnail , imagesAudio — Music2. User Profile : A profile is built for each user, summarizing their preferences based on the features of items they have liked or interacted positively with previously.The recommendation process generally follows these steps:Analyze Content: Extract relevant features from items the user has liked.Build Profile: Create or update the user’s profile based on these features (e.g., a weighted vector of features).Match Content: Compare the user’s profile to the feature representations of other items not yet seen by the user.Recommend: Suggest items whose features closely match the user’s profile, typically using a similarity metric.2. COLLABORATIVE FILTERINGCollaborative filtering is about making predictions based on the actions and preferences of other users.The main types of collaborative systems are memory based and model based with further specialized approaches like hybrid and deep learning systems.1.Memory-Based Collaborative FilteringThis straightforward approach makes recommendations directly using the user-item matrix. It’s called “memory-based” because the system relies on the entire matrix to find similar users or items.User-User Collaborative Filtering: This method finds users similar to the target user based on shared preferences. For example, if User A and User B rate similar products highly, the system will recommend to User A what User B has liked but they haven’t interacted with yet.Item-Item Collaborative Filtering: Rather than finding similar users, this method identifies items similar to those the user has already interacted with. For example, if you’ve watched a particular movie, the system might suggest others with similar themes, directors, or genres.2.Model-Based Collaborative FilteringIn contrast to the memory-based method, model-based collaborative filtering builds a predictive model based on the user-item matrix. These models are typically more efficient and scalable, especially when dealing with large datasets.Matrix Factorization: One popular technique within model-based filtering is matrix factorization, like Singular Value Decomposition (SVD). This method decomposes the user-item matrix into lower-dimensional matrices, identifying latent factors (hidden patterns in the data) that influence preferences.Neural Networks: Neural networks and deep learning have been applied to collaborative filtering. These methods can capture more complex patterns in the data, improving the accuracy of predictions and recommendations.While memory-based methods are simpler and faster, model-based methods tend to scale better with larger datasets and can provide more accurate, nuanced recommendations by identifying latent factors that simpler models might miss.RANKINGIt sorts videos based on relevance and engagement .Here’s an overview of the process:Data Collection and Preprocessing: Gather user interaction data and relevant item features, and preprocess the data to handle missing values, outliers, and ensure compatibility with the learning to rank algorithms.Feature Engineering: Transform the raw data into meaningful features that capture user preferences and item attributes. This step may involve techniques like collaborative filtering, content-based filtering, and creating custom features specific to your domain.Selecting a Learning to Rank Algorithm: Choose an appropriate learning to rank algorithm based on your application requirements and data characteristics. Common options include pointwise, pairwise, and listwise methods, each with their own strengths and trade-offs.Model Training and Evaluation: Train the learning to rank model using labeled data, and evaluate its performance using relevant metrics such as NDCG, MAP, and MRR. Employ cross-validation and hyperparameter tuning to optimize the model’s effectiveness.REAL WORLD IMPLEMENTATION OF RECOMMENDATION SYSTEMBefore diving into challenges and limitations , it’s essential to understand crucial components of real-time recommendation system.1.DATA COLLECTIONData to power a real-time recommendation system must be acquired from various sources, such as user interactions, preferences, and content metadata. User-generated events are often ingested through streaming data platforms. Platforms collect various forms of interaction data, including watch history, search queries, clicks, likes, and viewing duration. This data helps in understanding user preferences and behavior patterns.For example, YouTube continuously records user interactions to build a dynamic profile for each user, which is later used to personalize recommendations.2. DATA STORAGEData must be stored efficiently, assuring it can be accessed and processed quickly. Redis is a common key-value store for recommender systems thanks to its exceptionally fast lookup.Platforms such as YouTube rely on large-scale proprietary datasets consisting of user interaction logs, including watch history, clicks, and engagement metrics. These datasets are not publicly available due to privacy and business considerations. Therefore, researchers often rely on publicly available datasets to study and simulate recommendation systems.3. DATA PIPELINESData pipelines are a series of data processing steps that enable the flow and transformation of raw data into valuable insights for businesses. These pipelines play a crucial role in the world of data engineering, as they help organizations to collect, clean, integrate and analyze vast amounts of information from various sources. Automating the processes of data engineering can ensure dependable and effective delivery of high-quality information to support decision making.4. DATA PROCESSINGData often must be cleaned, transformed, or otherwise prepared for analysis. This can include normalization or feature computation within an online feature store.One benefit of using a real-time data platform like Tinybird is that it offers an ergonomic query engine to perform data preprocessing using SQL. Engineers can use Tinybird’s materialized views to incrementally calculate features during real-time data ingestion so that subsequent requests to the recommendation engine are much faster.User Data → Data Cleaning → Feature Extraction → Model InputTypes of feedbackExplicit feedback :refers to that information collected by the system by explicitly asking users to rate how relevant are some items (either requiring a number, a comment or other information). Even though this lead to more precise information regarding user’s tastes, it is not promoted since it requires direct participation from the user and sometimes it influences in a bad way in terms of user experience.Implicit feedback : allude to no user participation required to gather information tastes. The system automatically tracks users’ preferences by monitoring the performed actions, such as which item they visited, where they clicked, which items they purchased, or how long they stayed on a web page.5. MODEL TRAININGThe Two Tower model is an efficient architecture for large-scale recommender systems. As illustrated in the diagram, it comprises two parallel neural networks: the “query tower” for users and the “candidate tower” for products. Each tower processes its input (User ID or Product ID) to generate dense embeddings, representing users and products in a shared space. The model predicts user-item interactions by computing the similarity between these embeddings using a dot product, enabling quick identification of potentially relevant items from a vast catalog. This makes it ideal for the initial “broad search” phase in recommendation systems.The Two Tower architecture’s full potential is realized through its integration with a vector store. By leveraging a vector store to index candidate vectors, the system can efficiently and scalably retrieve hundreds of relevant candidates for each user during inference.6. DEPLOYMENT IN PRODUCTION SYSTEMAfter training, models are deployed into production environments where they serve recommendations in real time. This step is crucial because the system must respond instantly when a user opens the platform.For example, when a user opens the homepage of YouTube, the system quickly generates and ranks recommendations within milliseconds.CHALLENGES AND LIMITATIONS1.Scalability and Real-Time Performance:Challenge: As e-commerce platforms grow, the recommender system must handle larger datasets and provide real-time recommendations.Solution: Scalability can be improved through parallel processing, distributed computing, and efficient data structures. To enhance real-time performance, optimizing algorithms and leveraging caching mechanisms can help deliver personalized recommendations promptly.The recommendation system must be able to scale and efficiently handle the growing amount of data as the e-commerce platform grows and attracts a larger user base.2.Cold Start Problem:Challenge: New users or items may lack sufficient historical data for collaborative filtering-based recommendations.Solution: To address the cold start issue, hybrid methods that combine collaborative filtering with content-based filtering or knowledge-based recommendations can be effective. Gathering more data on new users or items over time is essential for improving recommendations.When a new product is released or when a new user joins the platform, cold start problems arise because there is not enough historical data to make reliable recommendations.CONCLUSIONRecommendation systems are essential for modern content platforms. Youtube rely heavily on user behavior and engagement metrics. Ranking is a more classical machine learning problem yet our deep learning approach outperformed previous linear and tree-based methods for watch time prediction. Recommendation systems in particular benefit from specialized features describing past user behavior with items.Recommendation systems represent a powerful intersection of machine learning theory and real — world engineering.How Recommendation System Works on Youtube was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.