AI Made Easy: One article explains the two tower system of the recommendation system (two tower system)

Two Towers Recommender System is a collaborative filtering algorithm used in recommender systems. It's called a "two-tower" system because it consists of two neural networks, or "towers," that work together to generate personalized recommendations for users.

working principle

The first tower is called the "User Tower". It takes as input a user's historical interactions with items, such as products purchased by the user or movies watched, and converts this information into a fixed-length embedding vector representing the user's preferences. This embedding vector is then passed to the second tower.

The second tower is called the "item tower". It takes as input metadata about all items in the catalog, such as title, description, type, and other characteristics. The item tower also converts this information into a fixed-length embedding vector representing each item.

The two embedding vectors from user and item towers are then compared using a similarity function such as cosine similarity. The similarity score indicates how similar the user's preferences are to each item in the catalog. The item with the highest similarity score will be recommended to the user.

Since the two-tower recommender system can handle large-scale and sparse datasets and capture complex user-item interactions, it is a popular approach for personalized recommendation. It has been used in various applications such as e-commerce, streaming services and social media platforms.

How to train with deep learning

In the two-tower recommendation system, the neural network that generates the user and item embedding vectors needs to be optimized so that the dot product of the item embedding vectors purchased by users and the embedding vectors of unpurchased items is higher. This is usually achieved through a process called training, in which the model is presented with a set of user-item interaction data and learns to predict the likelihood of each user interacting with each item in the future.

During training, the model is optimized to minimize a loss function that measures the difference between predictions and actual user-item interactions. The most commonly used loss function in recommender systems is the binary cross-entropy loss, which penalizes the model for making wrong predictions.

To optimize a neural network, backpropagation is used to compute the gradient of the loss with respect to the model parameters. These gradients are then used to update the model parameters using an optimization algorithm such as stochastic gradient descent or Adam. The process of updating model parameters is repeated for multiple epochs until the model converges to an optimal set of parameters.

By optimizing the neural network in this way, the model learns to generate user and item embedding vectors that capture latent patterns and relationships in the data, and are able to accurately predict user-item interactions. This enables the Twin Towers recommendation system to provide personalized recommendations, tailored to each user's preferences.

Efficient real-time reasoning

When computing the dot product of a user embedding vector with the embedding vectors of all items in the item tower, there are several techniques that can be used to make the computation more efficient and faster. Here are a few ways:

Use matrix multiplication: Rather than computing the dot product of the user embedding vector and each item embedding vector individually, it is more efficient to perform a matrix multiplication computation of the user embedding vector and the entire item embedding matrix. This can be done using numpy or PyTorch libraries, which are already optimized for matrix calculations.

Use Approximate Nearest Neighbor (ANN) search: Computing the dot product between user embedding vectors and all item embedding vectors can be very expensive when the number of items is very large. One way to speed up the search is to use an approximate nearest neighbor search algorithm such as Locality Sensitive Hashing (LSH) or a kd tree. These algorithms allow us to quickly identify a smaller set of candidate items that are most similar to user preferences.

Use caching: Since user embeddings are fixed during inference, we can cache the dot product between user embeddings and all item embeddings. This can be done ahead of time during training, or dynamically during inference. By caching the dot product, we can avoid computing it every time a user requests a recommendation, which can significantly speed up the recommendation process.

Use parallel computation: If the hardware allows, we can compute the dot product between the user embedding vector and all item embedding vectors in parallel. This can be done using multithreading or GPU parallel computing, further speeding up the recommendation process.

By using these techniques, we can make the dot product computation between user embedding vectors and all item embedding vectors more efficient and faster, thus helping to improve the performance of recommender systems.

English link

Link

AI Good Book Recommendation

AI is changing with each passing day, but a high-rise building cannot be separated from a good foundation. Are you interested in learning about the principles and practice of artificial intelligence? Look no further! Our book on AI principles and practices is the perfect resource for anyone looking to gain insight into the world of AI. Written by leading experts in the field, this comprehensive guide covers everything from the basics of machine learning to advanced techniques for building intelligent systems. Whether you are a beginner or an experienced AI practitioner, this book has you covered. So why wait?

The principles and practices of artificial intelligence comprehensively cover the classics of various important systems of artificial intelligence and data science

Peking University Press, Principles and Practice of Artificial Intelligence Artificial intelligence and data science from entry to proficiency Detailed explanation of machine learning deep learning algorithm principles

Guess you like

Origin blog.csdn.net/robot_learner/article/details/129234403