recommenders
recommenders copied to clipboard
[Question] What are best practices to post-process predictions for inventory levels?
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.
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 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.