Method
Class name
index_factory
Main parameters
Bytes/vector
Exhaustive
Comments
Exact Search for L2
IndexFlatL2
"Flat"
d
4*d
yes
brute-force
Exact Search for Inner Product
IndexFlatIP
"Flat"
d
4*d
yes
also for cosine (normalize vectors beforehand)
Hierarchical Navigable Small World graph exploration
IndexHNSWFlat
'HNSWx,Flat`
d, M
4*d + 8 * M
no
Inverted file with exact post-verification
IndexIVFFlat
"IVFx,Flat"
quantizer, d, nlists, metric
4*d
no
Take another index to assign vectors to inverted lists
Locality-Sensitive Hashing (binary flat index)
IndexLSH
-
d, nbits
nbits/8
yes
optimized by using random rotation instead of random projections
Scalar quantizer (SQ) in flat mode
IndexScalarQuantizer
"SQ8"
d
d
yes
4 bit per component is also implemented, but the impact on accuracy may be inacceptable
Product quantizer (PQ) in flat mode
IndexPQ
"PQx"
d, M, nbits
M (if nbits=8)
yes
IVF and scalar quantizer
IndexIVFScalarQuantizer
"IVFx,SQ4" "IVFx,SQ8"
quantizer, d, nlists, qtype
SQfp16: 2 * d, SQ8: d or SQ4: d/2
no
there are 2 encodings: 4 bit per dimension and 8 bit per dimension
IVFADC (coarse quantizer+PQ on residuals)
IndexIVFPQ
"IVFx,PQy"
quantizer, d, nlists, M, nbits
M+4 or M+8
no
the memory cost depends on the data type used to represent ids (int or long), currently supports only nbits <= 8
IVFADC+R (same as IVFADC with re-ranking based on codes)
IndexIVFPQR
"IVFx,PQy+z"
quantizer, d, nlists, M, nbits, M_refine, nbits_refine
M+M_refine+4 or M+M_refine+8