Skip to main content

LotusFilter: Diversity-aware approximate nearest neighbor search

Project description

LotusFilter Logo

PyPI version Documentation CI

LotusFilter: Diversity-aware approximate nearest neighbor search combining Faiss with cutoff tables to prevent similar results from dominating search outputs.

✨ Features

  • Lightweight: Ultra-fast processing < 0.1ms per query
  • 🔄 Independence: Post-processing module that doesn't require original data retention
  • 🎯 Flexibility: Works seamlessly with various Faiss indexes
  • 🛠️ Simplicity: Single CutoffTable class - easy to integrate

🚀 Quick Start

Installation

pip install lotf

Simple Usage

import lotf
import faiss
import numpy as np

# Prepare data
Xb = np.random.rand(10000, 128).astype('float32')  # Database vectors
Xq = np.random.rand(5, 128).astype('float32')      # Query vectors

# Step 1: Build Faiss index
index = faiss.IndexFlatL2(Xb.shape[1])
index.add(Xb)

# Step 2: Build cutoff table for diversity filtering
epsilon = 15.0
ctable = lotf.CutoffTable(X=Xb, index=index, epsilon=epsilon)

# Step 3: Search with diversity
candidate_k, final_k = 300, 100
candidate_dists, candidate_ids = index.search(Xq, candidate_k)
diverse_dists, diverse_ids = ctable.filter(
    dists=candidate_dists, 
    ids=candidate_ids, 
    final_k=final_k
)

print(f"Diverse results: {diverse_ids}")

📄 Citation

If you use LotusFilter in your research, please cite our CVPR 2025 paper:

@inproceedings{mtasui2025cvpr,
    author    = {Yusuke Matsui},
    title     = {LotusFilter: Fast Diverse Nearest Neighbor Search via a Learned Cutoff Table},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    year      = {2025},
    pages     = {30430-30439}
}

📚 Documentation

👤 Author

Yusuke Matsui

Project details


Download files

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

Source Distribution

lotf-0.0.2.dev2.tar.gz (73.7 kB view details)

Uploaded Source

Built Distributions

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

lotf-0.0.2.dev2-cp312-abi3-win_amd64.whl (52.6 kB view details)

Uploaded CPython 3.12+Windows x86-64

lotf-0.0.2.dev2-cp312-abi3-win32.whl (49.7 kB view details)

Uploaded CPython 3.12+Windows x86

