recommenders icon indicating copy to clipboard operation
recommenders copied to clipboard

[Question] Would be possible to use TFRS with multiple independent indexes?

Open almirb opened this issue 3 years ago • 4 comments

Hi! Let me clarify this a little bit... In a scenario with more than 500 different stores, would it be possible to index the model to act as if there are several different models (one model for each store)? Eg: in each API query, we could pass the store_id... and the recommendations returned would only be linked to the items of that store.

If there is no alternative, the solution is to train 500 models anyway. :/

Thanks!

almirb avatar Jan 25 '22 16:01 almirb

Hi @almirb, Maybe you could build a multi-output model? In our case where we had multiple sets of candidates, I ended up creating a tensorflow functional model with multiple indexes as output.

inputs = {
   ### your definition of feature
  'feature1': tf.keras.Input(...)
   ...
}

outputs = {
   name: store_bruteforce_index(inputs) for store_bruteforce_index in your_store_bruteforce_layers
}

model = tf.keras.Model(inputs=inputs, outputs=outputs)

So when you run inference, you get recommendations for all the stores (outputs a dictionary) and you can select the one you want. You'll have a single master model instead of 500 models. Of course if you don't care about the other store's recommendations / eliminate unnecessary computations, I don't have a better solution for you.

ssridhar2802 avatar Jan 30 '22 03:01 ssridhar2802

You could build a single model for all stores, but index 500 separate BruteForce indices, one for each model. You would then query the appropriate index for a given store at serving time.

Does that make sense?

maciejkula avatar Jun 03 '22 21:06 maciejkula

You could build a single model for all stores, but index 500 separate BruteForce indices, one for each model. You would then query the appropriate index for a given store at serving time.

Does that make sense?

That sounds great! For now, I decided go to with LightFM... I probably would try TFRS again in the future. Thanks!

almirb avatar Jun 03 '22 21:06 almirb

Im also interested in this multi-tenant / multi-store approach.

Regarding BruteForce indexes for 500 stores, what if we had items that overlapped between indexes / stores?

Are there any examples or steps on how to implement multi store indexes?

[Edit] - Could you approach this problem by using the query_with_exclusions method, as described in #307

kylemcmearty avatar Jun 27 '22 14:06 kylemcmearty