Skip to main content

Scalable Nearest Neighbor search library

Project description

ScaNN

ScaNN (Scalable Nearest Neighbors) is a method for efficient vector similarity search at scale. This code release implements [1], which includes search space pruning and quantization for Maximum Inner Product Search and also supports other distance functions such as Euclidean distance. The implementation is designed for x86 processors with AVX2 support. ScaNN achieves state-of-the-art performance on ann-benchmarks.com as shown on the glove-100-angular dataset below:

glove-100-angular

ScaNN can be configured to fit datasets with different sizes and distributions. It has both TensorFlow and Python APIs. The library shows strong performance with large datasets [1]. The code is released for research purposes. For more details on the academic description of algorithms, please see [1].

Reference [1]:

@inproceedings{avq_2020,
  title={Accelerating Large-Scale Inference with Anisotropic Vector Quantization},
  author={Guo, Ruiqi and Sun, Philip and Lindgren, Erik and Geng, Quan and Simcha, David and Chern, Felix and Kumar, Sanjiv},
  booktitle={International Conference on Machine Learning},
  year={2020},
  URL={https://arxiv.org/abs/1908.10396}
}

Installation

manylinux_2_27-compatible wheels are available on PyPI:

pip install scann

ScaNN supports Linux environments running Python versions 3.8-3.11. See docs/releases.md for release notes; the page also contains download links for ScaNN wheels prior to version 1.1.0, which were not released on PyPI.

In accordance with the manylinux_2_27 specification, ScaNN requires libstdc++ version 3.4.23 or above from the operating system. See here for an example of how to find your system's libstdc++ version; it can generally be upgraded by installing a newer version of g++.

Integration with TensorFlow Serving

We provide custom Docker images of TF Serving that are linked to the ScaNN TF ops. See the tf_serving directory for further information.

Building from source

To build ScaNN from source, first install the build tool bazel, Clang 16, and libstdc++ headers for C++17 (which are provided with GCC 9). Additionally, ScaNN requires a modern version of Python (3.8.x or later) and Tensorflow 2.15 installed on that version of Python. Once these prerequisites are satisfied, run the following command in the root directory of the repository:

python configure.py
CC=clang-16 bazel build -c opt --features=thin_lto --copt=-mavx --copt=-mfma --cxxopt="-std=c++17" --copt=-fsized-deallocation --copt=-w :build_pip_pkg
./bazel-bin/build_pip_pkg

A .whl file should appear in the root of the repository upon successful completion of these commands. This .whl can be installed via pip.

Usage

See the example in docs/example.ipynb. For a more in-depth explanation of ScaNN techniques, see docs/algorithms.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

scann-1.3.0-cp311-cp311-manylinux_2_27_x86_64.whl (10.6 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.27+ x86-64

scann-1.3.0-cp310-cp310-manylinux_2_27_x86_64.whl (10.6 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.27+ x86-64

scann-1.3.0-cp39-cp39-manylinux_2_27_x86_64.whl (10.6 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.27+ x86-64

File details

Details for the file scann-1.3.0-cp311-cp311-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for scann-1.3.0-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 c096d88250371c6a6b733081e245cd433b863eb58581c51cbbd8956f56e5f252
MD5 8479a9ff3530d2fb5b971675a1d03c3b
BLAKE2b-256 11597bf4fbd2b16d0ddfc2d2aa0494eb0340c9510d7ef5a98a6de022ed6a5006

See more details on using hashes here.

File details

Details for the file scann-1.3.0-cp310-cp310-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for scann-1.3.0-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 e0a837bacda8fcaff456af0865d0cab5e4b4ec242a6d7144634ab288c4929d3b
MD5 f27ef484adc8078f26fbf53bd2557911
BLAKE2b-256 5f25f79496f95f164b84765a4f7c4951b12fc1f40ff37070abdf6a2e1fb2bb0d

See more details on using hashes here.

File details

Details for the file scann-1.3.0-cp39-cp39-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for scann-1.3.0-cp39-cp39-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 131e2b903e5dc958aecc9c3290cafb98a97829e0d9cb939007d2cd29d4b4e0ed
MD5 551b70580f1dfdbf7486f798c2eae2db
BLAKE2b-256 36d0585ae4d2ecf376a6c5dd332eafa6a754f207dc0867e66b9b680a634a54a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page