lotf-0.0.2.dev2-cp312-abi3-musllinux_1_2_x86_64.whl (154.4 kB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ x86-64

lotf-0.0.2.dev2-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (54.6 kB view details)

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

lotf-0.0.2.dev2-cp312-abi3-macosx_11_0_arm64.whl (46.6 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

lotf-0.0.2.dev2-cp312-abi3-macosx_10_14_x86_64.whl (49.7 kB view details)

Uploaded CPython 3.12+macOS 10.14+ x86-64

lotf-0.0.2.dev2-cp311-cp311-win_amd64.whl (53.9 kB view details)

Uploaded CPython 3.11Windows x86-64

lotf-0.0.2.dev2-cp311-cp311-win32.whl (51.2 kB view details)

Uploaded CPython 3.11Windows x86

lotf-0.0.2.dev2-cp311-cp311-musllinux_1_2_x86_64.whl (157.4 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

lotf-0.0.2.dev2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (57.7 kB view details)

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

lotf-0.0.2.dev2-cp311-cp311-macosx_11_0_arm64.whl (48.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

lotf-0.0.2.dev2-cp311-cp311-macosx_10_14_x86_64.whl (51.3 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

lotf-0.0.2.dev2-cp310-cp310-win_amd64.whl (54.1 kB view details)

Uploaded CPython 3.10Windows x86-64

lotf-0.0.2.dev2-cp310-cp310-win32.whl (51.3 kB view details)

Uploaded CPython 3.10Windows x86

lotf-0.0.2.dev2-cp310-cp310-musllinux_1_2_x86_64.whl (157.6 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

lotf-0.0.2.dev2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (57.8 kB view details)

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

lotf-0.0.2.dev2-cp310-cp310-macosx_11_0_arm64.whl (48.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

lotf-0.0.2.dev2-cp310-cp310-macosx_10_14_x86_64.whl (51.5 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

File details

Details for the file lotf-0.0.2.dev2.tar.gz.

File metadata

  • Download URL: lotf-0.0.2.dev2.tar.gz
  • Upload date:
  • Size: 73.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lotf-0.0.2.dev2.tar.gz
Algorithm Hash digest
SHA256 78a56caee88eafcd080ce80cd3874c818a866a4237b45ebd084e64d6799b820c
MD5 cc6de02fae3e3a2fd9f7c9e531d37ced
BLAKE2b-256 6876a47d1b837d8e5316748432d6e2ba7d87c0a927d7dc6e218da21eab47520d

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2.tar.gz:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: lotf-0.0.2.dev2-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 52.6 kB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lotf-0.0.2.dev2-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 244d2d7644b7f21a33d3b79937f1e7f8ac8fde32b79cfa97689368bcc7c9d312
MD5 167e0ea9293275f9842fc2e83678bfce
BLAKE2b-256 3da26ac0b38fb8eda89e9e918535e56cc1bfdedbaf7b3a7df04cc810ed67c9f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp312-abi3-win_amd64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp312-abi3-win32.whl.

File metadata

  • Download URL: lotf-0.0.2.dev2-cp312-abi3-win32.whl
  • Upload date:
  • Size: 49.7 kB
  • Tags: CPython 3.12+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lotf-0.0.2.dev2-cp312-abi3-win32.whl
Algorithm Hash digest
SHA256 b7070d7ed1dadc131d792d40c341f7025d7681657ad770738847c83bc865acfc
MD5 bca643ad2489c305fde481b60fbcd573
BLAKE2b-256 20d1707a21e1f205719c9d81791191af9e324ee51e389d532cef5638c181c542

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp312-abi3-win32.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp312-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.2.dev2-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 541f71c9460cf4da32d2b705c4aa9cef5ba5f128c97ac610f7cf14244514fb4b
MD5 0f84ea62de9d0c3b3eb926dcaead056f
BLAKE2b-256 9617d212c29d12a2b86e053c3dbeb9c9618d36f820744145c53679a0534cbab7

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp312-abi3-musllinux_1_2_x86_64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.2.dev2-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 78cb215452a490f9d70ad083feb6ef6e068e5efdd08113dc9e95738647ccfda8
MD5 c0ea195fb7eeeceefe474d554ce0d740
BLAKE2b-256 13dbffa5652ffd80c50bd6b1a09eafe4d3f51c1aeb74d9aa6883baa6b820d261

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lotf-0.0.2.dev2-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 72112af17f6b4e1b1224a3241b55784f6d7a374db51096021c4eb0ecd22bd89f
MD5 38b8301b3475152fadc6c3dc3411c4cb
BLAKE2b-256 c5f2e9f082aec6220712267ac031682a04665e25f06ba7d5773fd34987edd453

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp312-abi3-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.2.dev2-cp312-abi3-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 286b021c4844e0b9b53e69bdea249138e8ca72e4632909086fcbd31f6c93b8a3
MD5 9dc098dd3c3c9c220a342b9321f0b100
BLAKE2b-256 d982325fe55a97dc3c6210a160a1c75ab4e04de9fa988d1bafd76f5bfe8b00ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp312-abi3-macosx_10_14_x86_64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: lotf-0.0.2.dev2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 53.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lotf-0.0.2.dev2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d076f05d18a28603b3fab7bb4c7dc58cd299354f9a207a683bf90ba78d97b709
MD5 209539a4458ab85a16c847ccd14300d1
BLAKE2b-256 0d27fe2e1bc88685ea83f754b0b53815425c2a1dcfa8b5b3c007145bf3ea7e7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp311-cp311-win_amd64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp311-cp311-win32.whl.

File metadata

  • Download URL: lotf-0.0.2.dev2-cp311-cp311-win32.whl
  • Upload date:
  • Size: 51.2 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lotf-0.0.2.dev2-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 67378b22ecb98f516374709fe76f1d96b9f7ea7f990d061e49d505a7eaa6fd83
MD5 6b50ce505b55d486c8b8e7271f546f6e
BLAKE2b-256 8cc2aab5d25723a52566bd6684172dcaca521e6af2d762442ed78164ef9dbd7b

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp311-cp311-win32.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.2.dev2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 71033b8372f907f30391788fb2657c1dc547d3f8101ff48e63e498a7eca19c2e
MD5 5558b3bb8eea2d56391591cffdd86d6f
BLAKE2b-256 83fa95594d4575e159d41a513aef49ae42be11b59e95c4f80ade3c709f841b31

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp311-cp311-musllinux_1_2_x86_64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.2.dev2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2735814dba092500dd7be353f5c27b6cc49f9f905b03daf4f1e0970f775c2f35
MD5 cec7ba18a12cd3bd4aa7e52decc25e87
BLAKE2b-256 8a52c368c2cd376e5a3c7e8bdda86e7d7edb97a7823dd61dc66c6d7e0ca3ccd5

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lotf-0.0.2.dev2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a5800621ebd6bbe777e7fd3ec33a65efa632ede5946c449820b2caacd100946d
MD5 e06afee20e84826154ce632d6fcdb716
BLAKE2b-256 ea4f992ed7394c6a3457cbfa927ac13744d2236ef46eb7d58eafdd91bd307a94

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp311-cp311-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.2.dev2-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 2f3a246bbc3ad252498ca40621ab1531564e64e725c1a8de863ef452d3f42bde
MD5 c7df392f2bde8f53612a8bd29c8e2d4e
BLAKE2b-256 4c072013fa93cdebb2679f3dc7f9285dd3e343edf4eed87fa25c29b2d582ce9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp311-cp311-macosx_10_14_x86_64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: lotf-0.0.2.dev2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 54.1 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lotf-0.0.2.dev2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 16c6a18fe4f60b9b5014cd6f7b8bc467f3a5d4b2aac2b60398ad4dc5a17cd465
MD5 98fc770853cd7d9c10de170e4dc237f3
BLAKE2b-256 d23780047672fd7c76037b726fa99b8838e09e41581d8ab786787a5fcd3126e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp310-cp310-win_amd64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp310-cp310-win32.whl.

File metadata

  • Download URL: lotf-0.0.2.dev2-cp310-cp310-win32.whl
  • Upload date:
  • Size: 51.3 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lotf-0.0.2.dev2-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 b9fd456e65ca28d2ddd6b5783a4f3823b23379108f87d61da25ae05e3ae90ffb
MD5 467b34d817872cadfa5f63b382b61c4d
BLAKE2b-256 4ebafc1828e377ae424261c023691ec14253bfcb564bd7d42b545f2ef446aa67

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp310-cp310-win32.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.2.dev2-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4a08baa926138ecbf41ad15d114c1012a69cff24e6f6249bb46c15643506ab43
MD5 4f17ca8cd4426246ace1c1868710eac7
BLAKE2b-256 d0d5c4b5bf4fcaf600168a65658f187b6067d9bc7b361e5bcc8fddfba9974638

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp310-cp310-musllinux_1_2_x86_64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.2.dev2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 35c4be99e0dfa64c59516cd38c16a8b63fa8f28d5e0bf18f58370349182b77a6
MD5 462dfb40972270509554c9c1d4204325
BLAKE2b-256 859da5b7300073d3c6c0545a3f0fe76113e53870256af1f57363d37d4367c316

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lotf-0.0.2.dev2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dc987debb7ac983a52aba74621fa790dfccd5d7d9c7042ec0ec997f5e96642ae
MD5 884db4f35c3bad0849586bb1f1c0619e
BLAKE2b-256 0a95329cc75a5e7cba0387ca32893cdfe5d3afc144a49fa32ac68b48c6f6d5e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lotf-0.0.2.dev2-cp310-cp310-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.2.dev2-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ce1cbca8d3c8c23095b6d08af5eb12422099a81248023ce33cbe7743ed20769a
MD5 3e6c7adfbb23b80f668ac890c0c0963b
BLAKE2b-256 8c8da45e6f16a10ff4b22279cb474bdada135738987c51db679ebfe510e001b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.2.dev2-cp310-cp310-macosx_10_14_x86_64.whl:

Publisher: wheels.yml on matsui528/lotf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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