SPTAG icon indicating copy to clipboard operation
SPTAG copied to clipboard

How to set Cosine similarity as distance method with the Python Wrapper?

Open hadeson opened this issue 6 years ago • 2 comments

From GettingStarted.md I figured that we can use L2 distance by: SPTAG.AnnIndex.SetBuildParam("DistCalcMethod", "L2") What is the value for cosine similarity distance?

hadeson avatar May 30 '19 08:05 hadeson

I believe it is Cosine.

m0baxter avatar May 30 '19 18:05 m0baxter

@m0baxter Using the same code as Singlebox PythonWrapper section in GettingStarted.md I tried Test('BKT', 'Cosine') and the search result is: [0, 1, 2] [1.0, 1.0, 1.0] [0, 1, 2] [-5.324554920196533, -5.324554920196533, -5.324554920196533] [0, 1, 2] [-11.649109840393066, -11.649109840393066, -11.649109840393066] I believe it should be the same as Test('BKT', 'L2'), which is: [0, 1, 2] [0.0, 10.0, 40.0] [2, 1, 3] [0.0, 10.0, 10.0] [4, 3, 5] [0.0, 10.0, 10.0] Also any tag other than "L2" would gives the first result.

hadeson avatar May 31 '19 03:05 hadeson