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.1.tar.gz (72.3 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.1-cp312-abi3-win_amd64.whl (52.5 kB view details)

Uploaded CPython 3.12+Windows x86-64

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

Uploaded CPython 3.12+Windows x86

lotf-0.0.1-cp312-abi3-musllinux_1_2_x86_64.whl (154.3 kB view details)

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

lotf-0.0.1-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (54.5 kB view details)

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

lotf-0.0.1-cp312-abi3-macosx_11_0_arm64.whl (46.5 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

lotf-0.0.1-cp312-abi3-macosx_10_14_x86_64.whl (49.6 kB view details)

Uploaded CPython 3.12+macOS 10.14+ x86-64

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

Uploaded CPython 3.11Windows x86-64

lotf-0.0.1-cp311-cp311-win32.whl (51.1 kB view details)

Uploaded CPython 3.11Windows x86

lotf-0.0.1-cp311-cp311-musllinux_1_2_x86_64.whl (157.3 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

lotf-0.0.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (57.6 kB view details)

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

lotf-0.0.1-cp311-cp311-macosx_11_0_arm64.whl (48.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

lotf-0.0.1-cp311-cp311-macosx_10_14_x86_64.whl (51.2 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

lotf-0.0.1-cp310-cp310-win_amd64.whl (54.0 kB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10Windows x86

lotf-0.0.1-cp310-cp310-musllinux_1_2_x86_64.whl (157.5 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

lotf-0.0.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (57.7 kB view details)

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

lotf-0.0.1-cp310-cp310-macosx_11_0_arm64.whl (48.2 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

lotf-0.0.1-cp310-cp310-macosx_10_14_x86_64.whl (51.4 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

File details

Details for the file lotf-0.0.1.tar.gz.

File metadata

  • Download URL: lotf-0.0.1.tar.gz
  • Upload date:
  • Size: 72.3 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.1.tar.gz
Algorithm Hash digest
SHA256 eb69c64abad1f7163b6f8edfaf31e196dcda7b95ff08baacde158a8df3298ddf
MD5 28a8219fb83098ef0504e1f3565baa77
BLAKE2b-256 1e22907575bedbc7a05bcc702735817b47d49c07e9ed6c65436bb05159107e85

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1.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.1-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: lotf-0.0.1-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 52.5 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.1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 11254652812da750bf369c3d8269ba8781c285280b0df99f166c8e1ee9b81eb0
MD5 ee6506bf43b6fa38d76aee8d9b88d875
BLAKE2b-256 5b50268b6fb4356b39a131f0e5fd2998fadcd690b78acbc11d4159f48344eb15

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp312-abi3-win32.whl.

File metadata

  • Download URL: lotf-0.0.1-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.1-cp312-abi3-win32.whl
Algorithm Hash digest
SHA256 a18d90bd3694d47c2555466224f717741a8b16705a6d5d7c00417cb72397e1ff
MD5 fad9ec0192be99a6d94b1574ce89df85
BLAKE2b-256 153399683703c15e04e0a0b82bab46a84c87042b0d34fc1f95a57723458d4059

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp312-abi3-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: lotf-0.0.1-cp312-abi3-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 154.3 kB
  • Tags: CPython 3.12+, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lotf-0.0.1-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d4ef2f2fcacef7de9fd3e28a3b1c0bdb430fcbf9652b1efb0b289580116d80fe
MD5 defa9fbeedc0016d2f3f34f7cba28bb1
BLAKE2b-256 fa27b855c24adcda85596edf8f529175efd4687d6903171aa84554725a5f8e9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.1-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ac34b81663bec0fc8b1ab23b37be4bd642d83893db9f739cd366028e8d2003ec
MD5 a777504c6a453c1d3cbe421d5bf4015b
BLAKE2b-256 cf0697a034bb6eaf0879bbe14d304779d0e2e9b40db78cffe01cf2f6b7cfb5c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: lotf-0.0.1-cp312-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 46.5 kB
  • Tags: CPython 3.12+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lotf-0.0.1-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a98abadebe0af2cb21f65a54540b0b089a478b4446537988f5405743affd4e87
MD5 072fbd4e673c14c062b3af7e9f29c2e6
BLAKE2b-256 62d292b6cc60aea1e34e335ec825148e99bc0bc751d6b7387cef5ff76c096770

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp312-abi3-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.1-cp312-abi3-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 b10dba0b64e5590fb34969a46267d79f115044450001612b1fb9664c2210b9a3
MD5 5abe101ea559d5a3cb9b23ff952ca479
BLAKE2b-256 81dcca4a3ed7473d36679ab2196dfec6a5ac156fd7ad608cc7b798c0a8961cdc

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: lotf-0.0.1-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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4d0e75f635296f37b35745584ea528cb1a5a6096ced90580392a5ecf117da4a9
MD5 cfd8af59d302885aa32a3056d41bb1c7
BLAKE2b-256 ce39da42010d3907716592b5d3398cbdf1bbf8dbba799428a9be7c7df00c5f58

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp311-cp311-win32.whl.

File metadata

  • Download URL: lotf-0.0.1-cp311-cp311-win32.whl
  • Upload date:
  • Size: 51.1 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.1-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 477308ee93405de79ddc96f9eb1116617efadad0fcb3bf7cbb40822838aae93e
MD5 7b133190358cf6fe8b808c414ac1bd05
BLAKE2b-256 f69e73ba5bd5c6d0713e0433a0f405af9e795fadaf94db6a4c96c5a9f3ec783c

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7ad623f79651fbd302ba95e26b1b56d6446310e8f8bde1413efbb8e739b033aa
MD5 c3fdb6e7632e07a918ccfd5c2119b6bd
BLAKE2b-256 21d2409214307d497bde8b7ba6712898d13aec22f23274766488e50ca0fdfb71

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3a2f218af69a5ce98f3c22091342805ae23540596807d99c8e1347820450452e
MD5 1db82a1dbbb94b1179de878fe9e37e08
BLAKE2b-256 39d87d96c70f4a017b71204a68c36c43443f129e8723b91b1391cd7b165dd0a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lotf-0.0.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c2f0e3d17283ababe49dca15f35d23d639021f316b298fb08639ee772e7892d2
MD5 85a9eb46c081703128fe70cbf1e08757
BLAKE2b-256 d17ad13d9b9f98d8638cc3c60272112420e74ba13bed5767301a42506a053d7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp311-cp311-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.1-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 4a31956857b10bc48aece8a6c6fa6b2a55ee47092aa709a4c27b187f6d88884f
MD5 fc6acc09570c2cbecfaf54b6f7314635
BLAKE2b-256 ff58e5be5b403fcf184501b6f87071e2ad4c5443d65ba6c192574c79df0b9878

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: lotf-0.0.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 54.0 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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d5721fc3ca3c531451bc969353cf458550c41613a6541190f5425d3a08482be2
MD5 bd2c24edd9840e502ba6854c243539fd
BLAKE2b-256 40a3df4567cf4a0b8de89cff721bef6f92ddae0abe7d4b781843d4b8e0f674f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp310-cp310-win32.whl.

File metadata

  • Download URL: lotf-0.0.1-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.1-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 010ac139d2a6a7159badf026a1fadebe2ea3f2cac1966122e3ae26d6eb30a736
MD5 e80b8d673ee26df17eeaf2713302e731
BLAKE2b-256 8895dda815925646cf57ea2955a7627a3cf76b78c459ec78f83291e760155ee2

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.1-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5526477eea3c76cd391bf51c878325f0cf8ec8a37c55a4a599d4ccf592d9b0b6
MD5 c236cceefc61233dff8007d139c31ae4
BLAKE2b-256 14fc6e8b219a39244bcb343e2593d4fa26cdc98672bca1d5d6b38f189bb53bf0

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2aa1aa84588e061518699589b51124e94e5d833b823284f57028e57ccd7ac9c4
MD5 bc42dabd261c7aa1bfbd2a1def5206d0
BLAKE2b-256 a14f02cd2adc5197edd7a5a3928eecd9d63101108a8b5fbb1d12da0e0a02c196

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lotf-0.0.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70232a6359c031774c744d592ab8254bc96ce792bba35544f221f8c298a56b56
MD5 128c584cb86983c9b842da930d12f533
BLAKE2b-256 b9d0f8547173d7d579d982b1fbbcec7671f1339f30572e18b4d2a4428dbf521b

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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.1-cp310-cp310-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for lotf-0.0.1-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 88d921a8ccba118cc297daf56091264a0eda94db7693695dd19d9cc33abdb83c
MD5 fb7949a6098dfde66c6c0f0d84aff003
BLAKE2b-256 e1000a3942eecf6862f2da9b6a5c3f80b271649734b992226674c5217e365151

See more details on using hashes here.

Provenance

The following attestation bundles were made for lotf-0.0.1-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