Faiss: params for IndexIVFPQ

Created on 16 Nov 2018  路  4Comments  路  Source: facebookresearch/faiss

Greetings!
for now there are 3 million 512-d vectors in my database, running on a 4 CPU 16G RAM machine.
200,000 vectors were trained, and index params as below
'''
m = 8
k = 120
quantizer = faiss.IndexFlatL2(d)
index = faiss.IndexIVFPQ(quantizer, d, 32, m, 8)
index.nprobe = 32

'''

search one vector cost around 50 ms ( pretty good锛夛紝but the accuracy is not satisfactory.
Is there any adjustment on the index params can improve accuracy while at the meantime keep searching time less than 100ms
Thanks!

question

Most helpful comment

Also, it seems you could use a simple IndexFlatL2 instead of an IndexIVFPQ, as 1. your data would fit in memory uncompressed and 2. you are already performing an exhaustive (approximate) search. Using an IndexFlatL2 would perform an exact exhaustive search, hence accuracy would not be an issue. See the wiki page for choosing an index.

All 4 comments

Currently, you seem to have nlist = nprobe, which means you are effectively performing an exhaustive search, and your accuracy issue probably comes from the PQ encoding (here you are compressing each vector from 512 32bit floats to 8 bytes codes, which means a compression factor of 256). You could try increasing the m parameter. Thoughts @mdouze?

Also, it seems you could use a simple IndexFlatL2 instead of an IndexIVFPQ, as 1. your data would fit in memory uncompressed and 2. you are already performing an exhaustive (approximate) search. Using an IndexFlatL2 would perform an exact exhaustive search, hence accuracy would not be an issue. See the wiki page for choosing an index.

@beauby Thanks a lot.
I am getting to know IndexIVFPQ for preparing a larger database -_- .As you suggested, should I increase the last param encoded bits(8) while increasing param m ? and is my xt quantity(200,000) many enough for 3 million database.

No activity, closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brunodoamaral picture brunodoamaral  路  3Comments

ilyakhov picture ilyakhov  路  3Comments

mylyu picture mylyu  路  3Comments

0DF0Arc picture 0DF0Arc  路  3Comments

daniellevy picture daniellevy  路  3Comments