Skip to main content

Scalable Approximate 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

manylinux2014-compatible wheels are available on PyPI:

pip install scann

ScaNN supports Linux environments running Python versions 3.7-3.9. 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 manylinux2014 specification, ScaNN requires libstdc++ version 3.4.19 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 8, and libstdc++ headers for C++17 (which are provided with GCC 9). Additionally, ScaNN requires a modern version of Python (3.7.x or later) and Tensorflow 2.7 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-8 bazel build -c opt --features=thin_lto --copt=-mavx2 --copt=-mfma --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" --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.2.6-cp39-cp39-manylinux2014_x86_64.whl (10.9 MB view details)

Uploaded CPython 3.9

scann-1.2.6-cp38-cp38-manylinux2014_x86_64.whl (10.9 MB view details)

Uploaded CPython 3.8

scann-1.2.6-cp37-cp37m-manylinux2014_x86_64.whl (10.9 MB view details)

Uploaded CPython 3.7m

File details

Details for the file scann-1.2.6-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

  • Download URL: scann-1.2.6-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 10.9 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.7

File hashes

Hashes for scann-1.2.6-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba67bae7ef9378b764af08fc8e033e0ef22732d60b7b6d2591215a63b2c97a62
MD5 9b2cb4cfae3defa3b53d212a1d6a19bd
BLAKE2b-256 7996aa4c1013de5cf523164ff3e1490f79542d88bb58d2e9edcd89c3d6edab7e

See more details on using hashes here.

File details

Details for the file scann-1.2.6-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: scann-1.2.6-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 10.9 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.7

File hashes

Hashes for scann-1.2.6-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 341f759ade6fbdbf02c8fb878bf8e43ff2d3a000d602f8a3fa240776b2cd56eb
MD5 731280a492bb5fbc062af14df7c893bf
BLAKE2b-256 dd95a63aa13f2475f6a21155cac0aaaa0c8dfce5e60af74c834c45df3624aa1f

See more details on using hashes here.

File details

Details for the file scann-1.2.6-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: scann-1.2.6-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 10.9 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.7

File hashes

Hashes for scann-1.2.6-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cac5f1fdefe8d67c3fdf6a780cc017494ceb2d6f0092609c4f87b49cb8889f0c
MD5 79a0aae9cf268057a15aabf8e2e956db
BLAKE2b-256 5bd82ef1bceb4796f84a98925353c8f717a9e66f0e0ef2202095204346900d34

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