1
$\begingroup$

I think the cosine similarity of negative values has its own meaning.

If you softmax the cosine similarity of Q and K, wouldn't it prevent Transformer from using information with the opposite meaning?

$\endgroup$
1
  • $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community Bot
    Mar 24 at 6:51

1 Answer 1

1
$\begingroup$

Consider that before the attention block, you apply a (trainable) linear projection, and that there are many attention heads.

enter image description here

This gives the needed degrees of freedom to handle the potential logic of negative cosine similarity that you think the model is lacking. For instance, one head might learn to rotate the query while another one might learn not to rotate it.

$\endgroup$
6
  • $\begingroup$ If we make good use of the cosine similarity of negative values, can't we get the information that we can get from two heads from one head? $\endgroup$ Mar 24 at 10:50
  • $\begingroup$ Maybe, but that would be a different model. You can experiment with that approach. $\endgroup$
    – noe
    Mar 24 at 11:02
  • $\begingroup$ Please, consider accepting the answer (with the tick ✓ next to it). $\endgroup$
    – noe
    Mar 24 at 11:03
  • $\begingroup$ In fact, I posted it on Stack Overflow for the first time. I appreciate you for replying. @noe $\endgroup$ Mar 24 at 11:56
  • $\begingroup$ At relu activation, cosine similarities with values below a certain value are likely to be treated the same @noe $\endgroup$ Mar 24 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.