recommenders icon indicating copy to clipboard operation
recommenders copied to clipboard

[Question] What are best practices to post-process predictions for inventory levels?

Open ageofneil opened this issue 3 years ago • 2 comments

Suppose I run the worlds last DVD-rent-by-mail service and we've developed a basic recommend model by following your excellent Recommending movies: retrieval guide. Everything is working great until we notice our model is recommending movies that are out of stock! What's a good way to deal with this? I can't train the model before every recommendation, so obviously some sort of post processing needs to be done to the recommendation. I'm not sure the right way to approach this.

ageofneil avatar Dec 08 '21 21:12 ageofneil

For example for

index= tfrs.layers.factorized_top_k.ScaNN(model.query_model, num_reordering_candidates=1000)
index.index_from_dataset(
    tf.data.Dataset.zip((items_map.batch(100), 
    items.batch(100).map(model.candidate_model)))
)

To query it and get recomendations with only in stock items you can create a list with out of stock items, items_exclusion_list

and use it like this

x, t = index.query_with_exclusions(query_doc, exclusions=tf.constant([items_exclusion_list]))

Otherwise,

You can get large number of recomendations and remove out of stock items

dartpain avatar Dec 16 '21 15:12 dartpain

@dartpain makes a great suggestion.

I will also point out that recommenders are almost always deployed within a larger system that contains a final business logic layer - in this case, that business logic layer would make database calls to ensure that whatever is returned to the user is in stock.

maciejkula avatar Dec 20 '21 18:12 maciejkula