-
Notifications
You must be signed in to change notification settings - Fork 657
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
Allow additional parameters in compute_mat
#697
Comments
Hello @KevinMusgrave |
Would overriding the
I guess it depends where |
Or do you mean you need to change the |
Exactly @KevinMusgrave, I am already using the very nice NTXentLoss. Recently, I discovered that scaling the simple dot distance with the rewards associated with each embedding is beneficial for my research task. At this point, I need to access the embedding identifier because each embedding has its associated reward. |
I see, so you also need to modify NTXentLoss to take in those ids? |
If there is no other overriding approach, yes. |
Yeah I don't think there's another approach. The only other way would be to set some attribute of your custom distance object before computing the loss. dist_fn = CustomDistance()
loss_fn = NTXentLoss(distance=dist_fn)
...
dist_fn.curr_ref_ids = ref_ids
loss = loss_fn(...)
# inside dist_fn refer to self.curr_ref_ids |
I see. For a feature release, it would be great if the |
Hello, Is there any progress here? |
Sorry, no progress yet |
Hello,
The following code snippet shows a custom distance function that scales the simple dot distance with the rewards associated with each embedding.
However, the loss function call of
mat = self.distance(embeddings, ref_emb)
not allows calling the overridden methodcompute_mat(self, embeddings_ids, embeddings, ref_emb_ids, ref_emb)
(containing the embeddings and ref_emb ids) required to get the embedding reward and scale the corresponding distance value.Is there a workaround?
Thank you.
The text was updated successfully, but these errors were encountered: