Skip to main content

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.

Metadata

Release files for scann 1.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for scann 1.2.4
File Interpreter ABI Platform
scann-1.2.4-cp39-cp39-manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
scann-1.2.4-cp38-cp38-manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
scann-1.2.4-cp37-cp37m-manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details

Total release size: 31.9 MB

Release files / scann-1.2.4-cp39-cp39-manylinux2014_x86_64.whl

Download URL scann-1.2.4-cp39-cp39-manylinux2014_x86_64.whl
Size 10.6 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
440973b1e877392c2c7ca5daefceb3a9aecf7145aae88f4e5e0bc6e72dbd4c73
BLAKE2b-256 checksum
How to use checksums
14497ad80b70e955831e6096ed665d1d436c0e0f99f86e1912ea81abc10682c8
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / scann-1.2.4-cp38-cp38-manylinux2014_x86_64.whl

Download URL scann-1.2.4-cp38-cp38-manylinux2014_x86_64.whl
Size 10.6 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
2977b18f609738dd9544f84d870b842a949d40b9763d320f74337d8b06eaecc5
BLAKE2b-256 checksum
How to use checksums
56b952b5b4837ac2c4c3c7f6a56dd980a543bcc0c60912fa94f1619c55f5dc0c
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / scann-1.2.4-cp37-cp37m-manylinux2014_x86_64.whl

Download URL scann-1.2.4-cp37-cp37m-manylinux2014_x86_64.whl
Size 10.6 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
26acb8532126c6717f41597d2fdf84b976dc1eb252a37fd798e511e6583acb0c
BLAKE2b-256 checksum
How to use checksums
ecd463ee1142e3d6baee297c9be53b25a8b26ba62e357935aa49b68c5acb2192
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

1.4.2

10 release files

1.4.1

4 release files

1.4.0

8 release files

1.3.5

8 release files

1.3.4

4 release files

1.3.3

4 release files

1.3.2

4 release files

1.3.1

4 release files

1.3.0

3 release files

1.2.9

4 release files

1.2.8

4 release files

1.2.7

4 release files

1.2.6

3 release files

1.2.5

3 release files

This release

1.2.4 This release

3 release files

1.2.3

4 release files

1.2.2

4 release files

1.2.1

3 release files

1.2.0

3 release files

1.1.1

4 release files

1.1.0

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page