LEANN IVF Backend
FAISS IndexIVFFlat backend for LEANN with add and delete APIs for incremental updates (#231, #89, #141).
Install
uv sync --package leann-backend-ivf
# or
pip install leann-backend-ivf
Requires faiss-cpu. For query embedding during search, the IVF searcher uses the same embedding server as HNSW; install leann-backend-hnsw if you use recompute/query embedding.
Build
leann build my-index --docs ./src --backend-name ivf
Optional backend kwargs (e.g. via API): nlist (default 100), distance_metric ("l2" or "cosine"/"mips").
Add / Delete API
Follows the same idea as HNSW’s update path; use these for incremental workflows (e.g. after Merkle tree / file-change API):
-
add_vectors(index_path, embeddings, passage_ids)Appends vectors to an existing IVF index.embeddings:(N, D)float32;passage_ids: list of N passage id strings (must not already exist). -
remove_ids(index_path, passage_ids)Removes vectors by passage id. Returns the number of vectors removed. Use after detecting changed chunk ids: delete old, then re-insert new.
Example:
from leann_backend_ivf import add_vectors, remove_ids
# After file-change API says chunk id "abc123" changed:
remove_ids("/path/to/index.leann", ["abc123"])
# Re-embed and add new chunk with same or new id
add_vectors("/path/to/index.leann", new_embeddings, ["abc123"])
Core integration (#89, #141)
LeannBuilder.update_index(index_path, remove_passage_ids=None) in leann-core supports IVF: it calls add_vectors for appends and, when remove_passage_ids is set, calls remove_ids first (e.g. from a file-change / Merkle API). Use for incremental build or reindex: detect changed chunk ids → update_index(path, remove_passage_ids=changed_ids) then add chunks for the new content.
Notes
- IVF stores vectors in flat lists per cluster; no compact/recompute mode like HNSW. Good for frequent add/delete.
- ID mapping is stored in
ivf_id_map.jsonnext to the index; passage ids are stable across add/delete. - Search uses
nprobe(default fromcomplexity, capped bynlist). Tunenlistat build time for speed/recall.
Metadata
Release files for leann-backend-ivf 0.3.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| leann_backend_ivf-0.3.9-py3-none-any.whl | Python 3 | none | any | Details for leann_backend_ivf-0.3.9-py3-none-any.whl |
Release files / leann_backend_ivf-0.3.9-py3-none-any.whl
| Download URL | leann_backend_ivf-0.3.9-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
df959667176ee11406d043f1a34238d7574988dc6b4315084aa3ac6c7181184e
|
|
BLAKE2b-256 checksum How to use checksums |
0d6c967d43e464495bb51e382bbd3add424423c2e970cbb674b8ae57a21ee5e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for leann-backend-ivf 0.3.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.