首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >facebook faiss的安装测试

facebook faiss的安装测试

作者头像
sparkexpert
发布2018-01-09 16:11:14
2.1K0
发布2018-01-09 16:11:14
举报

Faiss 是由 Facebook AI Research(FAIR)开发的一个用于有效的相似性搜索(similarity search)和稠密矢量聚类(clustering of dense vectors)的库。它包含了在任何大小的向量集合里进行搜索的算法,向量集合的大小甚至可以达到装不进 RAM。它还包含了用于评估和参数调优的支持代码。Faiss 是用 C ++编写的,带有 Python / numpy 的完整包装。其中最有用的一些算法是在 GPU 上实现的。

针对这个开源的好东西,非常想测试一下,于是从开源地址:https://github.com/facebookresearch/faiss下载了源码进行查看和编译

主要安装过程参照github上faiss的安装文档,这里记录一些安装时遇到的问题。

1.

Faiss is compiled via a Makefile. The system-dependent configuration of the Makefile is in an include file, makefile.inc. The variables in makefile.inc must be set by hand.

在faiss-master根目录下复制修改后的makefile.inc文件,其中cuda使用的是8.0版本makefile.inc must be set by hand.

2.To check that the link flags are correct, and verify whether the

implementation uses 32 or 64 bit integers, you can make tests/test_blas

and run执行test_blas是会打印出error,但是这个程序中直接打印出来的,并没有进行条件判断,因此运行是成功的./tests/test_blas

3. Once the proper BLAS flags are set, the library should compile

smoothly by running make A basic usage example is in tests/demo_ivfpq_indexing

tests/demo_ivfpq_indexing

其中对索引在1234-1242的9个向量搜索其最近邻邻居,最近的应该是它本身,distance应该为0,但是由于量化误差,导致距离不为0.

4.

Real-life test -------------- The following script extends the demo_sift1M test to several types of indexes: export PYTHONPATH=. # needed because the script is in a subdirectory python python/demo_auto_tune.py 执行高亮语句前,需要在faiss-master的根目录下创建tmp目录,不然在最终的写入时会报错。写入tmp中的图片如下:python python/demo_auto_tune.py

再看了下FAISS原理,Faiss 是围绕一种存储了一个向量集的索引类型(index type)而构建的,并且提供了一个使用 L2 和/或点积向量比较在其中进行搜索的函数。一些索引类型是简单的基线,比如精准搜索。大部分可用的索引结构都对应了与以下方面的权衡:

  • 搜索时间
  • 搜索质量
  • 每个索引向量所用的内存
  • 训练时间
  • 无监督学习时对外部数据的需求
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017年03月31日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档