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.dev1.tar.gz (73.5 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.dev1-cp312-abi3-win_amd64.whl (52.6 kB view details)

Uploaded CPython 3.12+Windows x86-64

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

Uploaded CPython 3.12+Windows x86

lotf-0.0.2.dev1-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.dev1-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.dev1-cp312-abi3-macosx_11_0_arm64.whl (46.6 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

lotf-0.0.2.dev1-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.dev1-cp311-cp311-win_amd64.whl (53.9 kB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11Windows x86

lotf-0.0.2.dev1-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.dev1-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.dev1-cp311-cp311-macosx_11_0_arm64.whl (48.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

lotf-0.0.2.dev1-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.dev1-cp310-cp310-win_amd64.whl (54.1 kB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10Windows x86

lotf-0.0.2.dev1-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.dev1-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.dev1-cp310-cp310-macosx_11_0_arm64.whl (48.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

lotf-0.0.2.dev1-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.dev1.tar.gz.

File metadata

  • Download URL: lotf-0.0.2.dev1.tar.gz
  • Upload date:
  • Size: 73.5 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.dev1.tar.gz
Algorithm Hash digest
SHA256 0e2b0bff61784992edb1e173e42b4aa00154acbce0c58a15794ed58cb35e8862
MD5 909af3e211886f60f2553cdf9e6f2aef
BLAKE2b-256 937bafad962cea294e2cca2729a9048bc2b533bf23246f5aa2a168ad5fa131e1

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: lotf-0.0.2.dev1-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.dev1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e95eb929ecd48fb4405cb1941d23f2dae3a37af47c4f8f6ff945a26a53d50a90
MD5 40d3becf8283e683025b67bb9dc7099c
BLAKE2b-256 210899efcedc55f0da51d5c4eb742f82a8b43ea40f802514ceec2ceb9e990932

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: lotf-0.0.2.dev1-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.dev1-cp312-abi3-win32.whl
Algorithm Hash digest
SHA256 07a5418a2c80d3e41e24568b4f03f03dea49f38a30a91b33807f49c05df828f0
MD5 9bc70eaf0f8bdc3dc2423f71ed7f6db3
BLAKE2b-256 0e1365f878675fbb6fe9ee1f409d0d08cfb4819a73cc7619374fb0a37f456d26

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lotf-0.0.2.dev1-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0e46a1f273cd29f135a5873601ab12b2fab6d68faafb02212a10dd9e79465107
MD5 706f712ca63ed0e7b97b79802a17f344
BLAKE2b-256 bf4e04d90d1a38cabf24643ed0d61794e3507dd70b1f160b4a83cad468a4b41b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lotf-0.0.2.dev1-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6b23380a9573928a2b15860d518e948e78fb7d3e7d17232c5c4883d7559c6f8f
MD5 50f8dd2d29d5f56ef97be878e574ddfd
BLAKE2b-256 3f260fa460fec399b8694a2def2e2555baabc9a8996e28c10aa2d9b16c41626f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lotf-0.0.2.dev1-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6ba7477f1ca0360e9203e7a8234ae1dabbbfcb082c47945c1008e40a5eb3e87d
MD5 1c5a24712a4c2e5a1b608054e34c4b31
BLAKE2b-256 f029653e87baa8cda0df3a0f560c4de33b074e2dd32bf2fc01c9990bbcccfbb6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lotf-0.0.2.dev1-cp312-abi3-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c55815725215f1b60ba9856d41aa84ca818e159d4cf4cf09aaf6f9acf1413876
MD5 ad1a19d7a60a685afa286383e51f0997
BLAKE2b-256 bfc17ca545452bb749523f84b2d48ae11d3bd43d71d90d2abafabcb776252949

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: lotf-0.0.2.dev1-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.dev1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f0bf0ee51c77c474dd1ed9fc85f0b934d826d88893a8e149c75dfa1f5772e7e1
MD5 3787b3756c3ad8a5108e4200a9e1cbd2
BLAKE2b-256 5ab13b095fb7d65478d94c90d25d2c7e0ea43a0e9ada2d5f2f17e100576e7268

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: lotf-0.0.2.dev1-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.dev1-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 de44bca72f46298ee458e1d14785387247a6aede7931c5bbb56ba75cd6fafb49
MD5 5608e0fd1f88153f1cdd2e8a69bd3543
BLAKE2b-256 b3eb7660944e4ac7f2bc8595bfc1c40e662d20de2de9168ea3e009e99d9a84e8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lotf-0.0.2.dev1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4db2fdf48ed45997647989f3c90399f75ce49100d2d93b8afdd4d61356b0f020
MD5 442e6d083828c0105c00c67247041426
BLAKE2b-256 23ccdc29a91bfc4920d7dd4a78046936a5e71b796b3bbe776a66df6487715b7b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lotf-0.0.2.dev1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c5902a849e0bae93f60f0d0f36d34245eca374f752149bc997cf6465bea98f13
MD5 8a137ca9a2b0fd95abbe6814a51c5578
BLAKE2b-256 5f4a83d0035f1b56a0cce7d7569c3067b5cdc11d82a5920c35da8a27dd187c34

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lotf-0.0.2.dev1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1bdb859251a6f9399c93d30b67f39e6ebe458309bde63c5b39ee674e0f1f7866
MD5 b93bb6ea6a9cbdc01cb68a86ea95e060
BLAKE2b-256 0a202fe0484b4136c7004ef65367e77132eea60c250f8bd505a14b2b3d8e8662

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lotf-0.0.2.dev1-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 308b21a3eb7e30ea4534b353b2bb8e2b62d41e5d255cde704d81fdaed7042e22
MD5 2ff4a9fd1ff663c7aca42faaa0f902a1
BLAKE2b-256 8a9414153368b9efa6d6c078d8eba9db7509ddb5b0224b73008c58b19451bdb9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: lotf-0.0.2.dev1-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.dev1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 56aa97936453f5765a3fe016ee1bf37ad44bb08dbfcd437652cd578be6387d08
MD5 5f72815865bc82d5eae8d6a98e3e24d5
BLAKE2b-256 eb40e7ca83e081418926d1bc4f0ad1b9c9a62fcbdd56ae38c448083a00c7d7e8

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: lotf-0.0.2.dev1-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.dev1-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 7c9e1432ed96b65130b3f4138605b7c34e7321f1b89331dd02433847bb8b02e0
MD5 460d60c6c6493be080291c8d03d00f6f
BLAKE2b-256 6689a6d48b5e7d7804d5a4ede1dfa4ed6ecdf35417346e61d97f948f0dcd4840

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lotf-0.0.2.dev1-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9c606a11cf853aadf87f92ce3ef7159f7dc4a5ae45725b82e322e107e9fddcdc
MD5 7c9e6b6d3b4fe2667476a49e4470071c
BLAKE2b-256 24ac40e4ab97197969237d572846ddbd108e0bc45ddacb5dd0e71bf1a507a1bc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lotf-0.0.2.dev1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6d6c1c8a4fd027c80d4aa5e91cb2d15e1d8ce0fc4cc86a6429a173a263ff69fd
MD5 b2bacdc21126a349afb8fd2085ad178d
BLAKE2b-256 f7391661a005c9e75da9f03fadb0c5aa8f03332003674f584c8e5a4111c0a24f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lotf-0.0.2.dev1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7037aa7e4fc7c675074f157c50914a821eda7861111f7b30cad894adb106c0ca
MD5 dc917d82655109c276a96e7071278248
BLAKE2b-256 1423578eba73c026acbcf5751bc7d1d2d6e15fd8768041078d120cc7c1d18e70

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lotf-0.0.2.dev1-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c0a6619efc0f60703a18fe7a3adbc1b620423690f0ac2085a3e68e02b31ebe31
MD5 6ce7bc7421290477e6b5647da97ac85d
BLAKE2b-256 e8e79d0050b38d63dbd301c30473634aebb6ef292ccf1db8e56f0f2ea033e5b1

See more details on using hashes here.

Provenance

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