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

Why torch.abs() can get better performance in sentence-pair matching tasks? #1755

Open
BruceStayHungry opened this issue Nov 12, 2022 · 0 comments

Comments

@BruceStayHungry
Copy link

When learning the code of sentence-transformers, I noticed the usage of torch.abs() in calculating the difference of sentence vectors. The below code is from the forward function in SoftmaxLoss

if self.concatenation_sent_difference:
            vectors_concat.append(torch.abs(rep_a - rep_b))

I am curious about the effect of torch.abs() so I compared a paraphrasing task with or without torch.abs().
Results show that using torch.abs() is much better than not using it.

My question:
Why using torch.abs() is better?

Please forgive my ignorance and thanks for any explanation!

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