Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use sample_weights for retrieval task? #732

Open
modic23 opened this issue Aug 5, 2024 · 0 comments
Open

How can I use sample_weights for retrieval task? #732

modic23 opened this issue Aug 5, 2024 · 0 comments

Comments

@modic23
Copy link

modic23 commented Aug 5, 2024

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'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant