LEANN for Local RAG: Storage, Recall and Tradeoffs
Understand LEANN’s selective embedding recomputation, interpret its 97% storage claim, and evaluate local RAG with a worked budget, diagrams and an interactive calculator.
BY MEI LIN · FDEINTERVIEWS EDITORIAL · UPDATED OCTOBER 23, 2026 · 9 MIN READ
PRACTICE THIS:Vector database fundamentals ·Capacity planning for vector indexes ·Embedding versions and drift ·RAG and agent design questions
LEANN is a storage-efficient approximate nearest-neighbor index. Its central trade is to retain a compact search structure and recompute selected document embeddings when a query needs them. That makes it worth evaluating when storing every dense vector is the constraint and the machine can afford additional inference during retrieval.
A personal knowledge base queried a few times an hour has different constraints from a shared service. Start with the customer’s disk ceiling, query rate and latency requirement. Use the vector database fundamentals to separate the index from the surrounding retrieval service.
Sources: LEANN project and implementation.
How the index and query paths fit together
The MLSys 2026 paper describes a build path that computes embeddings, constructs a proximity graph, preserves useful connections around high-degree nodes, and retains compressed vector information. Query processing uses cheap approximate distances to select promising candidates, then regenerates exact embeddings from source content. Exact and approximate scoring interact during traversal; this is more than a final reranking pass. Batching improves the utilization of the embedding hardware.
Follow the source-content box below: recomputation still needs the original chunks and a reproducible embedding model. Keep both with the index.
The figure explains the paper’s two-level design. The repository offers HNSW and DiskANN backends with different paths and settings. For example, its configuration guide describes DiskANN with recompute enabled as PQ traversal followed by final reranking, unlike the paper’s interleaved traversal. Check the selected backend before assuming that every paper optimization is active in your installed package.
THE STORAGE / COMPUTE EXCHANGE
Keep the routes. Recreate selected vectors.
OFFLINE
Build once
- 01
Embed the source chunks
Create vectors with a recorded model and preprocessing configuration.
- 02
Construct and prune the graph
Retain useful routes through highly connected nodes.
- 03
Persist compact search data
Keep graph links and compressed vector information.
PER QUERY
Search on demand
- 01
Embed the question
Use the query configuration compatible with the index.
- 02
Explore and recompute selectively
Approximate scoring selects candidates; exact scoring guides further exploration.
- 03
Return evidence
Rank visited candidates and return source passages for the downstream task.
Source content + reproducible embedding model
Both paths depend on these. Query-time recomputation still needs the original inputs. Batch candidate embeddings; repeat exploration until the search stops.
Sources: MLSys 2026 paper, sections 3–6, Backend and recomputation configuration.
Read the 97% claim with its denominator
The project README reports a 60-million-chunk Wikipedia comparison: 201 GB for its conventional-vector baseline and 6 GB for LEANN. The arithmetic is (201 − 6) / 201 = 97.0% less index storage, or a 33.5-fold ratio. These are the project’s reported results, not a benchmark run by FDE Interviews.
That is not a 6 GB total application footprint. Source documents, parsed chunks, model weights and caches remain separate items. Measure peak build disk and memory too; creating the index can require more headroom than serving it.
Compare quality at the same k, embedding configuration and dataset. Nearest-neighbor recall, passage relevance and generated-answer quality are different measurements. “Without accuracy loss” on one benchmark is not a guarantee for a customer corpus.
Sources: Project-reported storage comparisons, Paper evaluation and experimental conditions.
Work a complete storage budget
Use the calculator to distinguish index savings from application savings. Its starting example is deliberately synthetic: one million chunks, 768-dimensional float32 vectors and 32 four-byte neighbor IDs per chunk. That gives 3.072 GB of dense vectors plus 0.128 GB of adjacency data before additional implementation overhead.
The example also reserves 1,000 bytes of source text per chunk and 0.5 GB for model files. Enter a measured candidate-index size instead of assuming the README’s percentage applies. At the initial 100 MB candidate size, the simplified index subtotal falls from 3.2 GB to 0.1 GB; the application subtotal falls from 4.7 GB to 1.6 GB. Those are 96.9% and 66.0% savings respectively. The different percentages are both correct because their denominators differ.
The calculator excludes metadata, filesystem overhead, runtime memory, build scratch space and caches. It predicts neither LEANN’s size nor its latency. Practice the same arithmetic in vector-index capacity planning.
WORKED BUDGET / SYNTHETIC ASSUMPTIONS
What is actually getting smaller?
Candidate size is your input, not a LEANN prediction. Decimal units: 1 GB = 1,000 MB. Fixed assumptions: 768 float32 dimensions, 32 four-byte neighbor IDs, 1,000 source bytes per chunk and 0.5 GB of model files.
| Component | Dense | Candidate |
|---|---|---|
| Source chunks | 1.000 GB | 1.000 GB |
| Model files | 0.500 GB | 0.500 GB |
| Index | 3.200 GB | 0.100 GB |
| Application subtotal | 4.700 GB | 1.600 GB |
Index alone
96.9% smaller
Application subtotal
66.0% smaller
Excludes metadata, filesystem overhead, runtime memory, build scratch space and caches. Smaller on disk says nothing about retrieval latency or answer quality.
A first evaluation that can change your decision
Start with a bounded, approved corpus and a frozen set of queries. For a hypothetical support-manual pilot, include ordinary paraphrases, exact part numbers, ambiguous product names and questions with no answer in the corpus. Label which source passages support each answer before comparing retrievers. Keep a holdout set for the final decision.
Build a dense baseline and the candidate index using the same chunk boundaries, embedding model and similarity convention. Record exact dependency versions and backend settings. An ANN recall test can compare returned IDs with exhaustive nearest neighbors on a manageable subset; a relevance test compares results with human-labeled useful passages. Report these as separate measurements.
Measure retrieval latency independently of generation. Run a cold process, a warmed process and concurrent queries. Record p50 and p95 alongside peak memory, disk footprint, build duration and query-time embedding work. Publish the machine specification and whether the corpus and model were already cached. A one-user warm-cache demonstration does not establish the p95 of the shared customer service.
Choose acceptance criteria before tuning: passage relevance, disk ceiling and p95 retrieval deadline. Set thresholds from the application. If latency fails, investigate query-time embedding work and contention before changing the generation model.
Local storage is only one privacy boundary
LEANN supports local and remote model providers. Selecting a cloud embedding provider can send source text out during indexing and query-time recomputation. Selecting a cloud generation provider can send the question and retrieved passages out even when the index itself stays on disk. Audit both paths.
For an offline deployment, provision models first, then test with outbound access disabled. Use a synthetic corpus while inspecting traffic. Installation downloads are a separate setup phase.
Access control belongs around the retrieval workflow. A local index is not proof that every user is entitled to every document. For an initial multi-user pilot, separate corpora by authorization boundary or verify that filtering prevents unauthorized source text from reaching embedding calls, returned snippets, logs and generation. Retrieved text remains untrusted input even when it came from a trusted directory.
Sources: Generation providers and local/remote configuration, Embedding-provider settings.
Where the trade can fail
Recomputation moves work into the query path. A high query rate, an expensive encoder or a saturated GPU can turn a disk win into a latency problem. Repeated popular queries may benefit from caching, but count the cache in the storage budget and test eviction behavior rather than reporting only its best case.
Preserve the model revision, tokenizer, normalization and document/query templates. A successful file load does not establish compatibility with a changed encoder. See embedding versions and drift before changing any of these inputs.
Treat updates and deletions as release tests. Add a document, change a passage, remove a document and revoke its permission. Verify the resulting search results and any saved snippets. Package support for incremental operations depends on the backend and version; the paper’s update design is not a promise that every interface exposes the same behavior.
For exact identifiers, retain an exact or lexical retrieval path and evaluate the combined system. Semantic proximity alone is a weak contract for a serial number. If the customer needs replication, transactional metadata changes or a particular service-level objective, evaluate those capabilities explicitly instead of assuming an ANN library supplies the surrounding database service.
Sources: Backend and tuning notes, Project troubleshooting notes.
| Workload constraint | What to evaluate | Reason to keep the existing path |
|---|---|---|
| Tight disk budget, modest query traffic | LEANN with measured recomputation cost | Cold or concurrent p95 misses the deadline |
| Exact product identifiers | Lexical retrieval alongside vector search | Useful passages are missed despite high ANN recall |
| Shared or restricted corpus | Authorization, revocation and cache tests | Unauthorized snippets reach retrieval or generation |
How to explain the decision in an interview
A defensible answer starts with the constraint: “I would evaluate LEANN for a storage-constrained corpus with modest query traffic. I would keep the source text and embedding configuration reproducible, then compare retrieval relevance, cold and warm p95, and peak build resources against a dense baseline.” This is a proposed approach, not a reported company interview answer.
Practice this decision with the RAG and agent questions. For the 97% claim, identify the index-storage denominator. For privacy, trace both embedding and generation requests. For a rollout, record the approved corpus, model/backend revisions, acceptance thresholds and rollback trigger. Keep the existing retrieval path until the candidate passes the customer workload.
Turn it into offers. Work the real questions and concepts this maps to:
FAQ
LEANN is a storage-efficient approximate nearest-neighbor index for embedding search. It reduces stored dense-vector data by recomputing selected embeddings during retrieval. Its usefulness depends on the workload’s storage, latency and quality requirements.
No. The project reports 201 GB versus 6 GB for a 60-million-chunk comparison, approximately 97% less index storage. That does not include every component of an application or guarantee the same saving on a different corpus.
It can be part of a local deployment, but provider configuration matters. Remote embedding or generation services may receive source text, queries or retrieved passages. Provision local models and verify the application without outbound access before calling a deployment offline.
No. Measure nearest-neighbor recall, relevance of retrieved passages and grounded answer quality separately. Use the same dataset and embedding configuration for comparisons, then test the complete application on held-out customer queries.
Evaluate it when index storage is a binding constraint and query-time recomputation fits the latency and compute budget. Verify required filtering, updates, operational controls and concurrency before replacing a working retrieval service.
Discussion (3)
Editorial note: the candidate-size slider is an input, not an estimate. Measure the index artifact, then enter that value. The dense baseline is also simplified; production overhead belongs in a separate measurement.
For an exact part number, include a lexical baseline in the evaluation. Nearest-neighbor recall measures agreement with vector neighbors; it does not establish that those neighbors answer the customer’s question.
Test permission revocation with a warmed cache as well as a new process. A search that correctly excludes a document can still be undermined by a saved snippet elsewhere in the application.
