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

Giving hard_negative a higher weight when calculating loss #2910

Open
yjoonjang opened this issue Aug 24, 2024 · 1 comment
Open

Giving hard_negative a higher weight when calculating loss #2910

yjoonjang opened this issue Aug 24, 2024 · 1 comment

Comments

@yjoonjang
Copy link

yjoonjang commented Aug 24, 2024

Hello, I am a Korean student who loves the work of sentence-transformers team.
I've used a lot of losses you made when finetuning an embedding model.

However, I thought that it will be nice if there is a loss that gives hard_negative a higher weight in loss calculation.
For example, the input will be like: (anchor, positive, hard_negative) triplets,
and when caculating loss, utilizing
lambda * (similarity between anchor-hard_negative) + (1-lambda) * (similarity between anchor-in_batch_negatives)
looks pretty good for me.

Because the input consists of (anchor, positive, hard_negative),
in-batch negatives will include both positives and hard negatives from same batch.

Can I hear your thoughts about this idea?
And also, it would be grateful if you let me know if there are some losses similar to this idea that I missed.

Thank you for reading.

@yjoonjang
Copy link
Author

@tomaarsen
Could you please check my issue? Thank you.

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