Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

cosine_scores defined in biencoder.py does not work #232

Open
xhluca opened this issue Sep 5, 2022 · 0 comments
Open

cosine_scores defined in biencoder.py does not work #232

xhluca opened this issue Sep 5, 2022 · 0 comments

Comments

@xhluca
Copy link

xhluca commented Sep 5, 2022

Reference:

def cosine_scores(q_vector: T, ctx_vectors: T):

F.cosine_similarity will fail to compute the similarity along a specified dimension when the other dimensions differ. For example, if x is a 10x64 tensor, and y is a 20x64 tensor, then it is expected to get a 10x20 matrix when calling cosine_scores. However, that function won't work:

>>> x = torch.randn(10, 64)
>>> y = torch.randn(20, 64)
>>> F.cosine_similarity(x, y, dim=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: The size of tensor a (10) must match the size of tensor b (20) at non-singleton dimension 0

Since it is not used anywhere else in the repo and the paper, maybe it would be a good idea to remove cosine_scores?

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

No branches or pull requests

1 participant