Skip to main content

CPU-only Python package for the ConANN-modified FAISS bindings

Project description

conann

conann is a CPU-focused Python package for the ConANN-enabled FAISS bindings. It exposes the familiar FAISS-style Python API under:

import conann

The package is intended for approximate nearest-neighbor search workflows where vectors are produced in Python, NumPy, PyTorch, Transformers, CLIP, sentence embedding models, or similar ML pipelines, and then searched through an IVF index.

This project packages the ConANN-modified FAISS CPU path so it can be installed and used directly from Python without asking users to build the research fork by hand.

Install

pip install conann

Supported wheels are built for:

  • Python 3.10, 3.11, 3.12, 3.13, 3.14
  • Linux x86_64
  • Windows win_amd64
  • CPU-only execution

Quick Start

import numpy as np
import conann

d = 32
nb = 5000
nq = 100
nlist = 32
k = 5

rng = np.random.default_rng(123)
xb = rng.random((nb, d), dtype=np.float32)
xq = rng.random((nq, d), dtype=np.float32)

index = conann.IndexFlatL2(d)
index.add(xb)

distances, labels = index.search(xq, k)
print(labels.shape)

IVF Search

quantizer = conann.IndexFlatL2(d)
ivf = conann.IndexIVFFlat(quantizer, d, nlist, conann.METRIC_L2)

ivf.train(xb)
ivf.add(xb)
ivf.nprobe = 8

distances, labels = ivf.search(xq, k)

ConANN Calibration And Search

ConANN-specific methods are exposed on supported IVF indexes:

exact = conann.IndexFlatL2(d)
exact.add(xb)
_, ground_truth = exact.search(xq, k)

calibration = ivf.calibrate_conann(
    alpha=0.2,
    k=k,
    xq=xq,
    ground_truth=ground_truth,
    calib_sz=0.5,
    tune_sz=0.25,
    dataset_key="example",
)

distances, labels = ivf.search_conann(xq, calibration, k=k)
metrics = ivf.evaluate_conann(labels, ground_truth)
timing = ivf.conann_time_report()

print(metrics)
print(timing)

The main ConANN additions are:

  • calibrate_conann(...)
  • search_conann(...)
  • evaluate_conann(...)
  • conann_time_report()

Standard FAISS-style index classes such as IndexFlatL2 and IndexIVFFlat are also available through the conann module.

PyTorch Embeddings

conann works with PyTorch-generated embeddings after converting tensors to CPU float32 NumPy arrays:

embeddings = model_output.detach().cpu().numpy().astype("float32")

Those arrays can then be added to a conann index in the same way as regular NumPy vectors.

Package Metadata

import conann

print(conann.__version__)        # 0.1.1
print(conann.__faiss_version__)  # 1.9.0

This package intentionally uses import conann; it does not install a top-level import faiss alias. Internal SWIG modules remain private implementation details of the package.

Scope

This package is currently:

  • CPU-only
  • focused on the ConANN-enabled IVF path
  • distributed as prebuilt wheels for supported CPython versions
  • intended for research, experimentation, and practical Python access to ConANN

It is not a complete replacement for every FAISS feature. In particular, it does not provide GPU FAISS support, and not every FAISS index family is part of the ConANN-specific workflow.

Development

The package root is:

conann/

The ConANN/FAISS C++ source used by the build lives at:

../conann-main/conann

Useful scripts:

scripts/build_manylinux_wheels.sh
scripts/build_all_pythons.sh
scripts/build_all_pythons_windows.ps1
scripts/verify_wheels.sh
scripts/verify_wheels_windows.ps1

Release wheels and smoke-test records are kept under:

wheels/linux_x86_64/
wheels/win_amd64/
results/

License And Attribution

This package is built from a ConANN-modified FAISS codebase. Keep upstream license notices and attribution intact when redistributing or modifying the package.

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

If you're not sure about the file name format, learn more about wheel file names.

conann-0.1.1-cp314-cp314-win_amd64.whl (8.2 MB view details)

Uploaded CPython 3.14Windows x86-64

conann-0.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

conann-0.1.1-cp313-cp313-win_amd64.whl (8.1 MB view details)

Uploaded CPython 3.13Windows x86-64

conann-0.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

conann-0.1.1-cp312-cp312-win_amd64.whl (8.1 MB view details)

Uploaded CPython 3.12Windows x86-64

conann-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

