I’m using embeddings with pgvector but when using cosine distance the results weren’t matching expectations so I decided to make sure my test example would work with Scholar, but the results are off in Scholar as well which implies to me that maybe I have the wrong expectations, and yet… after looking it up, I don’t think I’m misunderstanding.
Most simple example:
Scholar.Metrics.Distance.cosine(Nx.tensor([1,1]), Nx.tensor([1,1])) #Nx.Tensor< f32 5.960464477539063e-8 >
If two tensors are “pointing” in the same direction the cosine distance should be 1, but this is pretty much 0 implying that the tensors are “orthogonal” (not similar at all).
What am I doing wrong?
Do I need to subtract from 1?
Nx.subtract(Nx.tensor(1), Scholar.Metrics.Distance.cosine(Nx.tensor([1,2]), Nx.tensor([1,2]))) #Nx.Tensor< f32 0.9999999403953552 >