question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Save & Serve tfrs that does not recommend items previously interacted with using BruteForce layer

See original GitHub issue

I am working with a relatively small data set and am noticing that users are being recommended a lot of items they have previously interacted with and I would like to pre-filter out these items before saving and serving the mode on ai platform. I realize this could also be done after the list has been generated, but the way our app works makes it rather difficult (and slow) to filter post hoc on the client side.

I have seen a few other issues addressing related questions (e.g., 307, 113). However, I have not seen a definitive solution, and these seem to deal with either excluding a set of items for all users (rather than a unique set for each user), or excluding items from test recommendations.

Currently, I generate an index with 80 recommended items: index = tfrs.layers.factorized_top_k.BruteForce(model.user_model, k = 80)

and then remove any duplicates that existed in the training df: index.index_from_dataset( tf.data.Dataset.zip((unique_recipe_id_pred.batch(80), unique_recipe_id_pred.batch(80).map(model.recipe_model))))

This works well, but how could I also exclude items in the index that users have interacted with? Could the query with exclusions function be a possible solution?

Apologies if I have missed something here and thanks in advance for any advice!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
yrianderreumauxcommented, Nov 19, 2021

@maciejkula & @patrickorlando thank you both for your thoughts on this. I am curious if you could point me to any code regarding the second option of wrapping the BruteForce index in a model with logic, I fear my technical skills are not sufficient to figure it out alone. In the meantime, using your suggestion we have added a middle (business) layer using React Native to filter out previously interacted with items, which whilst slowing us down ~.5 seconds per call, has solved the problem.

2reactions
patrickorlandocommented, Nov 18, 2021

You need to track the state of what user’s have interacted with separately from the model. If for each user you maintain a list of item_ids that the user has interacted with, you can then filter them out in your caller API, or wrap the BruteForce Index in a model with some logic to remove them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Excluding previously seen samples from test ...
Save & Serve tfrs that does not recommend items previously interacted with using BruteForce layer. I am working with a relatively small data ......
Read more >
Predict values with tensorflow recommender system model ...
Has anyone used the TFRS with context features and found a way to predict item values for a (user, feature)-combination? Does anyone have...
Read more >
Train and Deploy Google Cloud's Two Towers Recommender
In this article I will approach recommendation algorithms when you ... will recommend products/services to a customer based in his/her previous purchases.
Read more >
Movies Recommendation Systems with TensorFlow
Furthermore, owing to its nature, this system makes only safe recommendations. Collaborative Filtering: In this method, we don't have any metadata about the ......
Read more >
Intro to Recommender Systems with TensorFlow and TFRS
A recommender system algorithm tries to predict the missing values in that matrix, and recommend the items that it predicts with a big...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found