conann-0.1.1-cp311-cp311-win_amd64.whl (8.1 MB view details)

Uploaded CPython 3.11Windows x86-64

conann-0.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

conann-0.1.1-cp310-cp310-win_amd64.whl (8.1 MB view details)

Uploaded CPython 3.10Windows x86-64

conann-0.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file conann-0.1.1-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: conann-0.1.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for conann-0.1.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 6652b183560caefb9b644929f0b552e64be0f2ea4549524dada0b9b69b788a7d
MD5 095191e58c525c0ad7e516eb07ca4444
BLAKE2b-256 d8ae2979759242eba9c0f8b0cd12c510ad03b957ee86d8c7fc9239e23bb62ef2

See more details on using hashes here.

File details

Details for the file conann-0.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for conann-0.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f182127ac05b9b7cc9459d252f2f7d0eb3b4acd59b9595d938f91cdda5a8fe4d
MD5 de3438bbdb701571cde7f4f5db551025
BLAKE2b-256 ee6efeb85c0dc42fed1910ce109ed98dc7db436ac44137dd6dbe4eae3ceb436f

See more details on using hashes here.

File details

Details for the file conann-0.1.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: conann-0.1.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 8.1 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for conann-0.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4487012ebc5edd3308340b6885d113a0d0fd523bd0881d138a679768614fc20f
MD5 37b702ad4f12a4742586b44e474252a5
BLAKE2b-256 511c43ee3dcf220490b6c0f36ab90430b8ee669fd7228c7f216d3ae755a00252

See more details on using hashes here.

File details

Details for the file conann-0.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for conann-0.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 611b9c56d68c9ec578aabd31457c8da7c91e9f1004db5743cbae6b511da5e050
MD5 6cd92705fe6e14a889efa405a62fd7e7
BLAKE2b-256 d4bacce638f746d2c28fa3d8ae897e0c99872702af4bef9e975e38a517382052

See more details on using hashes here.

File details

Details for the file conann-0.1.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: conann-0.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 8.1 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for conann-0.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e19937109aa0e0b9ca82452c96960c7084abb88e054429e8445bf57cfe6f825d
MD5 89264696fdc64618974971dae5bf6c21
BLAKE2b-256 6e376d8233315634a42fbbafd4b512c6d03bae6407d65ea25df2c4413b3ef551

See more details on using hashes here.

File details

Details for the file conann-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for conann-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ca64756478c6fbcc6e585ce9bc00ace902e603105d3dbbb5428ee5fa6993cdb8
MD5 1062acf755711fc2cc62d8e3d4229310
BLAKE2b-256 1455aeb76f8632cfe61cba0b191977e43fad85d5dce4595472a463b7f5e90146

See more details on using hashes here.

File details

Details for the file conann-0.1.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: conann-0.1.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 8.1 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for conann-0.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 08ee5f87cc5e5fa78ff4ef9c5e1baace0e2d7da24109e014c66d2a6c251aa384
MD5 2ca7006245e00f6de3381db9b54fc961
BLAKE2b-256 dc970a4f57a3e347c09330f576274bb195aeac9c3fd3ba6f5561333b822e0079

See more details on using hashes here.

File details

Details for the file conann-0.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for conann-0.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 70f8a770178a614465326a509530ae99bae56036e4eca0f05d874207792c5649
MD5 a9b48b1a0d80f57c4e2d046ac29d5aff
BLAKE2b-256 251ee58fa5e2d30594b51f24435a576ef6deff3907963f9be9b72659700c7e13

See more details on using hashes here.

File details

Details for the file conann-0.1.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: conann-0.1.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 8.1 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for conann-0.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8119ae681de5d5941c06f88220d24b4ecc7d9e0ca15a425e6601de203d2f356f
MD5 72c2279fe22b58734a08c21f9504f741
BLAKE2b-256 92486b5eed4db6b1412daad9b3032aa860a26d919a847f57c161994c68d22533

See more details on using hashes here.

File details

Details for the file conann-0.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for conann-0.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a83dce708be57841cc332784973ec56f8ea835241a183bdbee9a3dbb74f89e8b
MD5 d7a618b693fc0548f70cde95ce4cd374
BLAKE2b-256 3bb3b7ae078cef9994cd83f1e28dfa6fab9e36f94b48cdf1bf9a1db082f6ce7c

See more details on using hashes here.

Supported by

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