Skip to content
FossShelf
Home / Categories / For Data Engineers

LEANN

Storage-efficient vector index for private on-device RAG.

Replaces Zilliz Cloud

13.80K starsMITlast commit 11 Nov 2026

Who it's for

Developers building private local RAG applications

LEANN makes it practical to build RAG over millions of personal documents (emails, files, browser history) on standard laptop hardware without cloud services. The 97% storage savings mean a 60M-chunk corpus fits in 6GB, and the fully offline operation means sensitive data never reaches external servers.

If your dataset is small (under a few thousand documents) and storage is not a constraint, a simpler in-process vector store with pre-stored embeddings involves less setup for the same result.

AI coding agent users who want semantic codebase search

The MCP-native integration makes LEANN a drop-in replacement for the keyword-based search Claude Code uses by default. Benchmarks on 30 SWE-Bench Pro tasks show 2.1x initial relevant-code recall versus BM25, which means the agent surfaces the right files earlier and uses fewer context-window tokens on repository exploration.

If your codebase is small enough that grep-style keyword search already surfaces the right context reliably, the setup cost (install, index build, MCP server config) may not justify the switch.

Research teams indexing large public document corpora

LEANN's storage efficiency is most visible at scale. The paper benchmarks a 60M-document dataset at 6GB instead of the 201GB a conventional index requires. Teams that previously needed dedicated servers for index storage can run comparable workloads on standard research hardware or a single cloud VM.

If you need GPU-accelerated embedding inference or high-concurrency API throughput for a production service, LEANN's CPU-bound on-the-fly recomputation may not meet your latency requirements.

The problem

Vector search indices are storage-heavy by design. High-dimensional embeddings and the proximity graph metadata that enables fast approximate nearest-neighbor search can together require several times more disk space than the original text data. A dataset of 60 million text chunks balloons to over 200GB once a conventional HNSW or DiskANN index is built on top. That storage requirement puts large-scale semantic search out of reach on consumer hardware. For privacy-sensitive workloads such as personal documents, emails, browser history, or internal codebases, this creates a difficult choice: accept the storage overhead on a server, pay a managed vector database provider, or fall back to keyword search. Most local AI applications use keyword (BM25) search not because it produces better results, but because it fits on a laptop.

How it works

Graph-based embedding recomputation

LEANN computes embeddings on demand during query time rather than storing them in the index. Combined with high-degree preserving pruning of the proximity graph, this cuts total index size by up to 50x compared to a standard HNSW or DiskANN index, with no measurable drop in recall or query latency for RAG workloads. The paper benchmarks show state-of-the-art accuracy at around 5% of the storage footprint of a conventional index.

Offline and fully private operation

No data leaves the local machine. LEANN runs entirely on-device with no telemetry, no cloud API calls for search or indexing, and no vendor dependency after install. This makes it suited for personal data such as emails, messages, and documents that cannot be sent to external services.

Native MCP integration for coding agents

LEANN ships as a drop-in semantic search MCP service compatible with Claude Code and other MCP-aware agents. In benchmarks on 30 SWE-Bench Pro tasks from ContextBench, it achieved 2.1x the initial relevant-code recall of BM25 and 12.6 percentage points higher relevant-code coverage after exploration, while using 8.4% fewer tokens overall.

Broad LLM provider compatibility

The generation layer connects to any OpenAI-compatible API, including Ollama, LM Studio, vLLM, llama.cpp, OpenAI, Anthropic, DeepSeek, Mistral, and others. Switching providers requires only an environment variable change. For full privacy, Ollama with a locally downloaded model keeps every request on-device.

Multi-source data ingestion

LEANN supports indexing PDF, TXT, and Markdown documents, Apple Mail, Google Search history, WeChat, iMessage, ChatGPT and Claude conversation archives, and live data from Slack and other platforms via MCP. All sources use the same declarative builder API: one configuration format handles every data type.

