diff --git a/README.md b/README.md index d78b290..85ea74d 100755 --- a/README.md +++ b/README.md @@ -1,64 +1,62 @@ -
+
+
-
-
+
- đž Extreme Storage Saving âĸ đ 100% Private âĸ đ RAG Everything âĸ ⥠Easy & Accurate
+
- Quick Start âĸ - Features âĸ - Benchmarks âĸ - Paper -
+**Bottom line:** Index 60 million Wikipedia articles in 6GB instead of 201GB. Your MacBook can finally handle real datasets. ---- +## Why This Matters -## đ What is LEANN-RAG? +**Privacy:** Your data never leaves your laptop. No OpenAI, no cloud, no "terms of service". -**LEANN-RAG** is a lightweight, locally deployable **Retrieval-Augmented Generation (RAG)** engine designed for personal devices. It combines **compact storage**, **clean usability**, and **privacy-by-design**, making it easy to build personalized retrieval systems over your own data â emails, notes, documents, chats, or anything else. +**Speed:** Real-time search on consumer hardware. No server setup, no configuration hell. -Unlike traditional vector databases that rely on massive embedding storage, LEANN reduces storage needs dramatically by using **graph-based recomputation** and **pruned HNSW search**, while maintaining responsive and reliable performance â all without sending any data to the cloud. +**Scale:** Handle datasets that would crash traditional vector DBs on your laptop. ---- +## 30-Second Demo: RAG Your Life -## đĨ Key Highlights +```python +from leann.api import LeannBuilder, LeannSearcher -### đž 1. Extreme Storage Efficiency -LEANN reduces storage usage by **up to 97%** compared to conventional vector DBs (e.g., FAISS), by storing only pruned graph structures and computing embeddings at query time. -> For example: 60M chunks can be indexed in just **6GB**, compared to **200GB+** with dense storage. +# Index your entire email history (90K emails = 14MB vs 305MB) +builder = LeannBuilder(backend_name="hnsw") +builder.add_from_mailbox("~/Library/Mail") # Your actual emails +builder.build_index("my_life.leann") -### đ 2. Fully Private, Cloud-Free -LEANN runs entirely locally. No cloud services, no API keys, and no risk of leaking sensitive data. -> Converse with your own files **without compromising privacy**. +# Ask questions about your own data +searcher = LeannSearcher("my_life.leann") +searcher.search("What did my boss say about the deadline?") +searcher.search("Find emails about vacation requests") +searcher.search("Show me all conversations with John about the project") +``` -### đ§ 3. RAG Everything -Build truly personalized assistants by querying over **your own** chat logs, email archives, browser history, or agent memory. -> LEANN makes it easy to integrate personal context into RAG workflows. +**That's it.** No cloud setup, no API keys, no "fine-tuning". Just your data, your questions, your laptop. -### ⥠4. Easy, Accurate, and Fast -LEANN is designed to be **easy to install**, with a **clean API** and minimal setup. It runs efficiently on consumer hardware without sacrificing retrieval accuracy. -> One command to install, one click to run. +[Try the interactive demo â](demo.ipynb) ---- - -## đ Why Choose LEANN? - -Traditional RAG systems often require trade-offs between storage, privacy, and usability. **LEANN-RAG aims to simplify the stack** with a more practical design: - -- â **No embedding storage** â compute on demand, save disk space -- â **Low memory footprint** â lightweight and hardware-friendly -- â **Privacy-first** â 100% local, no network dependency -- â **Simple to use** â developer-friendly API and seamless setup - -> đ For more details, see our [academic paper](https://arxiv.org/abs/2506.08276) -## đ Quick Start +## Get Started in 30 Seconds ### Installation @@ -115,24 +113,6 @@ ollama pull llama3.2:3b **Note:** For Hugging Face models >1B parameters, you may encounter OOM errors on consumer hardware. Consider using smaller models like Qwen3-0.6B or switch to Ollama for better memory management. -### 30-Second Example -Try it out in [**demo.ipynb**](demo.ipynb) - -```python -from leann.api import LeannBuilder, LeannSearcher -# 1. Build index (no embeddings stored!) -builder = LeannBuilder(backend_name="hnsw") -builder.add_text("C# is a powerful programming language") -builder.add_text("Python is a powerful programming language") -builder.add_text("Machine learning transforms industries") -builder.add_text("Neural networks process complex data") -builder.add_text("Leann is a great storage saving engine for RAG on your macbook") -builder.build_index("knowledge.leann") -# 2. Search with real-time embeddings -searcher = LeannSearcher("knowledge.leann") -results = searcher.search("C++ programming languages", top_k=2, recompute_beighbor_embeddings=True) -print(results) -``` ### Run the Demo (support .pdf,.txt,.docx, .pptx, .csv, .md etc) @@ -146,6 +126,40 @@ or you want to use python source .venv/bin/activate python ./examples/main_cli_example.py ``` +## Wild Things You Can Do + +### đĩī¸ Search Your Entire Life +```bash +python examples/mail_reader_leann.py +# "What did my boss say about the Christmas party last year?" +# "Find all emails from my mom about birthday plans" +``` +**90K emails â 14MB.** Finally, search your email like you search Google. + +### đ Time Machine for the Web +```bash +python examples/google_history_reader_leann.py +# "What was that AI paper I read last month?" +# "Show me all the cooking videos I watched" +``` +**38K browser entries â 6MB.** Your browser history becomes your personal search engine. + +### đŦ WeChat Detective +```bash +python examples/wechat_history_reader_leann.py +# "ææŗäš°éæ¯å¸įēĻįŋ°éįįčĄŖīŧįģæä¸äē寚åēčå¤ŠčŽ°åŊ" +# "Show me all group chats about weekend plans" +``` +**400K messages â 64MB.** Search years of chat history in any language. + +### đ Personal Wikipedia +```bash +# Index 60M Wikipedia articles in 6GB (not 201GB) +python examples/build_massive_index.py --source wikipedia +# "Explain quantum computing like I'm 5" +# "What are the connections between philosophy and AI?" +``` + **PDF RAG Demo (using LlamaIndex for document parsing and Leann for indexing/search)** This demo showcases how to build a RAG system for PDF/md documents using Leann. @@ -155,254 +169,42 @@ This demo showcases how to build a RAG system for PDF/md documents using Leann. -## ⨠Features +## How It Works -### đĨ Core Features +LEANN doesn't store embeddings. Instead, it builds a lightweight graph and computes embeddings on-demand during search. -- **đ Real-time Embeddings** - Eliminate heavy embedding storage with dynamic computation using optimized ZMQ servers and highly optimized search paradigm (overlapping and batching) with highly optimized embedding engine -- **đ Scalable Architecture** - Handles millions of documents on consumer hardware; the larger your dataset, the more LEANN can save -- **đ¯ Graph Pruning** - Advanced techniques to minimize the storage overhead of vector search to a limited footprint -- **đī¸ Pluggable Backends** - DiskANN, HNSW/FAISS with unified API +**The magic:** Most vector DBs store every single embedding (expensive). LEANN stores a pruned graph structure (cheap) and recomputes embeddings only when needed (fast). -### đ ī¸ Technical Highlights -- **đ Recompute Mode** - Highest accuracy scenarios while eliminating vector storage overhead -- **⥠Zero-copy Operations** - Minimize IPC overhead by transferring distances instead of embeddings -- **đ High-throughput Embedding Pipeline** - Optimized batched processing for maximum efficiency -- **đ¯ Two-level Search** - Novel coarse-to-fine search overlap for accelerated query processing (optional) -- **đž Memory-mapped Indices** - Fast startup with raw text mapping to reduce memory overhead -- **đ MLX Support** - Ultra-fast recompute with quantized embedding models, accelerating building and search by 10-100x ([minimal example](test/build_mlx_index.py)) +**Backends:** DiskANN, HNSW, or FAISS - pick what works for your data size. -### đ¨ Developer Experience +**Performance:** Real-time search on millions of documents. MLX support for 10-100x faster building on Apple Silicon. -- **Simple Python API** - Get started in minutes -- **Extensible backend system** - Easy to add new algorithms -- **Comprehensive examples** - From basic usage to production deployment -## Applications on your MacBook -### đ§ Lightweight RAG on your Apple Mail - -LEANN can create a searchable index of your Apple Mail emails, allowing you to query your email history using natural language. - -#### Quick Start - -
-
+