recommenders icon indicating copy to clipboard operation
recommenders copied to clipboard

How can I use sample_weights for retrieval task?

Open modic23 opened this issue 1 year ago • 1 comments

Hi,

I'm trying to build a retrieval model. I have positive samples and some weights corresponding to each of these sample which helps to denote that for the given sample how much weight it holds. I want to use these weights so that I have better recommendations from the retrieval model. I'm assuming that sample_weights param can help me to do this.

Let me know if I'm thinking in the right way and if yes, Is this the right way to do this?

self.task = tfrs.tasks.Retrieval(metrics=metrics) def compute_loss(self, features, training=False): q_emb = ... p_emb = ... return self.task(q_emb, p_emb, compute_metrics=not training, sample_weight=features['weight'])

modic23 avatar Aug 05 '24 11:08 modic23