[MLsys2026 Best Paper]: https://arxiv.org/abs/2506.08276. RAG on Everything with LEANN. Enjoy 97% storage savings while running a fast, accurate, and 100% private RAG application on your personal device.
Python aifaissgpt-osslangchainllama-indexllmlocalstorageoffline-firstollamaprivacypythonragretrieval-augmented-generationvector-databasevector-searchvectors
fix(packaging): ship IVF backend with default leann install (#297)
Aakash Sureshffb0d9092a0a
diff --git a/.github/workflows/build-reusable.yml b/.github/workflows/build-reusable.ymlindex e41dec8..ed87502 100644--- a/.github/workflows/build-reusable.yml+++ b/.github/workflows/build-reusable.yml@@ -363,6 +363,11 @@ jobs:ficd ../..+ # Build IVF backend (pure Python; depends on leann-core + faiss-cpu at install time)+ cd packages/leann-backend-ivf+ uv build --wheel --python ${{ matrix.python }} --find-links ${GITHUB_WORKSPACE}/packages/leann-core/dist+ cd ../..+# Build meta package (platform independent)cd packages/leannuv build@@ -555,6 +560,13 @@ jobs:uv pip install --python "$UV_PY" ./packages/leann-backend-diskannfi+ IVF_WHL=$(find packages/leann-backend-ivf/dist -maxdepth 1 -name "*.whl" -print -quit)+ if [[ -n "$IVF_WHL" ]]; then+ uv pip install --python "$UV_PY" "$IVF_WHL"+ else+ uv pip install --python "$UV_PY" ./packages/leann-backend-ivf+ fi+LEANN_WHL=$(find packages/leann/dist -maxdepth 1 -name "*.whl" -print -quit)if [[ -n "$LEANN_WHL" ]]; thenuv pip install --python "$UV_PY" "$LEANN_WHL"@@ -624,10 +636,19 @@ jobs:uv python install 3.13uv venv --python 3.13source .venv/bin/activate || source .venv/Scripts/activate- uv pip install --find-links wheels leann-core- uv pip install --find-links wheels leann-backend-hnsw- uv pip install --find-links wheels leann-backend-diskann- uv pip install --find-links wheels leann+ # Flatten artifact subdirectories into a single wheelhouse.+ # actions/download-artifact stores each artifact in its own folder and+ # pip/uv --find-links does not recurse into nested directories.+ mkdir -p wheelhouse+ find wheels -name "*.whl" -exec cp {} wheelhouse/ \;++ # Prefer wheels produced in this workflow run for our internal packages,+ # but still allow dependencies to be installed from the normal index.+ uv pip install --find-links wheelhouse leann-core+ uv pip install --find-links wheelhouse leann-backend-hnsw+ uv pip install --find-links wheelhouse leann-backend-diskann+ uv pip install --find-links wheelhouse leann-backend-ivf+ uv pip install --find-links wheelhouse leann- name: Import & tiny runtime checkenv:@@ -639,6 +660,7 @@ jobs:import leannimport leann_backend_hnsw as himport leann_backend_diskann as d+ import leann_backend_ivf as ivffrom leann import LeannBuilder, LeannSearcherb = LeannBuilder(backend_name="hnsw")b.add_text("hello arch")diff --git a/packages/leann-backend-hnsw/CMakeLists.txt b/packages/leann-backend-hnsw/CMakeLists.txtindex 4e55890..d4b2c46 100644--- a/packages/leann-backend-hnsw/CMakeLists.txt+++ b/packages/leann-backend-hnsw/CMakeLists.txt@@ -73,10 +73,11 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64")message(STATUS "Configuring Faiss for ARM64 architecture")if(CMAKE_SYSTEM_NAME STREQUAL "Linux")- # Default to generic: many ARM64 Linux CI runners (and some consumer- # devices) don't implement SVE, and Faiss built with SVE can SIGILL at- # runtime. Opt in with `-DLEANN_FAISS_ARM64_SVE=ON`.- option(LEANN_FAISS_ARM64_SVE "Enable SVE in Faiss on ARM64 Linux (requires SVE at runtime)" OFF)+ # Default generic: many ARM64 Linux hosts (GitHub ubuntu-*-arm, Ampere Altra,+ # Graviton2) do not implement SVE. Faiss built with FAISS_OPT_LEVEL=sve uses+ # -march=armv8-a+sve and can SIGILL on those CPUs. Opt in with+ # -DLEANN_FAISS_ARM64_SVE=ON for Neoverse V1 / Graviton3+ and similar.+ option(LEANN_FAISS_ARM64_SVE "Faiss SVE on ARM64 Linux (requires SVE at runtime)" OFF)if(LEANN_FAISS_ARM64_SVE)set(FAISS_OPT_LEVEL "sve" CACHE STRING "" FORCE)message(STATUS "Setting FAISS_OPT_LEVEL to 'sve' for ARM64 Linux (LEANN_FAISS_ARM64_SVE=ON)")diff --git a/packages/leann-core/pyproject.toml b/packages/leann-core/pyproject.tomlindex d7f8599..3173282 100644--- a/packages/leann-core/pyproject.toml+++ b/packages/leann-core/pyproject.toml@@ -13,8 +13,10 @@ license = "MIT"# All required dependencies includeddependencies = [- "numpy>=1.20.0,<2; python_version < '3.13'",- "numpy>=2,<3; python_version >= '3.13'",+ # NumPy wheel availability varies by platform/Python version.+ # Keep the constraint wide enough that the Arch smoke test can always+ # resolve a binary distribution (numpy>=2 isn't available in that env).+ "numpy>=1.20.0,<3","tqdm>=4.60.0","psutil>=5.8.0","pyzmq>=23.0.0",diff --git a/packages/leann/README.md b/packages/leann/README.mdindex 6c3092a..2c3a401 100644--- a/packages/leann/README.md+++ b/packages/leann/README.md@@ -5,7 +5,7 @@ LEANN is a revolutionary vector database that democratizes personal AI. Transfor## Installation```bash-# Default installation (includes both HNSW and DiskANN backends)+# Default installation (HNSW, DiskANN, and IVF backends)uv pip install leann# CPU-only install (Linux)@@ -23,8 +23,8 @@ from leann import LeannBuilder, LeannSearcher, LeannChatfrom pathlib import PathINDEX_PATH = str(Path("./").resolve() / "demo.leann")-# Build an index (choose backend: "hnsw" or "diskann")-builder = LeannBuilder(backend_name="hnsw") # or "diskann" for large-scale deployments+# Build an index (choose backend: "hnsw", "diskann", or "ivf" for incremental updates)+builder = LeannBuilder(backend_name="hnsw") # or "diskann" / "ivf"builder.add_text("LEANN saves 97% storage compared to traditional vector databases.")builder.add_text("Tung Tung Tung Sahur called—they need their banana‑crocodile hybrid back")builder.build_index(INDEX_PATH)diff --git a/packages/leann/pyproject.toml b/packages/leann/pyproject.tomlindex 667f38c..3b5e070 100644--- a/packages/leann/pyproject.toml+++ b/packages/leann/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"[project]name = "leann"-version = "0.3.7"+version = "0.3.8"description = "LEANN - The smallest vector index in the world. RAG Everything with LEANN!"readme = "README.md"requires-python = ">=3.10"@@ -24,11 +24,12 @@ classifiers = ["Programming Language :: Python :: 3.13",]-# Default installation: core + hnsw + diskann+# Default installation: core + hnsw + diskann + ivf (incremental updates)dependencies = ["leann-core>=0.1.0","leann-backend-hnsw>=0.1.0","leann-backend-diskann>=0.1.0",+ "leann-backend-ivf>=0.3.6",][project.optional-dependencies]diff --git a/tests/test_cpu_only_install.py b/tests/test_cpu_only_install.pyindex 1e1e52c..0d5c2f4 100644--- a/tests/test_cpu_only_install.py+++ b/tests/test_cpu_only_install.py@@ -31,11 +31,11 @@ def test_leann_base_dependencies_include_diskann():assert "leann-backend-diskann>=0.1.0" in deps-def test_leann_core_numpy_pinned_below_2():+def test_leann_core_numpy_is_bounded_below_3():data = _load_leann_core_pyproject()deps = data["project"].get("dependencies", [])- assert any(dep.startswith("numpy") and "<2" in dep for dep in deps)+ assert any(dep.startswith("numpy") and ">=1.20.0" in dep and "<3" in dep for dep in deps)def test_leann_core_cpu_extra_pins_cpu_torch():