faiss icon indicating copy to clipboard operation
faiss copied to clipboard

when will METRIC_INNER_PRODUCT be fully implemented on GpuIndexIVFPQ?

Open sundl123 opened this issue 9 years ago • 6 comments

Hello! Our projects requires to store more than 100Millions vectors (256D) on GPU, so we plan to use GpuIndexIVFPQ in order to compress the data, but METRIC_INNER_PRODUCT is not implented in GpuIndexIVFPQ which is a must for our projects. So could you please tell us when will METRIC_INNER_PRODUCT be fully implemented on GpuIndexIVFPQ?

thank you very much

sundl123 avatar Jun 08 '17 03:06 sundl123

Hi

Implementing this is currently not high on our priority list.

You may be interested in http://ulrichpaquet.com/Papers/SpeedUp.pdf section 3 that transforms inner product computations into L2 distance computations.

mdouze avatar Jun 08 '17 04:06 mdouze

METRIC_INNER_PRODUCT is not implented in IndexIVFFlat? I set nlist = 100, nprobe = 10 in IndexIVFFlat, but not get the correct result..

kittenkaka avatar Jun 15 '17 13:06 kittenkaka

Hi Please open a new issue with a complete bug report.

mdouze avatar Jun 19 '17 11:06 mdouze

@mdouze assuming vectors are normalized before indexing/training/search, wouldn't (2-distances**2)/2 convert the METRIC_L2 distances (returned by the search function) to cosine similarities (inner product metric)?

My maths are a bit rusty so I'm possibly wrong 🤓

cosine similarity = cos(C) where C is the angle between vectors a and b
We know a = 1 and b = 1 since the vectors are normalized. 
c is the distance between vectors a and b.

cos(C) = (a^2 + b^2 - c^2) / (2ab)
            = (1+1-distance^2) / (2*1*1)
            = (2-distance^2) / 2

billkle1n avatar Aug 29 '17 03:08 billkle1n

Yes for normalized vectors.

mdouze avatar Aug 29 '17 08:08 mdouze

@mdouze thanks. I just noticed that the distances returned by IVFPQ are already squared so it would be (2-distance) / 2

billkle1n avatar Aug 29 '17 19:08 billkle1n