█

AI/TLDR

Buy me a coffee
Buy me a coffee

LEANN

Tiny-footprint vector database for private, on-device RAG over your own data

RAG Frameworks & PlatformsOpen source
Language
Python
License
MIT
$uv venv
IN SHORT

What is LEANN?

LEANN is an open-source vector database built for running RAG (retrieval-augmented generation) on your own machine. It lets a laptop index and search across millions of documents while keeping everything local, so your data never leaves your device and there are no cloud costs. It sits in the RAG Frameworks & Platforms category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Python and licensed MIT.

Overview

LEANN is an open-source vector database built for running RAG (retrieval-augmented generation) on your own machine. It lets a laptop index and search across millions of documents while keeping everything local, so your data never leaves your device and there are no cloud costs.

Its main trick is storage savings: instead of saving every embedding, LEANN uses graph-based selective recomputation with graph pruning to compute embeddings on demand. The project reports up to 97% less storage than traditional vector databases without losing search accuracy, and it can connect to many LLM providers including Ollama, OpenAI, Anthropic, HuggingFace, and other OpenAI-compatible endpoints.

What it does

  • Graph-based selective recomputation computes embeddings on demand, cutting index storage by up to 97% with no reported accuracy loss
  • Simple declarative Python API with LeannBuilder, LeannSearcher, and LeannChat for building, searching, and chatting with an index
  • Command-line tools (leann build, search, ask, list, remove, watch) with auto-detection of formats like PDF, TXT, MD, DOCX, and code files
  • Connects to many LLM and embedding providers, including local engines (Ollama, LM Studio, vLLM, llama.cpp) and cloud APIs via OpenAI-compatible endpoints
  • RAG over personal data sources such as the file system, Apple Mail, browser history, WeChat, iMessage, and ChatGPT or Claude conversations
  • Native MCP integration that adds semantic search to Claude Code and pulls live data from platforms like Slack and Twitter

Getting started

LEANN installs from PyPI and uses uv for environment management. After installing it, you can build an index from your documents and query it from Python or the command line.

Install LEANN

Create a virtual environment with uv and install the package from PyPI.

bashbash
uv venv
source .venv/bin/activate
uv pip install leann

Build, search, and chat in Python

Use the declarative API to build an index, run a semantic search, and ask questions over your data.

pythonpython
from leann import LeannBuilder, LeannSearcher, LeannChat
from pathlib import Path
INDEX_PATH = str(Path("./").resolve() / "demo.leann")

builder = LeannBuilder(backend_name="hnsw")
builder.add_text("LEANN saves 97% storage compared to traditional vector databases.")
builder.build_index(INDEX_PATH)

searcher = LeannSearcher(INDEX_PATH)
results = searcher.search("storage savings", top_k=1)

chat = LeannChat(INDEX_PATH, llm_config={"type": "hf", "model": "Qwen/Qwen3-0.6B"})
response = chat.ask("How much storage does LEANN save?", top_k=1)

Use the command line

Build an index from a folder of documents, then search or ask questions against it.

bashbash
leann build my-docs --docs ./your_documents
leann search my-docs "machine learning concepts"
leann ask my-docs --interactive

Manage your indexes

List the indexes you have built and remove ones you no longer need.

bashbash
leann list
leann remove my-docs

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Build a private RAG assistant on your laptop that semantic-searches your files, emails, browser history, and chat archives without sending data to the cloud
  • Index very large document collections on limited storage, where saving full embeddings would be too big or would crash a traditional vector database
  • Add semantic search to Claude Code through LEANN's MCP service, so an agent can retrieve relevant context instead of relying only on keyword grep
  • Connect a local LLM such as Ollama to your indexed knowledge base for fully offline question answering over personal or team data

How LEANN compares

LEANN alongside other open-source rag frameworks & platforms tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Dify★ 162kAn open-source platform with a visual workflow builder for creating LLM and RAG applications without writing much code.
graphify★ 155kTurns a folder of code, docs, PDFs and images into a local knowledge graph with tree-sitter AST parsing and Leiden communities — queryable by agents over MCP, no vector store.
RAGFlow★ 95kA RAG engine built around deep document understanding that turns complex files into a grounded, citation-backed question-answering layer.
Context7★ 65.7kContext7 pulls current, version-specific documentation and code examples for any library and feeds them into your LLM, available as a CLI skill or an MCP server.
Pathway★ 61.9kA Python framework with a Rust streaming engine that keeps ETL, real-time analytics and RAG pipelines continuously up to date as source data changes.
LightRAG★ 41kA graph-based RAG system that builds an entity-and-relationship knowledge graph for fast retrieval and easy incremental updates.
PageIndex★ 40.8kPageIndex turns long PDFs into a table-of-contents tree and uses LLM reasoning to retrieve relevant sections, with no vector database and no chunking.
LEANN★ 13.8kTiny-footprint vector database for private, on-device RAG over your own data