Skip to main content

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.json next to the index; passage ids are stable across add/delete.
  • Search uses nprobe (default from complexity, capped by nlist). Tune nlist at build time for speed/recall.

Release files for leann-backend-ivf 0.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for leann-backend-ivf 0.3.6
File Interpreter ABI Platform
leann_backend_ivf-0.3.6-py3-none-any.whl Python 3 none any Details

Release files / leann_backend_ivf-0.3.6-py3-none-any.whl

Download URL leann_backend_ivf-0.3.6-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36d6c00379cd8bd1f67474c43b310ca3751a5ed780bdf1e27c0de160b0d421c2
BLAKE2b-256 checksum
How to use checksums
36d0f6018e7e2368a94e6764f82155818bea7096eee8a348c8c28fd2d82c3b86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.3.6 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page