构建依赖 swig>=4.0.2、cmake>=3.12.0、boost>=1.67.0,版本不足会编译失败;Linux 下需先自行编译 ThirdParty 中的 SPDK、isal-l_crypto 和 RocksDB;clone 时需跳过 Git LFS 大文件(set GIT_LFS_SKIP_SMUDGE=1)

SPTAG
microsoftMIT活跃维护微软开源的分布式近似最近邻搜索库,提供高质量向量索引构建、搜索和在线服务工具,专为大规模向量检索场景设计。
A distributed approximate nearest neighborhood search (ANN) library which provides a high quality vector index build, search and distributed online serving toolkits for large scale vector search scenario.
mkdir build
cd build && cmake -DSPDK=OFF -DROCKSDB=OFF .. && makeREADME 未说明显存、GPU 型号或 CPU 运行要求,仅列出构建依赖 swig>=4.0.2、cmake>=3.12.0、boost>=1.67.0
微软开源的分布式近似最近邻搜索库,提供大规模向量索引构建、搜索与在线服务工具
微软开源的分布式近似最近邻搜索库,提供高质量向量索引构建、搜索和在线服务工具,专为大规模向量检索场景设计。
核心能力
- 提供 kd-tree+RNG 的 SPTAG-KDT 与平衡 k-means 树+RNG 的 SPTAG-BKT 两种索引
- 支持在线向量删除与插入的增量更新
- 支持跨多台机器的分布式搜索服务
- 按 L2 距离或余弦距离返回最近邻向量
- 提供 Python Wrapper 与端到端在线服务教程
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
SPTAG: A library for fast approximate nearest neighbor search
SPTAG
SPTAG (Space Partition Tree And Graph) is a library for large scale vector approximate nearest neighbor search scenario released by Microsoft Research (MSR) and Microsoft Bing.
What's NEW
- Result Iterator with Relaxed Monotonicity Signal Support
- New Research Paper SPFresh: Incremental In-Place Update for Billion-Scale Vector Search - published in SOSP 2023
- New Research Paper VBASE: Unifying Online Vector Similarity Search and Relational Queries via Relaxed Monotonicity - published in OSDI 2023
Introduction
This library assumes that the samples are represented as vectors and that the vectors can be compared by L2 distances or cosine distances. Vectors returned for a query vector are the vectors that have smallest L2 distance or cosine distances with the query vector.
SPTAG provides two methods: kd-tree and relative neighborhood graph (SPTAG-KDT) and balanced k-means tree and relative neighborhood graph (SPTAG-BKT). SPTAG-KDT is advantageous in index building cost, and SPTAG-BKT is advantageous in search accuracy in very high-dimensional data.
How it works
SPTAG is inspired by the NGS approach [WangL12]. It contains two basic modules: index builder and searcher. The RNG is built on the k-nearest neighborhood graph [WangWZTG12, WangWJLZZH14] for boosting the connectivity. Balanced k-means trees are used to replace kd-trees to avoid the inaccurate distance bound estimation in kd-trees for very high-dimensional vectors. The search begins with the search in the space partition trees for finding several seeds to start the search in the RNG. The searches in the trees and the graph are iteratively conducted.
Highlights
- Fresh update: Support online vector deletion and insertion
- Distributed serving: Search over multiple machines
Build
Requirements
- swig >= 4.0.2
- cmake >= 3.12.0
- boost >= 1.67.0
Fast clone
set GIT_LFS_SKIP_SMUDGE=1
git clone --recurse-submodules https://github.com/microsoft/SPTAG
OR
git config --global filter.lfs.smudge "git-lfs smudge --skip -- %f"
git config --global filter.lfs.process "git-lfs filter-process --skip"
Install
For Linux: Compile SPDK
cd ThirdParty/spdk
./scripts/pkgdep.sh
CC=gcc-9 ./configure
CC=gcc-9 make -j
Compile isal-l_crypto
cd ThirdParty/isal-l_crypto
./autogen.sh
./configure
make -j
Build RocksDB
mkdir build && cd build
cmake -DUSE_RTTI=1 -DWITH_JEMALLOC=1 -DWITH_SNAPPY=1 -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-fPIC" ..
make -j
sudo make install
Build SPTAG
mkdir build
cd build && cmake -DSPDK=OFF -DROCKSDB=OFF .. && make
It will generate a Release folder in the code directory which contains all the build targets.
For Windows:
mkdir build
cd build && cmake -A x64 -DSPDK=OFF -DROCKSDB=OFF ..
It will generate a SPTAGLib.sln in the build directory. Compiling the ALL_BUILD project in the Visual Studio (at least 2019) will generate a Release directory which contains all the build targets.
For detailed instructions on installing Windows binaries, please see here
Using Docker:
docker build -t sptag .
Will build a docker container with binaries in /app/Release/.
Verify
Run the SPTAGTest (or Test.exe) in the Release folder to verify all the tests have passed.
Usage
The detailed usage can be found in Get started. There is also an end-to-end tutorial for building vector search online service using Python Wrapper in Python Tutorial. The detailed parameters tunning can be found in Parameters.
References
Please cite SPTAG in your publications if it helps your research:
@inproceedings{xu2023spfresh,
title={SPFresh: Incremental In-Place Update for Billion-Scale Vector Search},
author={Xu, Yuming and Liang, Hengyu and Li, Jin and Xu, Shuotao and Chen, Qi and Zhang, Qianxi and Li, Cheng and Yang, Ziyue and Yang, Fan and Yang, Yuqing and others},
booktitle={Proceedings of the 29th Symposium on Operating Systems Principles},
pages={545--561},
year={2023}
}
@inproceedings{zhang2023vbase,
title={$\{$VBASE$\}$: Unifying Online Vector Similarity Search and Relational Queries via Relaxed Monotonicity},
author={Zhang, Qianxi and Xu, Shuotao and Chen, Qi and Sui, Guoxin and Xie, Jiadong and Cai, Zhizhen and Chen, Yaoqi and He, Yinxuan and Yang, Yuqing and Yang, Fan and others},
booktitle={17th USENIX Symposium on Operating Systems Design and Implementation (OSDI 23)},
year={2023}
}
@inproceedings{ChenW21,
author = {Qi Chen and
Bing Zhao and
Haidong Wang and
Mingqin Li and
Chuanjie Liu and
Zengzhong Li and
Mao Yang and
Jingdong Wang},
title = {SPANN: Highly-efficient Billion-scale Approximate Nearest Neighbor Search},
booktitle = {35th Conference on Neural Information Processing Systems (NeurIPS 2021)},
year = {2021}
}
@manual{ChenW18,
author = {Qi Chen and
Haidong Wang and
Mingqin Li and
Gang Ren and
Scarlett Li and
Jeffery Zhu and
Jason Li and
Chuanjie Liu and
Lintao Zhang and
Jingdong Wang},
title = {SPTAG: A library for fast approximate nearest neighbor search},
url = {https://github.com/Microsoft/SPTAG},
year = {2018}
}
@inproceedings{WangL12,
author = {Jingdong Wang and
Shipeng Li},
title = {Query-driven iterated neighborhood graph search for large scale indexing},
booktitle = {ACM Multimedia 2012},
pages = {179--188},
year = {2012}
}
@inproceedings{WangWZTGL12,
author = {Jing Wang and
Jingdong Wang and
Gang Zeng and
Zhuowen Tu and
Rui Gan and
Shipeng Li},
title = {Scalable k-NN graph construction for visual descriptors},
booktitle = {CVPR 2012},
pages = {1106--1113},
year = {2012}
}
@article{WangWJLZZH14,
author = {Jingdong Wang and
Naiyan Wang and
You Jia and
Jian Li and
Gang Zeng and
Hongbin Zha and
Xian{-}Sheng Hua},
title = {Trinary-Projection Trees for Approximate Nearest Neighbor Search},
journal = {{IEEE} Trans. Pattern Anal. Mach. Intell.},
volume = {36},
number = {2},
pages = {388--403},
year = {2014
}
Contribute
This project welcomes contributions and suggestions from all the users.
We use GitHub issues for tracking suggestions and bugs.
License
The entire codebase is under MIT license