Facebook 开源的一个高性能的高维向量相似度检索和聚类库。
开源协议之前采用 BSD + Patents。最新版 v1.5.2 采用 MIT,可以在商业软件中使用。
github 上有 6000 多 Stars。
Faiss 主要特性:
- 支持相似度检索和聚类;
- 支持多种索引方式;
- 支持CPU和GPU计算;
- 支持Python和C++调用;
Faiss 索引类型:
Exact Search for L2
#基于L2距离的确定搜索匹配Exact Search for Inner Product
#基于内积的确定搜索匹配Hierarchical Navigable Small World graph exploration
#分层索引Inverted file with exact post-verification
#倒排索引Locality-Sensitive Hashing (binary flat index)
#本地敏感hashScalar quantizer (SQ) in flat mode
#标量量化索引Product quantizer (PQ) in flat mode
#笛卡尔乘积索引IVF and scalar quantizer
#倒排+标量量化索引IVFADC (coarse quantizer+PQ on residuals)
#倒排+笛卡尔乘积索引IVFADC+R (same as IVFADC with re-ranking based on codes)
#倒排+笛卡尔乘积索引 + 基于编码器重排
第1个和第2个索引方式是属于精确匹配,其他索引方式都是通过数据压缩的非精确匹配。
虽然压缩索引方式损失少量检索精度,但大大减少内存占用,从而支持超大规模数据集检索,比如在单机上支持10亿规模的高维向量相似度检索。
Faiss 使用场景:
最常见的人脸比对,指纹比对,基因比对等。
Faiss 开发资料:
github: https://github.com/facebookresearch/faiss
tutorial: https://github.com/facebookresearch/faiss/wiki/Getting-started