Features

  • Graph-based embedding recomputation
  • Offline and fully private operation
  • Native MCP integration for coding agents
  • Broad LLM provider compatibility
  • Multi-source data ingestion

How to install

Install LEANN from PyPI in a Python 3.10+ virtual environment.

pip install leann

Recommended for this setup

Strengths

  • 97% storage reduction at state-of-the-art accuracy: On published benchmarks from the MLsys2026 Best Paper, LEANN uses approximately 5% of the storage a conventional HNSW or DiskANN index requires for the same dataset, while maintaining state-of-the-art nearest-neighbor accuracy and comparable query latency. The savings come from the algorithm itself, not from compression that degrades recall.
  • No infrastructure required for the common case: LEANN installs as a single Python package from PyPI and runs in a standard virtual environment. There is no database server, no Docker requirement, and no network dependency. A developer can go from install to a working local RAG query in under ten minutes on a standard laptop.
  • MIT license with no usage restrictions: The entire library is MIT licensed. There are no commercial use restrictions, no per-query fees, no data-sharing requirements, and no managed-service upsell. Every feature is available to anyone who installs the package, including for internal commercial use.

Trade-offs

  • GPU acceleration not yet available: Embedding recomputation runs on CPU only. Without GPU support, rebuilding a large index or serving high-query-per-second workloads can be slow on consumer hardware. For datasets in the tens of millions of chunks, build time on CPU may be measured in hours. The README survey indicated GPU acceleration was a requested community feature not yet released.
  • DiskANN backend requires platform-specific native libraries: Running the DiskANN backend for very large disk-based indices requires installing libomp, Boost, Protobuf, and MKL on Linux, or equivalent packages on macOS and Windows. The setup steps are documented in the README but add meaningful complexity beyond a pip install, and some platform-specific build issues are tracked in open GitHub issues.
  • Young project with tracked build issues: First released in June 2025, LEANN has 37 open issues as of the research date. Documented known issues include a Linux hardlink failure with uv and nltk (worked around by setting UV_LINK_MODE=copy) and Ubuntu 20.04 Protobuf pinning requirements for DiskANN. Production deployments should anticipate occasional rough edges.

Tech stack

Languages
Python, Shell, CMake, Jupyter Notebook, Dockerfile
Frameworks
LangChain
Databases
FAISS
Tooling
AWS

FAQ

Does LEANN work offline with no API keys?

Yes. When using a local embedding model and a local LLM such as Ollama, LEANN runs entirely offline with no network calls. No telemetry is collected and no data leaves the device. An internet connection and API key are only required if you choose a cloud LLM provider for the generation step.

What embedding models does LEANN support?

LEANN supports any sentence-transformer model via HuggingFace (for example, facebook/contriever or nomic-embed-text), any OpenAI-compatible embedding endpoint (such as Jina AI or OpenAI text-embedding-3-small), and local inference via Ollama or vLLM. The embedding model and generation LLM can be configured independently via environment variables or CLI flags.

How does LEANN compare to storing embeddings in a FAISS index directly?

A standard FAISS index stores every embedding vector plus the proximity graph on disk, which requires full storage for each indexed document. LEANN stores only the compressed graph and recomputes vectors at query time from the raw text chunks. The tradeoff is modest CPU overhead per query in exchange for up to 50x less storage. On benchmark datasets, query latency for RAG workloads remains comparable to conventional indices.

Can LEANN be used with LangChain or LlamaIndex?

Yes. The repository lists both langchain and llama-index among its GitHub topics, and the README documents LLM backend compatibility with HuggingFace, Ollama, Anthropic, and any OpenAI-compatible API. The builder and searcher API maps to retriever abstractions in both frameworks.

What operating systems and Python versions does LEANN support?

LEANN runs on Python 3.10 through 3.14 on Ubuntu, Arch Linux, macOS (ARM64 and Intel), Windows native, and WSL. The base install via pip or uv has no native dependency requirements. The optional DiskANN backend for very large datasets requires platform-specific C++ libraries as documented in the repository README.

Similar tools

More in Data Engineers