-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Idea] Learn from Positives and Negatives Using Two Retrieval Models #675
Comments
I looked at the code for tfrs.layers.factorized_top_k.BruteForce and realized I could create a nearly identical class (BruteForceFurthest) that returns the furthest neighbors by changing one line of code. Here is the relevant code excerpt from the call() function.
As you can see, I think it is as simple as negating the scores so that the "top K" scores are really the bottom K scores. I then trained a "negative" retrieval model on the negative examples and instantiated BruteForceFurthest as follows:
After creating that top_k_retriever, I can retrieve the candidates the user is least likely not to click:
Ultimately, I want to combine these candidates with the candidates from the "positive" retrieval model. I'm wondering if I can do so in a special BruteForcePosNeg class that computes the nearest neighbors from the "positive" retrieval model and the furthest neighbors from the "negative" retrieval model, somehow averages the scores, and returns the top scoring candidates. |
This is a really interesting topic. But I have some questions:
Actually, there is a method called Mixed Negative Sampling that can mitigate this issue. You can refer to my blog for details. |
Thanks for sharing the Mixed Negative Sampling method, @caesarjuly. I'm going to study it and try to figure out how it works. As for your questions: 1. Are the negative samples come from explicit user feedback? 2. If yes, is the dataset sparse or too small? 3. If not, the dataset could be very noisy, how to clean it? 4. Are the scores from two separate models comparable? The scores can be highly affected by the sampling strategy. How to calibrate it before fusing? 6. The original idea of in-batch negative sampling is to take other users' positive samples as the current user's negative samples. In general, this idea can provide fast training speed. But there could be an issue regarding the sampling distribution. |
In a recommendation system with retrieval and ranking stages, the retrieval model typically learns only from positive examples in the training dataset. Consequently, it fails to learn which items users don't like. The initial set of recommendations from the retrieval model may include items that the user doesn't like and exclude items that the user does like.
Below is an idea for leveraging negative examples in retrieval models to address this problem. The approach is to train two retrieval models:
Armed with positive and negative retrieval models, we can invoke both of them in the retrieval stage. We query the positive retrieval model, then the negative retrieval model, and combine the lists of recommended candidates. The wrinkle is that, instead of using the negative retrieval model to find the nearest neighbors of a query vector, we want to use it to find the furthest neighbors of a query vector. I'm not sure we can do so with tfrs.layers.factorized_top_k.ScaNN or tfrs.layers.factorized_top_k.BruteForce.
Thoughts on this idea, or any pointers to code, classes, or libraries for retrieving furthest neighbors?
The text was updated successfully, but these errors were encountered: