I am going to implement a recommender system based on this paper. It basically uses a double embedding technique, one for the user representation and another one for the products (movies, clothes, whatever you are trying to sell.)

I understand thay you can easily train the embeddings based on a Boolean target that represents the interest of the user in a certain product. Let's say that the output layer of our NN would be a simple sigmoid (so we can assume this output as the probability that the user likes the product).

Once the training is done, I understand you want to recommend the $n$ top products. But if your dataset contains millions of products you cannot find the real top $n$, I guess some approximation or simplification should be used, but I could not find any information related to this. Any suggestion?


2 Answers 2


A common approach in practice is to first filter the dataset with a light model to generate a candidate set, and then apply the heavy model only to those candidates. This approach is used, for example, at YouTube (Covington et al., 2016).


A common approach to avoid the need of scoring all user-item combinations is to use approximate nearest neighbor techniques (ANN). With these techniques you can cluster you item latent vectors and only calculate scores with the vectors of some cluster instead of all the item latent vectors. For more details, I can recommend the following blog article by Erik Bernhardsson : Approximate Nearest Neighbours for Recommender Systems

Python Libraries that might help you: faiss, annoy, nmslib

Assumption and some Background: I assume the question relates to the computational cost of scoring all user item combinations in order to retrieve the top-n recommendations. A little bit more background: the output of standard collaborative filtering based recommender models is two embeddings (latent vectors), one for users and one for items. To get to the top-n recommendations per user one has to do the following:

  1. multiply each user vector with each item vector to get the scores for the respective user-item combinations
  2. per users sort descending by this score
  3. Take top-n recommendations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.