[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-yichuan-w--LEANN":3,"tool-yichuan-w--LEANN":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",147882,2,"2026-04-09T11:32:47",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108111,"2026-04-08T11:23:26",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[35,15,13,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":76,"owner_email":76,"owner_twitter":76,"owner_website":77,"owner_url":78,"languages":79,"stars":100,"forks":101,"last_commit_at":102,"license":103,"difficulty_score":32,"env_os":104,"env_gpu":105,"env_ram":106,"env_deps":107,"category_tags":120,"github_topics":122,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":139,"updated_at":140,"faqs":141,"releases":171},5890,"yichuan-w\u002FLEANN","LEANN","[MLsys2026]: RAG on Everything with LEANN. Enjoy 97% storage savings while running a fast, accurate, and 100% private RAG application on your personal device.","LEANN 是一款创新的向量数据库，旨在将你的个人电脑变身强大的私人 AI 助手。它核心解决了传统检索增强生成（RAG）系统存储成本高昂且依赖云服务的痛点，让你能在本地设备上对数百万份文档、邮件、聊天记录甚至代码库进行语义搜索，同时节省高达 97% 的存储空间且不损失准确性。\n\n这款工具特别适合注重数据隐私的个人用户、希望在本地部署高效 RAG 应用的开发者，以及需要处理海量私有数据的研究人员。无论是整理微信聊天记忆、归档浏览器历史，还是构建个人知识库，LEANN 都能在不产生云端费用并确保数据完全私密的前提下轻松胜任。\n\n其独特的技术亮点在于采用了“基于图的选择性重计算”与“保持高度剪枝”算法。与传统方案预先存储所有向量不同，LEANN 按需计算嵌入向量，从而实现了极致的压缩效率。作为全球最小的向量索引之一，LEANN 让在笔记本电脑上运行快速、精准且 100% 私有的 AI 应用成为现实，真正推动了个人 AI 的普及。","\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_73108177e111.png\" alt=\"LEANN Logo\" width=\"400\">\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Ftrendshift.io\u002Frepositories\u002F15049\" target=\"_blank\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_4cc089988f35.png\" alt=\"yichuan-w\u002FLEANN | Trendshift\" style=\"width: 250px; height: 55px;\" width=\"250\" height=\"55\"\u002F>\n  \u003C\u002Fa>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPython-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue.svg\" alt=\"Python Versions\">\n  \u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN\u002Factions\u002Fworkflows\u002Fbuild-and-publish.yml\u002Fbadge.svg\" alt=\"CI Status\">\n  \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPlatform-Ubuntu%20%26%20Arch%20%26%20WSL%20%7C%20macOS%20(ARM64%2FIntel)%20%7C%20Windows-lightgrey\" alt=\"Platform\">\n  \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-green.svg\" alt=\"MIT License\">\n  \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FMCP-Native%20Integration-blue\" alt=\"MCP Integration\">\n  \u003Ca href=\"https:\u002F\u002Fjoin.slack.com\u002Ft\u002Fleann-e2u9779\u002Fshared_invite\u002Fzt-3ol2ww9ic-Eg_kB8omwe6xmYVd0epr4Q\">\n    \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSlack-Join-4A154B?logo=slack&logoColor=white\" alt=\"Join Slack\">\n  \u003C\u002Fa>\n\n\u003C\u002Fp>\n\n\u003Cdiv align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fforms.gle\u002FrDbZf864gMNxhpTq8\">\n    \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F📣_Community_Survey-Help_Shape_v0.4-007ec6?style=for-the-badge&logo=google-forms&logoColor=white\" alt=\"Take Survey\">\n  \u003C\u002Fa>\n  \u003Cp>\n    We track \u003Cb>zero telemetry\u003C\u002Fb>. This survey is the ONLY way to tell us if you want \u003Cbr>\n    \u003Cb>GPU Acceleration\u003C\u002Fb> or \u003Cb>More Integrations\u003C\u002Fb> next.\u003Cbr>\n    👉 \u003Ca href=\"https:\u002F\u002Fforms.gle\u002FrDbZf864gMNxhpTq8\">\u003Cb>Click here to cast your vote (2 mins)\u003C\u002Fb>\u003C\u002Fa>\n  \u003C\u002Fp>\n\u003C\u002Fdiv>\n\n\u003Cdiv align=\"center\">\n  \u003Ch3>💬 Join our Slack community!\u003C\u002Fh3>\n  \u003Cp>\n    We'd love for you to be part of the LEANN community!\u003Cbr>\n    👉 \u003Ca href=\"https:\u002F\u002Fjoin.slack.com\u002Ft\u002Fleann-e2u9779\u002Fshared_invite\u002Fzt-3ol2ww9ic-Eg_kB8omwe6xmYVd0epr4Q\">\u003Cb>Join LEANN Slack\u003C\u002Fb>\u003C\u002Fa>\u003Cbr>\n    If the invite link has expired or you have trouble joining, please \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN\u002Fissues\">open an issue\u003C\u002Fa> and we'll help you get in!\n  \u003C\u002Fp>\n\u003C\u002Fdiv>\n\n\u003Ch2 align=\"center\" tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">\n    The smallest vector index in the world. RAG Everything with LEANN!\n\u003C\u002Fh2>\n\nLEANN is an innovative vector database that democratizes personal AI. Transform your laptop into a powerful RAG system that can index and search through millions of documents while using **97% less storage** than traditional solutions **without accuracy loss**.\n\n\nLEANN achieves this through *graph-based selective recomputation* with *high-degree preserving pruning*, computing embeddings on-demand instead of storing them all. [Illustration Fig →](#️-architecture--how-it-works) | [Paper →](https:\u002F\u002Farxiv.org\u002Fabs\u002F2506.08276)\n\n**Ready to RAG Everything?** Transform your laptop into a personal AI assistant that can semantic search your **[file system](#-personal-data-manager-process-any-documents-pdf-txt-md)**, **[emails](#-your-personal-email-secretary-rag-on-apple-mail)**, **[browser history](#-time-machine-for-the-web-rag-your-entire-browser-history)**, **[chat history](#-wechat-detective-unlock-your-golden-memories)** ([WeChat](#-wechat-detective-unlock-your-golden-memories), [iMessage](#-imessage-history-your-personal-conversation-archive)), **[agent memory](#-chatgpt-chat-history-your-personal-ai-conversation-archive)** ([ChatGPT](#-chatgpt-chat-history-your-personal-ai-conversation-archive), [Claude](#-claude-chat-history-your-personal-ai-conversation-archive)), **[live data](#mcp-integration-rag-on-live-data-from-any-platform)** ([Slack](#slack-messages-search-your-team-conversations), [Twitter](#-twitter-bookmarks-your-personal-tweet-library)), **[codebase](#-claude-code-integration-transform-your-development-workflow)**\\* , or external knowledge bases (i.e., 60M documents) - all on your laptop, with zero cloud costs and complete privacy.\n\n\n\\* Claude Code only supports basic `grep`-style keyword search. **LEANN** is a drop-in **semantic search MCP service fully compatible with Claude Code**, unlocking intelligent retrieval without changing your workflow. 🔥 Check out [the easy setup →](packages\u002Fleann-mcp\u002FREADME.md)\n\n\n\n## Why LEANN?\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_501c6b7cac1f.png\" alt=\"LEANN vs Traditional Vector DB Storage Comparison\" width=\"70%\">\n\u003C\u002Fp>\n\n> **The numbers speak for themselves:** Index 60 million text chunks in just 6GB instead of 201GB. From emails to browser history, everything fits on your laptop. [See detailed benchmarks for different applications below ↓](#-storage-comparison)\n\n\n🔒 **Privacy:** Your data never leaves your laptop. No OpenAI, no cloud, no \"terms of service\".\n\n🪶 **Lightweight:** Graph-based recomputation eliminates heavy embedding storage, while smart graph pruning and CSR format minimize graph storage overhead. Always less storage, less memory usage!\n\n📦 **Portable:** Transfer your entire knowledge base between devices (even with others) with minimal cost - your personal AI memory travels with you.\n\n📈 **Scalability:** Handle messy personal data that would crash traditional vector DBs, easily managing your growing personalized data and agent generated memory!\n\n✨ **No Accuracy Loss:** Maintain the same search quality as heavyweight solutions while using 97% less storage.\n\n## Installation\n\n### 📦 Prerequisites: Install uv\n\n[Install uv](https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002Fgetting-started\u002Finstallation\u002F#installation-methods) first if you don't have it. Typically, you can install it with:\n\n```bash\ncurl -LsSf https:\u002F\u002Fastral.sh\u002Fuv\u002Finstall.sh | sh\n```\n\n### 🚀 Quick Install\n\nClone the repository to access all examples and try amazing applications,\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN.git leann\ncd leann\n```\n\nand install LEANN from [PyPI](https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F) to run them immediately:\n\n```bash\nuv venv\nsource .venv\u002Fbin\u002Factivate\nuv pip install leann\n\n# CPU-only (Linux): use the `cpu` extra (e.g. `leann[cpu]`)\n```\n\n\u003C!--\n> Low-resource? See \"Low-resource setups\" in the [Configuration Guide](docs\u002Fconfiguration-guide.md#low-resource-setups). -->\n\n\u003Cdetails>\n\u003Csummary>\n\u003Cstrong>🔧 Build from Source (Recommended for development)\u003C\u002Fstrong>\n\u003C\u002Fsummary>\n\n\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN.git leann\ncd leann\ngit submodule update --init --recursive\n```\n\n**macOS:**\n\nNote: DiskANN requires MacOS 13.3 or later.\n\n```bash\nbrew install libomp boost protobuf zeromq pkgconf\nuv sync --extra diskann\n```\n\n**Linux (Ubuntu\u002FDebian):**\n\nNote: On Ubuntu 20.04, you may need to build a newer Abseil and pin Protobuf (e.g., v3.20.x) for building DiskANN. See [Issue #30](https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN\u002Fissues\u002F30) for a step-by-step note.\n\nYou can manually install [Intel oneAPI MKL](https:\u002F\u002Fwww.intel.com\u002Fcontent\u002Fwww\u002Fus\u002Fen\u002Fdeveloper\u002Ftools\u002Foneapi\u002Fonemkl.html) instead of `libmkl-full-dev` for DiskANN. You can also use `libopenblas-dev` for building HNSW only, by removing `--extra diskann` in the command below.\n\n```bash\nsudo apt-get update && sudo apt-get install -y \\\n  libomp-dev libboost-all-dev protobuf-compiler libzmq3-dev \\\n  pkg-config libabsl-dev libaio-dev libprotobuf-dev \\\n  libmkl-full-dev\n\nuv sync --extra diskann\n```\n\n**Linux (Arch Linux):**\n\n```bash\nsudo pacman -Syu && sudo pacman -S --needed base-devel cmake pkgconf git gcc \\\n  boost boost-libs protobuf abseil-cpp libaio zeromq\n\n# For MKL in DiskANN\nsudo pacman -S --needed base-devel git\ngit clone https:\u002F\u002Faur.archlinux.org\u002Fparu-bin.git\ncd paru-bin && makepkg -si\nparu -S intel-oneapi-mkl intel-oneapi-compiler\nsource \u002Fopt\u002Fintel\u002Foneapi\u002Fsetvars.sh\n\nuv sync --extra diskann\n```\n\n**Linux (RHEL \u002F CentOS Stream \u002F Oracle \u002F Rocky \u002F AlmaLinux):**\n\nSee [Issue #50](https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN\u002Fissues\u002F50) for more details.\n\n```bash\nsudo dnf groupinstall -y \"Development Tools\"\nsudo dnf install -y libomp-devel boost-devel protobuf-compiler protobuf-devel \\\n  abseil-cpp-devel libaio-devel zeromq-devel pkgconf-pkg-config\n\n# For MKL in DiskANN\nsudo dnf install -y intel-oneapi-mkl intel-oneapi-mkl-devel \\\n  intel-oneapi-openmp || sudo dnf install -y intel-oneapi-compiler\nsource \u002Fopt\u002Fintel\u002Foneapi\u002Fsetvars.sh\n\nuv sync --extra diskann\n```\n\n**Windows:**\n\nRequires [Visual Studio 2022 Build Tools](https:\u002F\u002Fvisualstudio.microsoft.com\u002Fdownloads\u002F#build-tools-for-visual-studio-2022) with the **C++ desktop development** workload, and [vcpkg](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fvcpkg).\n\n```powershell\n# Install toolchain (if not already present)\nchoco install cmake swig pkgconfiglite nuget.commandline -y\n\n# Install C++ dependencies via vcpkg\nvcpkg install zeromq:x64-windows openblas:x64-windows lapack:x64-windows `\n  boost-program-options:x64-windows protobuf:x64-windows\n\n# Set environment variables (adjust VCPKG_ROOT to your vcpkg path)\n$env:CMAKE_PREFIX_PATH = \"$env:VCPKG_ROOT\\installed\\x64-windows\"\n$env:PKG_CONFIG_PATH = \"$env:VCPKG_ROOT\\installed\\x64-windows\\lib\\pkgconfig\"\n$env:PKG_CONFIG_EXECUTABLE = \"C:\\ProgramData\\chocolatey\\bin\\pkg-config.exe\"\n$env:OPENBLAS_LIB = \"$env:VCPKG_ROOT\\installed\\x64-windows\\lib\\openblas.lib\"\n$env:PATH += \";$env:VCPKG_ROOT\\installed\\x64-windows\\bin\"\n$env:PATH += \";$env:VCPKG_ROOT\\installed\\x64-windows\\tools\\protobuf\"\n\nuv sync --extra diskann\n```\n\n\u003C\u002Fdetails>\n\n\n## Quick Start\n\nOur declarative API makes RAG as easy as writing a config file.\n\nCheck out [demo.ipynb](demo.ipynb) or [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fyichuan-w\u002FLEANN\u002Fblob\u002Fmain\u002Fdemo.ipynb)\n\n```python\nfrom leann import LeannBuilder, LeannSearcher, LeannChat\nfrom pathlib import Path\nINDEX_PATH = str(Path(\".\u002F\").resolve() \u002F \"demo.leann\")\n\n# Build an index\nbuilder = LeannBuilder(backend_name=\"hnsw\")\nbuilder.add_text(\"LEANN saves 97% storage compared to traditional vector databases.\")\nbuilder.add_text(\"Tung Tung Tung Sahur called—they need their banana‑crocodile hybrid back\")\nbuilder.build_index(INDEX_PATH)\n\n# Search\nsearcher = LeannSearcher(INDEX_PATH)\nresults = searcher.search(\"fantastical AI-generated creatures\", top_k=1)\n\n# Chat with your data\nchat = LeannChat(INDEX_PATH, llm_config={\"type\": \"hf\", \"model\": \"Qwen\u002FQwen3-0.6B\"})\nresponse = chat.ask(\"How much storage does LEANN save?\", top_k=1)\n```\n\n## RAG on Everything!\n\nLEANN supports RAG on various data sources including documents (`.pdf`, `.txt`, `.md`), Apple Mail, Google Search History, WeChat, ChatGPT conversations, Claude conversations, iMessage conversations, and **live data from any platform through MCP (Model Context Protocol) servers** - including Slack, Twitter, and more.\n\n\n\n### Generation Model Setup\n\n#### LLM Backend\n\nLEANN supports many LLM providers for text generation (HuggingFace, Ollama, Anthropic, and Any OpenAI compatible API).\n\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>🔑 OpenAI API Setup (Default)\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nSet your OpenAI API key as an environment variable:\n\n```bash\nexport OPENAI_API_KEY=\"your-api-key-here\"\n```\n\nMake sure to use `--llm openai` flag when using the CLI.\nYou can also specify the model name with `--llm-model \u003Cmodel-name>` flag.\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>🛠️ Supported LLM & Embedding Providers (via OpenAI Compatibility)\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nThanks to the widespread adoption of the OpenAI API format, LEANN is compatible out-of-the-box with a vast array of LLM and embedding providers. Simply set the `OPENAI_BASE_URL` and `OPENAI_API_KEY` environment variables to connect to your preferred service.\n\n```sh\nexport OPENAI_API_KEY=\"xxx\"\nexport OPENAI_BASE_URL=\"http:\u002F\u002Flocalhost:1234\u002Fv1\" # base url of the provider\n```\n\nTo use OpenAI compatible endpoint with the CLI interface:\n\nIf you are using it for text generation, make sure to use `--llm openai` flag and specify the model name with `--llm-model \u003Cmodel-name>` flag.\n\nIf you are using it for embedding, set the `--embedding-mode openai` flag and specify the model name with `--embedding-model \u003CMODEL>`.\n\n-----\n\n\nBelow is a list of base URLs for common providers to get you started.\n\n\n### 🖥️ Local Inference Engines (Recommended for full privacy)\n\n| Provider         | Sample Base URL             |\n| ---------------- | --------------------------- |\n| **Ollama** | `http:\u002F\u002Flocalhost:11434\u002Fv1` |\n| **LM Studio** | `http:\u002F\u002Flocalhost:1234\u002Fv1`  |\n| **vLLM** | `http:\u002F\u002Flocalhost:8000\u002Fv1`  |\n| **llama.cpp** | `http:\u002F\u002Flocalhost:8080\u002Fv1`  |\n| **SGLang** | `http:\u002F\u002Flocalhost:30000\u002Fv1` |\n| **LiteLLM** | `http:\u002F\u002Flocalhost:4000`     |\n\n-----\n\n### ☁️ Cloud Providers\n\n> **🚨 A Note on Privacy:** Before choosing a cloud provider, carefully review their privacy and data retention policies. Depending on their terms, your data may be used for their own purposes, including but not limited to human reviews and model training, which can lead to serious consequences if not handled properly.\n\n\n| Provider         | Base URL                                                   |\n| ---------------- | ---------------------------------------------------------- |\n| **OpenAI** | `https:\u002F\u002Fapi.openai.com\u002Fv1`                                |\n| **OpenRouter** | `https:\u002F\u002Fopenrouter.ai\u002Fapi\u002Fv1`                             |\n| **Gemini** | `https:\u002F\u002Fgenerativelanguage.googleapis.com\u002Fv1beta\u002Fopenai\u002F` |\n| **x.AI (Grok)** | `https:\u002F\u002Fapi.x.ai\u002Fv1`                                      |\n| **Groq AI** | `https:\u002F\u002Fapi.groq.com\u002Fopenai\u002Fv1`                           |\n| **DeepSeek** | `https:\u002F\u002Fapi.deepseek.com\u002Fv1`                              |\n| **SiliconFlow** | `https:\u002F\u002Fapi.siliconflow.cn\u002Fv1`                            |\n| **Zhipu (BigModel)** | `https:\u002F\u002Fopen.bigmodel.cn\u002Fapi\u002Fpaas\u002Fv4\u002F`                |\n| **Mistral AI** | `https:\u002F\u002Fapi.mistral.ai\u002Fv1`                                |\n| **Anthropic** | `https:\u002F\u002Fapi.anthropic.com\u002Fv1`                             |\n| **Jina AI** (Embeddings) | `https:\u002F\u002Fapi.jina.ai\u002Fv1`                         |\n\n> **💡 Tip: Separate Embedding Provider**\n>\n> To use a different provider for embeddings (e.g., Jina AI) while using another for LLM, use `--embedding-api-base` and `--embedding-api-key`:\n> ```bash\n> leann build my-index --docs .\u002Fdocs \\\n>   --embedding-mode openai \\\n>   --embedding-model jina-embeddings-v3 \\\n>   --embedding-api-base https:\u002F\u002Fapi.jina.ai\u002Fv1 \\\n>   --embedding-api-key $JINA_API_KEY\n> ```\n\nIf your provider isn't on this list, don't worry! Check their documentation for an OpenAI-compatible endpoint—chances are, it's OpenAI Compatible too!\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>🔧 Ollama Setup (Recommended for full privacy)\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n**macOS:**\n\nFirst, [download Ollama for macOS](https:\u002F\u002Follama.com\u002Fdownload\u002Fmac).\n\n```bash\n# Pull a lightweight model (recommended for consumer hardware)\nollama pull llama3.2:1b\n```\n\n**Linux:**\n\n```bash\n# Install Ollama\ncurl -fsSL https:\u002F\u002Follama.ai\u002Finstall.sh | sh\n\n# Start Ollama service manually\nollama serve &\n\n# Pull a lightweight model (recommended for consumer hardware)\nollama pull llama3.2:1b\n```\n\n\u003C\u002Fdetails>\n\n\n## ⭐ Flexible Configuration\n\nLEANN provides flexible parameters for embedding models, search strategies, and data processing to fit your specific needs.\n\n📚 **Need configuration best practices?** Check our [Configuration Guide](docs\u002Fconfiguration-guide.md) for detailed optimization tips, model selection advice, and solutions to common issues like slow embeddings or poor search quality.\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: Common Parameters (Available in All Examples)\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nAll RAG examples share these common parameters. **Interactive mode** is available in all examples - simply run without `--query` to start a continuous Q&A session where you can ask multiple questions. Type 'quit' to exit.\n\n```bash\n# Environment Variables (GPU Device Selection)\nLEANN_EMBEDDING_DEVICE       # GPU for embedding model (e.g., cuda:0, cuda:1, cpu)\nLEANN_LLM_DEVICE             # GPU for HFChat LLM (e.g., cuda:1, or \"cuda\" for multi-GPU auto)\n\n# Core Parameters (General preprocessing for all examples)\n--index-dir DIR              # Directory to store the index (default: current directory)\n--query \"YOUR QUESTION\"      # Single query mode. Omit for interactive chat (type 'quit' to exit), and now you can play with your index interactively\n--max-items N                # Limit data preprocessing (default: -1, process all data)\n--force-rebuild              # Force rebuild index even if it exists\n\n# Embedding Parameters\n--embedding-model MODEL      # e.g., facebook\u002Fcontriever, text-embedding-3-small, mlx-community\u002FQwen3-Embedding-0.6B-8bit or nomic-embed-text\n--embedding-mode MODE        # sentence-transformers, openai, mlx, or ollama\n\n# LLM Parameters (Text generation models)\n--llm TYPE                   # LLM backend: openai, ollama, hf, or anthropic (default: openai)\n--llm-model MODEL            # Model name (default: gpt-4o) e.g., gpt-4o-mini, llama3.2:1b, Qwen\u002FQwen2.5-1.5B-Instruct\n--thinking-budget LEVEL      # Thinking budget for reasoning models: low\u002Fmedium\u002Fhigh (supported by o3, o3-mini, GPT-Oss:20b, and other reasoning models)\n\n# Search Parameters\n--top-k N                    # Number of results to retrieve (default: 20)\n--search-complexity N        # Search complexity for graph traversal (default: 32)\n\n# Chunking Parameters\n--chunk-size N               # Size of text chunks (default varies by source: 256 for most, 192 for WeChat)\n--chunk-overlap N            # Overlap between chunks (default varies: 25-128 depending on source)\n\n# Index Building Parameters\n--backend-name NAME          # Backend to use: hnsw or diskann (default: hnsw)\n--graph-degree N             # Graph degree for index construction (default: 32)\n--build-complexity N         # Build complexity for index construction (default: 64)\n--compact \u002F --no-compact     # Use compact storage (default: true). Must be `no-compact` for `no-recompute` build.\n--recompute \u002F --no-recompute # Enable\u002Fdisable embedding recomputation (default: enabled). Should not do a `no-recompute` search in a `recompute` build.\n```\n\n\u003C\u002Fdetails>\n\n### 📄 Personal Data Manager: Process Any Documents (`.pdf`, `.txt`, `.md`)!\n\nAsk questions directly about your personal PDFs, documents, and any directory containing your files!\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_9dfa481133de.gif\" alt=\"LEANN Document Search Demo\" width=\"600\">\n\u003C\u002Fp>\n\nThe example below asks a question about summarizing our paper (uses default data in `data\u002F`, which is a directory with diverse data sources: two papers, Pride and Prejudice, and a Technical report about LLM in Huawei in Chinese), and this is the **easiest example** to run here:\n\n```bash\nsource .venv\u002Fbin\u002Factivate # Don't forget to activate the virtual environment\npython -m apps.document_rag --query \"What are the main techniques LEANN explores?\"\n```\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: Document-Specific Arguments\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### Parameters\n```bash\n--data-dir DIR           # Directory containing documents to process (default: data)\n--file-types .ext .ext   # Filter by specific file types (optional - all LlamaIndex supported types if omitted)\n```\n\n#### Example Commands\n```bash\n# Process all documents with larger chunks for academic papers\npython -m apps.document_rag --data-dir \"~\u002FDocuments\u002FPapers\" --chunk-size 1024\n\n# Filter only markdown and Python files with smaller chunks\npython -m apps.document_rag --data-dir \".\u002Fdocs\" --chunk-size 256 --file-types .md .py\n\n# Enable AST-aware chunking for code files\npython -m apps.document_rag --enable-code-chunking --data-dir \".\u002Fmy_project\"\n\n# Or use the specialized code RAG for better code understanding\npython -m apps.code_rag --repo-dir \".\u002Fmy_codebase\" --query \"How does authentication work?\"\n```\n\n\u003C\u002Fdetails>\n\n### 🎨 ColQwen: Multimodal PDF Retrieval with Vision-Language Models\n\nSearch through PDFs using both text and visual understanding with ColQwen2\u002FColPali models. Perfect for research papers, technical documents, and any PDFs with complex layouts, figures, or diagrams.\n\n> **🍎 Mac Users**: ColQwen is optimized for Apple Silicon with MPS acceleration for faster inference!\n\n```bash\n# Build index from PDFs\npython -m apps.colqwen_rag build --pdfs .\u002Fmy_papers\u002F --index research_papers\n\n# Search with text queries\npython -m apps.colqwen_rag search research_papers \"How does attention mechanism work?\"\n\n# Interactive Q&A\npython -m apps.colqwen_rag ask research_papers --interactive\n```\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: ColQwen Setup & Usage\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### Prerequisites\n```bash\n# Install dependencies\nuv pip install colpali_engine pdf2image pillow matplotlib qwen_vl_utils einops seaborn\nbrew install poppler  # macOS only, for PDF processing\n```\n\n#### Build Index\n```bash\npython -m apps.colqwen_rag build \\\n  --pdfs .\u002Fpdf_directory\u002F \\\n  --index my_index \\\n  --model colqwen2  # or colpali\n```\n\n#### Search\n```bash\npython -m apps.colqwen_rag search my_index \"your question here\" --top-k 5\n```\n\n#### Models\n- **ColQwen2** (`colqwen2`): Latest vision-language model with improved performance\n- **ColPali** (`colpali`): Proven multimodal retriever\n\nFor detailed usage, see the [ColQwen Guide](docs\u002FCOLQWEN_GUIDE.md).\n\n\u003C\u002Fdetails>\n\n### 📧 Your Personal Email Secretary: RAG on Apple Mail!\n\n> **Note:** The examples below currently support macOS only. Windows support coming soon.\n\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_179b5f3e4ec2.gif\" alt=\"LEANN Email Search Demo\" width=\"600\">\n\u003C\u002Fp>\n\nBefore running the example below, you need to grant full disk access to your terminal\u002FVS Code in System Preferences → Privacy & Security → Full Disk Access.\n\n```bash\npython -m apps.email_rag --query \"What's the food I ordered by DoorDash or Uber Eats mostly?\"\n```\n**780K email chunks → 78MB storage.** Finally, search your email like you search Google.\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: Email-Specific Arguments\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### Parameters\n```bash\n--mail-path PATH         # Path to specific mail directory (auto-detects if omitted)\n--include-html          # Include HTML content in processing (useful for newsletters)\n```\n\n#### Example Commands\n```bash\n# Search work emails from a specific account\npython -m apps.email_rag --mail-path \"~\u002FLibrary\u002FMail\u002FV10\u002FWORK_ACCOUNT\"\n\n# Find all receipts and order confirmations (includes HTML)\npython -m apps.email_rag --query \"receipt order confirmation invoice\" --include-html\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: Example queries you can try\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nOnce the index is built, you can ask questions like:\n- \"Find emails from my boss about deadlines\"\n- \"What did John say about the project timeline?\"\n- \"Show me emails about travel expenses\"\n\u003C\u002Fdetails>\n\n### 🔍 Time Machine for the Web: RAG Your Entire Chrome Browser History!\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_7d911b7eae0a.gif\" alt=\"LEANN Browser History Search Demo\" width=\"600\">\n\u003C\u002Fp>\n\n```bash\npython -m apps.browser_rag --query \"Tell me my browser history about machine learning?\"\n```\n**38K browser entries → 6MB storage.** Your browser history becomes your personal search engine.\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: Browser-Specific Arguments\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### Parameters\n```bash\n--chrome-profile PATH    # Path to Chrome profile directory (auto-detects if omitted)\n```\n\n#### Example Commands\n```bash\n# Search academic research from your browsing history\npython -m apps.browser_rag --query \"arxiv papers machine learning transformer architecture\"\n\n# Track competitor analysis across work profile\npython -m apps.browser_rag --chrome-profile \"~\u002FLibrary\u002FApplication Support\u002FGoogle\u002FChrome\u002FWork Profile\" --max-items 5000\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: How to find your Chrome profile\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nThe default Chrome profile path is configured for a typical macOS setup. If you need to find your specific Chrome profile:\n\n1. Open Terminal\n2. Run: `ls ~\u002FLibrary\u002FApplication\\ Support\u002FGoogle\u002FChrome\u002F`\n3. Look for folders like \"Default\", \"Profile 1\", \"Profile 2\", etc.\n4. Use the full path as your `--chrome-profile` argument\n\n**Common Chrome profile locations:**\n- macOS: `~\u002FLibrary\u002FApplication Support\u002FGoogle\u002FChrome\u002FDefault`\n- Linux: `~\u002F.config\u002Fgoogle-chrome\u002FDefault`\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>💬 Click to expand: Example queries you can try\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nOnce the index is built, you can ask questions like:\n\n- \"What websites did I visit about machine learning?\"\n- \"Find my search history about programming\"\n- \"What YouTube videos did I watch recently?\"\n- \"Show me websites I visited about travel planning\"\n\n\u003C\u002Fdetails>\n\n### 💬 WeChat Detective: Unlock Your Golden Memories!\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_0d2ddb2515cf.gif\" alt=\"LEANN WeChat Search Demo\" width=\"600\">\n\u003C\u002Fp>\n\n```bash\npython -m apps.wechat_rag --query \"Show me all group chats about weekend plans\"\n```\n**400K messages → 64MB storage** Search years of chat history in any language.\n\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>🔧 Click to expand: Installation Requirements\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nFirst, you need to install the [WeChat exporter](https:\u002F\u002Fgithub.com\u002Fsunnyyoung\u002FWeChatTweak-CLI),\n\n```bash\nbrew install sunnyyoung\u002Frepo\u002Fwechattweak-cli\n```\n\nor install it manually (if you have issues with Homebrew):\n\n```bash\nsudo packages\u002Fwechat-exporter\u002Fwechattweak-cli install\n```\n\n**Troubleshooting:**\n- **Installation issues**: Check the [WeChatTweak-CLI issues page](https:\u002F\u002Fgithub.com\u002Fsunnyyoung\u002FWeChatTweak-CLI\u002Fissues\u002F41)\n- **Export errors**: If you encounter the error below, try restarting WeChat\n  ```bash\n  Failed to export WeChat data. Please ensure WeChat is running and WeChatTweak is installed.\n  Failed to find or export WeChat data. Exiting.\n  ```\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: WeChat-Specific Arguments\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### Parameters\n```bash\n--export-dir DIR         # Directory to store exported WeChat data (default: wechat_export_direct)\n--force-export          # Force re-export even if data exists\n```\n\n#### Example Commands\n```bash\n# Search for travel plans discussed in group chats\npython -m apps.wechat_rag --query \"travel plans\" --max-items 10000\n\n# Re-export and search recent chats (useful after new messages)\npython -m apps.wechat_rag --force-export --query \"work schedule\"\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>💬 Click to expand: Example queries you can try\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nOnce the index is built, you can ask questions like:\n\n- \"我想买魔术师约翰逊的球衣，给我一些对应聊天记录?\" (Chinese: Show me chat records about buying Magic Johnson's jersey)\n\n\u003C\u002Fdetails>\n\n### 🤖 ChatGPT Chat History: Your Personal AI Conversation Archive!\n\nTransform your ChatGPT conversations into a searchable knowledge base! Search through all your ChatGPT discussions about coding, research, brainstorming, and more.\n\n```bash\npython -m apps.chatgpt_rag --export-path chatgpt_export.html --query \"How do I create a list in Python?\"\n```\n\n**Unlock your AI conversation history.** Never lose track of valuable insights from your ChatGPT discussions again.\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: How to Export ChatGPT Data\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n**Step-by-step export process:**\n\n1. **Sign in to ChatGPT**\n2. **Click your profile icon** in the top right corner\n3. **Navigate to Settings** → **Data Controls**\n4. **Click \"Export\"** under Export Data\n5. **Confirm the export** request\n6. **Download the ZIP file** from the email link (expires in 24 hours)\n7. **Extract or use directly** with LEANN\n\n**Supported formats:**\n- `.html` files from ChatGPT exports\n- `.zip` archives from ChatGPT\n- Directories with multiple export files\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: ChatGPT-Specific Arguments\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### Parameters\n```bash\n--export-path PATH           # Path to ChatGPT export file (.html\u002F.zip) or directory (default: .\u002Fchatgpt_export)\n--separate-messages         # Process each message separately instead of concatenated conversations\n--chunk-size N              # Text chunk size (default: 512)\n--chunk-overlap N           # Overlap between chunks (default: 128)\n```\n\n#### Example Commands\n```bash\n# Basic usage with HTML export\npython -m apps.chatgpt_rag --export-path conversations.html\n\n# Process ZIP archive from ChatGPT\npython -m apps.chatgpt_rag --export-path chatgpt_export.zip\n\n# Search with specific query\npython -m apps.chatgpt_rag --export-path chatgpt_data.html --query \"Python programming help\"\n\n# Process individual messages for fine-grained search\npython -m apps.chatgpt_rag --separate-messages --export-path chatgpt_export.html\n\n# Process directory containing multiple exports\npython -m apps.chatgpt_rag --export-path .\u002Fchatgpt_exports\u002F --max-items 1000\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>💡 Click to expand: Example queries you can try\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nOnce your ChatGPT conversations are indexed, you can search with queries like:\n- \"What did I ask ChatGPT about Python programming?\"\n- \"Show me conversations about machine learning algorithms\"\n- \"Find discussions about web development frameworks\"\n- \"What coding advice did ChatGPT give me?\"\n- \"Search for conversations about debugging techniques\"\n- \"Find ChatGPT's recommendations for learning resources\"\n\n\u003C\u002Fdetails>\n\n### 🤖 Claude Chat History: Your Personal AI Conversation Archive!\n\nTransform your Claude conversations into a searchable knowledge base! Search through all your Claude discussions about coding, research, brainstorming, and more.\n\n```bash\npython -m apps.claude_rag --export-path claude_export.json --query \"What did I ask about Python dictionaries?\"\n```\n\n**Unlock your AI conversation history.** Never lose track of valuable insights from your Claude discussions again.\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: How to Export Claude Data\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n**Step-by-step export process:**\n\n1. **Open Claude** in your browser\n2. **Navigate to Settings** (look for gear icon or settings menu)\n3. **Find Export\u002FDownload** options in your account settings\n4. **Download conversation data** (usually in JSON format)\n5. **Place the file** in your project directory\n\n*Note: Claude export methods may vary depending on the interface you're using. Check Claude's help documentation for the most current export instructions.*\n\n**Supported formats:**\n- `.json` files (recommended)\n- `.zip` archives containing JSON data\n- Directories with multiple export files\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: Claude-Specific Arguments\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### Parameters\n```bash\n--export-path PATH           # Path to Claude export file (.json\u002F.zip) or directory (default: .\u002Fclaude_export)\n--separate-messages         # Process each message separately instead of concatenated conversations\n--chunk-size N              # Text chunk size (default: 512)\n--chunk-overlap N           # Overlap between chunks (default: 128)\n```\n\n#### Example Commands\n```bash\n# Basic usage with JSON export\npython -m apps.claude_rag --export-path my_claude_conversations.json\n\n# Process ZIP archive from Claude\npython -m apps.claude_rag --export-path claude_export.zip\n\n# Search with specific query\npython -m apps.claude_rag --export-path claude_data.json --query \"machine learning advice\"\n\n# Process individual messages for fine-grained search\npython -m apps.claude_rag --separate-messages --export-path claude_export.json\n\n# Process directory containing multiple exports\npython -m apps.claude_rag --export-path .\u002Fclaude_exports\u002F --max-items 1000\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>💡 Click to expand: Example queries you can try\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nOnce your Claude conversations are indexed, you can search with queries like:\n- \"What did I ask Claude about Python programming?\"\n- \"Show me conversations about machine learning algorithms\"\n- \"Find discussions about software architecture patterns\"\n- \"What debugging advice did Claude give me?\"\n- \"Search for conversations about data structures\"\n- \"Find Claude's recommendations for learning resources\"\n\n\u003C\u002Fdetails>\n\n### 💬 iMessage History: Your Personal Conversation Archive!\n\nTransform your iMessage conversations into a searchable knowledge base! Search through all your text messages, group chats, and conversations with friends, family, and colleagues.\n\n```bash\npython -m apps.imessage_rag --query \"What did we discuss about the weekend plans?\"\n```\n\n**Unlock your message history.** Never lose track of important conversations, shared links, or memorable moments from your iMessage history.\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: How to Access iMessage Data\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n**iMessage data location:**\n\niMessage conversations are stored in a SQLite database on your Mac at:\n```\n~\u002FLibrary\u002FMessages\u002Fchat.db\n```\n\n**Important setup requirements:**\n\n1. **Grant Full Disk Access** to your terminal or IDE:\n   - Open **System Preferences** → **Security & Privacy** → **Privacy**\n   - Select **Full Disk Access** from the left sidebar\n   - Click the **+** button and add your terminal app (Terminal, iTerm2) or IDE (VS Code, etc.)\n   - Restart your terminal\u002FIDE after granting access\n\n2. **Alternative: Use a backup database**\n   - If you have Time Machine backups or manual copies of the database\n   - Use `--db-path` to specify a custom location\n\n**Supported formats:**\n- Direct access to `~\u002FLibrary\u002FMessages\u002Fchat.db` (default)\n- Custom database path with `--db-path`\n- Works with backup copies of the database\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: iMessage-Specific Arguments\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### Parameters\n```bash\n--db-path PATH                    # Path to chat.db file (default: ~\u002FLibrary\u002FMessages\u002Fchat.db)\n--concatenate-conversations       # Group messages by conversation (default: True)\n--no-concatenate-conversations    # Process each message individually\n--chunk-size N                    # Text chunk size (default: 1000)\n--chunk-overlap N                 # Overlap between chunks (default: 200)\n```\n\n#### Example Commands\n```bash\n# Basic usage (requires Full Disk Access)\npython -m apps.imessage_rag\n\n# Search with specific query\npython -m apps.imessage_rag --query \"family dinner plans\"\n\n# Use custom database path\npython -m apps.imessage_rag --db-path \u002Fpath\u002Fto\u002Fbackup\u002Fchat.db\n\n# Process individual messages instead of conversations\npython -m apps.imessage_rag --no-concatenate-conversations\n\n# Limit processing for testing\npython -m apps.imessage_rag --max-items 100 --query \"weekend\"\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>💡 Click to expand: Example queries you can try\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nOnce your iMessage conversations are indexed, you can search with queries like:\n- \"What did we discuss about vacation plans?\"\n- \"Find messages about restaurant recommendations\"\n- \"Show me conversations with John about the project\"\n- \"Search for shared links about technology\"\n- \"Find group chat discussions about weekend events\"\n- \"What did mom say about the family gathering?\"\n\n\u003C\u002Fdetails>\n\n### MCP Integration: RAG on Live Data from Any Platform\n\nConnect to live data sources through the Model Context Protocol (MCP). LEANN now supports real-time RAG on platforms like Slack, Twitter, and more through standardized MCP servers.\n\n**Key Benefits:**\n- **Live Data Access**: Fetch real-time data without manual exports\n- **Standardized Protocol**: Use any MCP-compatible server\n- **Easy Extension**: Add new platforms with minimal code\n- **Secure Access**: MCP servers handle authentication\n\n#### 💬 Slack Messages: Search Your Team Conversations\n\nTransform your Slack workspace into a searchable knowledge base! Find discussions, decisions, and shared knowledge across all your channels.\n\n```bash\n# Test MCP server connection\npython -m apps.slack_rag --mcp-server \"slack-mcp-server\" --test-connection\n\n# Index and search Slack messages\npython -m apps.slack_rag \\\n  --mcp-server \"slack-mcp-server\" \\\n  --workspace-name \"my-team\" \\\n  --channels general dev-team random \\\n  --query \"What did we decide about the product launch?\"\n```\n\n**📖 Comprehensive Setup Guide**: For detailed setup instructions, troubleshooting common issues (like \"users cache is not ready yet\"), and advanced configuration options, see our [**Slack Setup Guide**](docs\u002Fslack-setup-guide.md).\n\n**Quick Setup:**\n1. Install a Slack MCP server (e.g., `npm install -g slack-mcp-server`)\n2. Create a Slack App and get API credentials (see detailed guide above)\n3. Set environment variables:\n   ```bash\n   export SLACK_BOT_TOKEN=\"xoxb-your-bot-token\"\n   export SLACK_APP_TOKEN=\"xapp-your-app-token\"  # Optional\n   ```\n4. Test connection with `--test-connection` flag\n\n**Arguments:**\n- `--mcp-server`: Command to start the Slack MCP server\n- `--workspace-name`: Slack workspace name for organization\n- `--channels`: Specific channels to index (optional)\n- `--concatenate-conversations`: Group messages by channel (default: true)\n- `--max-messages-per-channel`: Limit messages per channel (default: 100)\n- `--max-retries`: Maximum retries for cache sync issues (default: 5)\n- `--retry-delay`: Initial delay between retries in seconds (default: 2.0)\n\n#### 🐦 Twitter Bookmarks: Your Personal Tweet Library\n\nSearch through your Twitter bookmarks! Find that perfect article, thread, or insight you saved for later.\n\n```bash\n# Test MCP server connection\npython -m apps.twitter_rag --mcp-server \"twitter-mcp-server\" --test-connection\n\n# Index and search Twitter bookmarks\npython -m apps.twitter_rag \\\n  --mcp-server \"twitter-mcp-server\" \\\n  --max-bookmarks 1000 \\\n  --query \"What AI articles did I bookmark about machine learning?\"\n```\n\n**Setup Requirements:**\n1. Install a Twitter MCP server (e.g., `npm install -g twitter-mcp-server`)\n2. Get Twitter API credentials:\n   - Apply for a Twitter Developer Account at [developer.twitter.com](https:\u002F\u002Fdeveloper.twitter.com)\n   - Create a new app in the Twitter Developer Portal\n   - Generate API keys and access tokens with \"Read\" permissions\n   - For bookmarks access, you may need Twitter API v2 with appropriate scopes\n   ```bash\n   export TWITTER_API_KEY=\"your-api-key\"\n   export TWITTER_API_SECRET=\"your-api-secret\"\n   export TWITTER_ACCESS_TOKEN=\"your-access-token\"\n   export TWITTER_ACCESS_TOKEN_SECRET=\"your-access-token-secret\"\n   ```\n3. Test connection with `--test-connection` flag\n\n**Arguments:**\n- `--mcp-server`: Command to start the Twitter MCP server\n- `--username`: Filter bookmarks by username (optional)\n- `--max-bookmarks`: Maximum bookmarks to fetch (default: 1000)\n- `--no-tweet-content`: Exclude tweet content, only metadata\n- `--no-metadata`: Exclude engagement metadata\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>💡 Click to expand: Example queries you can try\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n**Slack Queries:**\n- \"What did the team discuss about the project deadline?\"\n- \"Find messages about the new feature launch\"\n- \"Show me conversations about budget planning\"\n- \"What decisions were made in the dev-team channel?\"\n\n**Twitter Queries:**\n- \"What AI articles did I bookmark last month?\"\n- \"Find tweets about machine learning techniques\"\n- \"Show me bookmarked threads about startup advice\"\n- \"What Python tutorials did I save?\"\n\n\u003C\u002Fdetails>\n\u003Csummary>\u003Cstrong>🔧 Using MCP with CLI Commands\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n**Want to use MCP data with regular LEANN CLI?** You can combine MCP apps with CLI commands:\n\n```bash\n# Step 1: Use MCP app to fetch and index data\npython -m apps.slack_rag --mcp-server \"slack-mcp-server\" --workspace-name \"my-team\"\n\n# Step 2: The data is now indexed and available via CLI\nleann search slack_messages \"project deadline\"\nleann ask slack_messages \"What decisions were made about the product launch?\"\n\n# Same for Twitter bookmarks\npython -m apps.twitter_rag --mcp-server \"twitter-mcp-server\"\nleann search twitter_bookmarks \"machine learning articles\"\n```\n\n**MCP vs Manual Export:**\n- **MCP**: Live data, automatic updates, requires server setup\n- **Manual Export**: One-time setup, works offline, requires manual data export\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>🔧 Adding New MCP Platforms\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nWant to add support for other platforms? LEANN's MCP integration is designed for easy extension:\n\n1. **Find or create an MCP server** for your platform\n2. **Create a reader class** following the pattern in `apps\u002Fslack_data\u002Fslack_mcp_reader.py`\n3. **Create a RAG application** following the pattern in `apps\u002Fslack_rag.py`\n4. **Test and contribute** back to the community!\n\n**Popular MCP servers to explore:**\n- GitHub repositories and issues\n- Discord messages\n- Notion pages\n- Google Drive documents\n- And many more in the MCP ecosystem!\n\n\u003C\u002Fdetails>\n\n### 🚀 Claude Code Integration: Transform Your Development Workflow!\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>AST‑Aware Code Chunking\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nLEANN features intelligent code chunking that preserves semantic boundaries (functions, classes, methods) for Python, Java, C#, and TypeScript, improving code understanding compared to text-based chunking.\n\n📖 Read the [AST Chunking Guide →](docs\u002Fast_chunking_guide.md)\n\n\u003C\u002Fdetails>\n\n**The future of code assistance is here.** Transform your development workflow with LEANN's native MCP integration for Claude Code. Index your entire codebase and get intelligent code assistance directly in your IDE.\n\n**Key features:**\n- 🔍 **Semantic code search** across your entire project, fully local index and lightweight\n- 🧠 **AST-aware chunking** preserves code structure (functions, classes)\n- 📚 **Context-aware assistance** for debugging and development\n- 🚀 **Zero-config setup** with automatic language detection\n\n```bash\n# Install LEANN globally for MCP integration\nuv tool install leann-core --with leann\nclaude mcp add --scope user leann-server -- leann_mcp\n# Setup is automatic - just start using Claude Code!\n```\nTry our fully agentic pipeline with auto query rewriting, semantic search planning, and more:\n\n![LEANN MCP Integration](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_bc9d89ebc3e9.png)\n\n**🔥 Ready to supercharge your coding?** [Complete Setup Guide →](packages\u002Fleann-mcp\u002FREADME.md)\n\n## Command Line Interface\n\nLEANN includes a powerful CLI for document processing and search. Perfect for quick document indexing and interactive chat.\n\n### Installation\n\nIf you followed the Quick Start, `leann` is already installed in your virtual environment:\n```bash\nsource .venv\u002Fbin\u002Factivate\nleann --help\n```\n\n**To make it globally available:**\n```bash\n# Install the LEANN CLI globally using uv tool\nuv tool install leann-core --with leann\n\n\n# Now you can use leann from anywhere without activating venv\nleann --help\n```\n\n> **Note**: Global installation is required for Claude Code integration. The `leann_mcp` server depends on the globally available `leann` command.\n\n\n\n### Usage Examples\n\n```bash\n# build from a specific directory, and my_docs is the index name(Here you can also build from multiple dict or multiple files)\nleann build my-docs --docs .\u002Fyour_documents\n\n# Search your documents\nleann search my-docs \"machine learning concepts\"\n\n# Interactive chat with your documents\nleann ask my-docs --interactive\n\n# Ask a single question (non-interactive)\nleann ask my-docs \"Where are prompts configured?\"\n\n# Detect file changes since last build\u002Fwatch checkpoint\nleann watch my-docs\n\n# List all your indexes\nleann list\n\n# Remove an index\nleann remove my-docs\n```\n\n**Key CLI features:**\n- Auto-detects document formats (PDF, TXT, MD, DOCX, PPTX + code files)\n- **🧠 AST-aware chunking** for Python, Java, C#, TypeScript files\n- Smart text chunking with overlap for all other content\n- **📂 File change detection** via Merkle tree snapshots (`leann watch`)\n- Multiple LLM providers (Ollama, OpenAI, HuggingFace)\n- Organized index storage in `.leann\u002Findexes\u002F` (project-local)\n- Support for advanced search parameters\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 Click to expand: Complete CLI Reference\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nYou can use `leann --help`, or `leann build --help`, `leann search --help`, `leann watch --help`, `leann ask --help`, `leann list --help`, `leann remove --help` to get the complete CLI reference.\n\n**Build Command:**\n```bash\nleann build INDEX_NAME --docs DIRECTORY|FILE [DIRECTORY|FILE ...] [OPTIONS]\n\nOptions:\n  --backend {hnsw,diskann}     Backend to use (default: hnsw)\n  --embedding-model MODEL      Embedding model (default: facebook\u002Fcontriever)\n  --graph-degree N             Graph degree (default: 32)\n  --complexity N               Build complexity (default: 64)\n  --force                      Force rebuild existing index\n  --compact \u002F --no-compact     Use compact storage (default: true). Must be `no-compact` for `no-recompute` build.\n  --recompute \u002F --no-recompute Enable recomputation (default: true)\n```\n\n**Search Command:**\n```bash\nleann search INDEX_NAME QUERY [OPTIONS]\n\nOptions:\n  --top-k N                     Number of results (default: 5)\n  --complexity N                Search complexity (default: 64)\n  --recompute \u002F --no-recompute  Enable\u002Fdisable embedding recomputation (default: enabled). Should not do a `no-recompute` search in a `recompute` build.\n  --pruning-strategy {global,local,proportional}\n```\n\n**Watch Command:**\n```bash\nleann watch INDEX_NAME\n\n# Compares the current file system state against the last checkpoint (Merkle tree snapshot)\n# and reports which files have been added, removed, or modified, along with their chunk IDs.\n#\n# - Automatically saves a new checkpoint after detecting changes\n# - Each subsequent run compares against the most recent checkpoint\n# - File change detection uses SHA-256 content hashing via a Merkle tree\n#\n# Example output:\n#   === Changes since last checkpoint ===\n#   modified (1):\n#     - \u002Fpath\u002Fto\u002Ffile.py\n#       chunks: 42, 43, 44\n```\n\n**Ask Command:**\n```bash\nleann ask INDEX_NAME [OPTIONS]\n\nOptions:\n  --llm {ollama,openai,hf,anthropic}    LLM provider (default: ollama)\n  --model MODEL                         Model name (default: qwen3:8b)\n  --interactive                         Interactive chat mode\n  --top-k N                             Retrieval count (default: 20)\n```\n\n**List Command:**\n```bash\nleann list\n\n# Lists all indexes across all projects with status indicators:\n# ✅ - Index is complete and ready to use\n# ❌ - Index is incomplete or corrupted\n# 📁 - CLI-created index (in .leann\u002Findexes\u002F)\n# 📄 - App-created index (*.leann.meta.json files)\n```\n\n**Remove Command:**\n```bash\nleann remove INDEX_NAME [OPTIONS]\n\nOptions:\n  --force, -f    Force removal without confirmation\n\n# Smart removal: automatically finds and safely removes indexes\n# - Shows all matching indexes across projects\n# - Requires confirmation for cross-project removal\n# - Interactive selection when multiple matches found\n# - Supports both CLI and app-created indexes\n```\n\n\u003C\u002Fdetails>\n\n## 🚀 Advanced Features\n\n### 🎯 Metadata Filtering\n\nLEANN supports a simple metadata filtering system to enable sophisticated use cases like document filtering by date\u002Ftype, code search by file extension, and content management based on custom criteria.\n\n```python\n# Add metadata during indexing\nbuilder.add_text(\n    \"def authenticate_user(token): ...\",\n    metadata={\"file_extension\": \".py\", \"lines_of_code\": 25}\n)\n\n# Search with filters\nresults = searcher.search(\n    query=\"authentication function\",\n    metadata_filters={\n        \"file_extension\": {\"==\": \".py\"},\n        \"lines_of_code\": {\"\u003C\": 100}\n    }\n)\n```\n\n**Supported operators**: `==`, `!=`, `\u003C`, `\u003C=`, `>`, `>=`, `in`, `not_in`, `contains`, `starts_with`, `ends_with`, `is_true`, `is_false`\n\n📖 **[Complete Metadata filtering guide →](docs\u002Fmetadata_filtering.md)**\n\n### 🔍 Grep Search\n\nFor exact text matching instead of semantic search, use the `use_grep` parameter:\n\n```python\n# Exact text search\nresults = searcher.search(\"banana‑crocodile\", use_grep=True, top_k=1)\n```\n\n**Use cases**: Finding specific code patterns, error messages, function names, or exact phrases where semantic similarity isn't needed.\n\n📖 **[Complete grep search guide →](docs\u002Fgrep_search.md)**\n\n## 🏗️ Architecture & How It Works\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_3f5d5b6e0f1d.png\" alt=\"LEANN Architecture\" width=\"800\">\n\u003C\u002Fp>\n\n**The magic:** Most vector DBs store every single embedding (expensive). LEANN stores a pruned graph structure (cheap) and recomputes embeddings only when needed (fast).\n\n**Core techniques:**\n- **Graph-based selective recomputation:** Only compute embeddings for nodes in the search path\n- **High-degree preserving pruning:** Keep important \"hub\" nodes while removing redundant connections\n- **Dynamic batching:** Efficiently batch embedding computations for GPU utilization\n- **Two-level search:** Smart graph traversal that prioritizes promising nodes\n\n**Backends:**\n- **HNSW** (default): Ideal for most datasets with maximum storage savings through full recomputation\n- **DiskANN**: Advanced option with superior search performance, using PQ-based graph traversal with real-time reranking for the best speed-accuracy trade-off\n\n## Benchmarks\n\n**[DiskANN vs HNSW Performance Comparison →](benchmarks\u002Fdiskann_vs_hnsw_speed_comparison.py)** - Compare search performance between both backends\n\n**[Simple Example: Compare LEANN vs FAISS →](benchmarks\u002Fcompare_faiss_vs_leann.py)** - See storage savings in action\n\n### 📊 Storage Comparison\n\n| System | DPR (2.1M) | Wiki (60M) | Chat (400K) | Email (780K) | Browser (38K) |\n|--------|-------------|------------|-------------|--------------|---------------|\n| Traditional vector database (e.g., FAISS) | 3.8 GB      | 201 GB     | 1.8 GB     | 2.4 GB      | 130 MB        |\n| LEANN  | 324 MB      | 6 GB       | 64 MB       | 79 MB       | 6.4 MB        |\n| Savings| 91%         | 97%        | 97%         | 97%         | 95%           |\n\n\n\n## Reproduce Our Results\n\n```bash\nuv run benchmarks\u002Frun_evaluation.py    # Will auto-download evaluation data and run benchmarks\nuv run benchmarks\u002Frun_evaluation.py benchmarks\u002Fdata\u002Findices\u002Frpj_wiki\u002Frpj_wiki --num-queries 2000    # After downloading data, you can run the benchmark with our biggest index\n```\n\nThe evaluation script downloads data automatically on first run. The last three results were tested with partial personal data, and you can reproduce them with your own data!\n## 🔬 Paper\n\nIf you find Leann useful, please cite:\n\n**[LEANN: A Low-Storage Vector Index](https:\u002F\u002Farxiv.org\u002Fabs\u002F2506.08276)**\n\n```bibtex\n@misc{wang2025leannlowstoragevectorindex,\n      title={LEANN: A Low-Storage Vector Index},\n      author={Yichuan Wang and Shu Liu and Zhifei Li and Yongji Wu and Ziming Mao and Yilong Zhao and Xiao Yan and Zhiying Xu and Yang Zhou and Ion Stoica and Sewon Min and Matei Zaharia and Joseph E. Gonzalez},\n      year={2025},\n      eprint={2506.08276},\n      archivePrefix={arXiv},\n      primaryClass={cs.DB},\n      url={https:\u002F\u002Farxiv.org\u002Fabs\u002F2506.08276},\n}\n```\n\n## ✨ [Detailed Features →](docs\u002Ffeatures.md)\n\n## 🤝 [CONTRIBUTING →](docs\u002FCONTRIBUTING.md)\n\n\n## ❓ [FAQ →](docs\u002Ffaq.md)\n\n\n## 📈 [Roadmap →](docs\u002Froadmap.md)\n\n## 📄 License\n\nMIT License - see [LICENSE](LICENSE) for details.\n\n## 🙏 Acknowledgments\n\nCore Contributors: [Yichuan Wang](https:\u002F\u002Fyichuan-w.github.io\u002F) & [Zhifei Li](https:\u002F\u002Fgithub.com\u002Fandylizf).\n\nActive Contributors: [Gabriel Dehan](https:\u002F\u002Fgithub.com\u002Fgabriel-dehan), [Aakash Suresh](https:\u002F\u002Fgithub.com\u002FASuresh0524)\n\n\nWe welcome more contributors! Feel free to open issues or submit PRs.\n\nThis work is done at [**Berkeley Sky Computing Lab**](https:\u002F\u002Fsky.cs.berkeley.edu\u002F).\n\n## Star History\n\n[![Star History Chart](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_d664a156587f.png)](https:\u002F\u002Fwww.star-history.com\u002F#yichuan-w\u002FLEANN&Date)\n\u003Cp align=\"center\">\n  \u003Cstrong>⭐ Star us on GitHub if Leann is useful for your research or applications!\u003C\u002Fstrong>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  Made with ❤️ by the Leann team\n\u003C\u002Fp>\n\n## 🤖 Explore LEANN with AI\n\nLEANN is indexed on [DeepWiki](https:\u002F\u002Fdeepwiki.com\u002Fyichuan-w\u002FLEANN), so you can ask questions to LLMs using Deep Research to explore the codebase and get help to add new features.\n","\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_73108177e111.png\" alt=\"LEANN Logo\" width=\"400\">\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Ftrendshift.io\u002Frepositories\u002F15049\" target=\"_blank\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_4cc089988f35.png\" alt=\"yichuan-w\u002FLEANN | Trendshift\" style=\"width: 250px; height: 55px;\" width=\"250\" height=\"55\"\u002F>\n  \u003C\u002Fa>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPython-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue.svg\" alt=\"Python Versions\">\n  \u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN\u002Factions\u002Fworkflows\u002Fbuild-and-publish.yml\u002Fbadge.svg\" alt=\"CI Status\">\n  \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPlatform-Ubuntu%20%26%20Arch%20%26%20WSL%20%7C%20macOS%20(ARM64%2FIntel)%20%7C%20Windows-lightgrey\" alt=\"Platform\">\n  \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-green.svg\" alt=\"MIT License\">\n  \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FMCP-Native%20Integration-blue\" alt=\"MCP Integration\">\n  \u003Ca href=\"https:\u002F\u002Fjoin.slack.com\u002Ft\u002Fleann-e2u9779\u002Fshared_invite\u002Fzt-3ol2ww9ic-Eg_kB8omwe6xmYVd0epr4Q\">\n    \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSlack-Join-4A154B?logo=slack&logoColor=white\" alt=\"Join Slack\">\n  \u003C\u002Fa>\n\n\u003C\u002Fp>\n\n\u003Cdiv align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fforms.gle\u002FrDbZf864gMNxhpTq8\">\n    \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F📣_Community_Survey-Help_Shape_v0.4-007ec6?style=for-the-badge&logo=google-forms&logoColor=white\" alt=\"Take Survey\">\n  \u003C\u002Fa>\n  \u003Cp>\n    我们不收集任何遥测数据。本次调查是您告诉我们下一步希望我们开发\u003Cb>GPU加速\u003C\u002Fb>或\u003Cb>更多集成\u003C\u002Fb>功能的唯一方式。\u003Cbr>\n    👉 \u003Ca href=\"https:\u002F\u002Fforms.gle\u002FrDbZf864gMNxhpTq8\">\u003Cb>点击此处投票（只需2分钟）\u003C\u002Fb>\u003C\u002Fa>\n  \u003C\u002Fp>\n\u003C\u002Fdiv>\n\n\u003Cdiv align=\"center\">\n  \u003Ch3>💬 加入我们的Slack社区！\u003C\u002Fh3>\n  \u003Cp>\n    我们非常期待您的加入，成为LEANN社区的一员！\u003Cbr>\n    👉 \u003Ca href=\"https:\u002F\u002Fjoin.slack.com\u002Ft\u002Fleann-e2u9779\u002Fshared_invite\u002Fzt-3ol2ww9ic-Eg_kB8omwe6xmYVd0epr4Q\">\u003Cb>加入LEANN Slack\u003C\u002Fb>\u003C\u002Fa>\u003Cbr>\n    如果邀请链接已过期或您遇到加入困难，请\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN\u002Fissues\">提交一个问题\u003C\u002Fa>,我们会帮助您加入！\n  \u003C\u002Fp>\n\u003C\u002Fdiv>\n\n\u003Ch2 align=\"center\" tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">\n    全球最小的向量索引。用LEANN实现RAG一切！\n\u003C\u002Fh2>\n\nLEANN是一款创新的向量数据库，旨在让个人AI更加普及。它能将您的笔记本电脑转变为强大的RAG系统，能够在使用**比传统方案少97%的存储空间**且**不损失准确性**的情况下，对数百万份文档进行索引和检索。\n\n\nLEANN通过基于图的**选择性重计算**与**高阶保持剪枝**技术来实现这一点，即按需计算嵌入向量，而不是预先存储所有向量。[示意图 →](#️-architecture--how-it-works) | [论文 →](https:\u002F\u002Farxiv.org\u002Fabs\u002F2506.08276)\n\n**准备好RAG一切了吗？** 将您的笔记本电脑变成一个个人AI助手，能够语义搜索您的**文件系统**（#-personal-data-manager-process-any-documents-pdf-txt-md）、**电子邮件**（#-your-personal-email-secretary-rag-on-apple-mail）、**浏览器历史记录**（#-time-machine-for-the-web-rag-your-entire-browser-history）、**聊天记录**（#-wechat-detective-unlock-your-golden-memories）（WeChat、iMessage）、**代理记忆**（#-chatgpt-chat-history-your-personal-ai-conversation-archive）（ChatGPT、Claude）、**实时数据**（#mcp-integration-rag-on-live-data-from-any-platform）（Slack、Twitter）、**代码库**（#-claude-code-integration-transform-your-development-workflow）*，或者外部知识库（例如6000万份文档）——所有这些都可以在您的笔记本电脑上完成，无需任何云成本，并且完全保护您的隐私。\n\n\n\\* Claude Code仅支持基本的`grep`风格关键词搜索。而**LEANN**则是一个可直接使用的**语义搜索MCP服务，与Claude Code完全兼容**，让您无需改变工作流程即可实现智能检索。🔥 请查看[简易设置 →](packages\u002Fleann-mcp\u002FREADME.md)\n\n\n\n## 为什么选择LEANN？\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_501c6b7cac1f.png\" alt=\"LEANN与传统向量数据库存储对比\" width=\"70%\">\n\u003C\u002Fp>\n\n> **数据说明一切：** 只需6GB即可索引6000万个文本片段，而传统方法则需要201GB。从电子邮件到浏览器历史记录，一切都能装进您的笔记本电脑中。[不同应用场景的详细基准测试见下方 ↓](#-storage-comparison)\n\n\n🔒 **隐私：** 您的数据永远不会离开您的笔记本电脑。没有OpenAI，没有云端，也没有“服务条款”。\n\n🪶 **轻量级：** 基于图的重计算机制消除了繁重的嵌入向量存储需求，同时通过智能图剪枝和CSR格式进一步降低了图存储的开销。始终占用更少的存储空间和内存！\n\n📦 **便携性：** 您可以以极低的成本将整个知识库在不同设备之间转移（甚至与他人共享）——您的个人AI记忆将随身携带。\n\n📈 **可扩展性：** 能够处理传统向量数据库容易崩溃的混乱个人数据，轻松管理您不断增长的个性化数据以及代理生成的记忆！\n\n✨ **无精度损失：** 在使用97%更少存储空间的同时，仍能保持与重型解决方案相同的搜索质量。\n\n## 安装\n\n### 📦 先决条件：安装uv\n\n如果您尚未安装uv，请先按照以下步骤安装：\n\n```bash\ncurl -LsSf https:\u002F\u002Fastral.sh\u002Fuv\u002Finstall.sh | sh\n```\n\n### 🚀 快速安装\n\n克隆仓库以获取所有示例并尝试各种精彩应用，\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN.git leann\ncd leann\n```\n\n然后从[PyPI](https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F)安装LEANN，即可立即运行：\n\n```bash\nuv venv\nsource .venv\u002Fbin\u002Factivate\nuv pip install leann\n\n# 仅限 CPU（Linux）：使用 `cpu` 附加组件（例如 `leann[cpu]`）\n```\n\n\u003C!--\n> 资源有限？请参阅[配置指南](docs\u002Fconfiguration-guide.md#low-resource-setups)中的“低资源设置”部分。 -->\n\n\u003Cdetails>\n\u003Csummary>\n\u003Cstrong>🔧 从源代码构建（开发推荐）\u003C\u002Fstrong>\n\u003C\u002Fsummary>\n\n\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN.git leann\ncd leann\ngit submodule update --init --recursive\n```\n\n**macOS：**\n\n注意：DiskANN 需要 macOS 13.3 或更高版本。\n\n```bash\nbrew install libomp boost protobuf zeromq pkgconf\nuv sync --extra diskann\n```\n\n**Linux（Ubuntu\u002FDebian）：**\n\n注意：在 Ubuntu 20.04 上，您可能需要编译更新的 Abseil 库，并锁定 Protobuf 版本（例如 v3.20.x），以便成功构建 DiskANN。有关逐步说明，请参阅 [Issue #30](https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN\u002Fissues\u002F30)。\n\n您可以手动安装 [Intel oneAPI MKL](https:\u002F\u002Fwww.intel.com\u002Fcontent\u002Fwww\u002Fus\u002Fen\u002Fdeveloper\u002Ftools\u002Foneapi\u002Fonemkl.html)，而不是使用 `libmkl-full-dev` 来为 DiskANN 提供支持。此外，如果您只想构建 HNSW 索引，可以通过在以下命令中移除 `--extra diskann` 参数来使用 `libopenblas-dev`。\n\n```bash\nsudo apt-get update && sudo apt-get install -y \\\n  libomp-dev libboost-all-dev protobuf-compiler libzmq3-dev \\\n  pkg-config libabsl-dev libaio-dev libprotobuf-dev \\\n  libmkl-full-dev\n\nuv sync --extra diskann\n```\n\n**Linux（Arch Linux）：**\n\n```bash\nsudo pacman -Syu && sudo pacman -S --needed base-devel cmake pkgconf git gcc \\\n  boost boost-libs protobuf abseil-cpp libaio zeromq\n\n# 用于 DiskANN 中的 MKL\nsudo pacman -S --needed base-devel git\ngit clone https:\u002F\u002Faur.archlinux.org\u002Fparu-bin.git\ncd paru-bin && makepkg -si\nparu -S intel-oneapi-mkl intel-oneapi-compiler\nsource \u002Fopt\u002Fintel\u002Foneapi\u002Fsetvars.sh\n\nuv sync --extra diskann\n```\n\n**Linux（RHEL \u002F CentOS Stream \u002F Oracle \u002F Rocky \u002F AlmaLinux）：**\n\n更多详细信息请参阅 [Issue #50](https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN\u002Fissues\u002F50)。\n\n```bash\nsudo dnf groupinstall -y \"Development Tools\"\nsudo dnf install -y libomp-devel boost-devel protobuf-compiler protobuf-devel \\\n  abseil-cpp-devel libaio-devel zeromq-devel pkgconf-pkg-config\n\n# 用于 DiskANN 中的 MKL\nsudo dnf install -y intel-oneapi-mkl intel-oneapi-mkl-devel \\\n  intel-oneapi-openmp 或者 sudo dnf install -y intel-oneapi-compiler\nsource \u002Fopt\u002Fintel\u002Foneapi\u002Fsetvars.sh\n\nuv sync --extra diskann\n```\n\n**Windows：**\n\n需要安装带有 **C++ 桌面开发** 工作负载的 [Visual Studio 2022 Build Tools](https:\u002F\u002Fvisualstudio.microsoft.com\u002Fdownloads\u002F#build-tools-for-visual-studio-2022)，以及 [vcpkg](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fvcpkg)。\n\n```powershell\n# 安装工具链（如果尚未安装）\nchoco install cmake swig pkgconfiglite nuget.commandline -y\n\n# 通过 vcpkg 安装 C++ 依赖项\nvcpkg install zeromq:x64-windows openblas:x64-windows lapack:x64-windows `\n  boost-program-options:x64-windows protobuf:x64-windows\n\n# 设置环境变量（将 VCPKG_ROOT 调整为您的 vcpkg 路径）\n$env:CMAKE_PREFIX_PATH = \"$env:VCPKG_ROOT\\installed\\x64-windows\"\n$env:PKG_CONFIG_PATH = \"$env:VCPKG_ROOT\\installed\\x64-windows\\lib\\pkgconfig\"\n$env:PKG_CONFIG_EXECUTABLE = \"C:\\ProgramData\\chocolatey\\bin\\pkg-config.exe\"\n$env:OPENBLAS_LIB = \"$env:VCPKG_ROOT\\installed\\x64-windows\\lib\\openblas.lib\"\n$env:PATH += \";$env:VCPKG_ROOT\\installed\\x64-windows\\bin\"\n$env:PATH += \";$env:VCPKG_ROOT\\installed\\x64-windows\\tools\\protobuf\"\n\nuv sync --extra diskann\n```\n\n\u003C\u002Fdetails>\n\n\n## 快速入门\n\n我们的声明式 API 让 RAG 变得像编写配置文件一样简单。\n\n请查看 [demo.ipynb](demo.ipynb) 或 [![在 Colab 中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fyichuan-w\u002FLEANN\u002Fblob\u002Fmain\u002Fdemo.ipynb)\n\n```python\nfrom leann import LeannBuilder, LeannSearcher, LeannChat\nfrom pathlib import Path\nINDEX_PATH = str(Path(\".\u002F\").resolve() \u002F \"demo.leann\")\n\n# 构建索引\nbuilder = LeannBuilder(backend_name=\"hnsw\")\nbuilder.add_text(\"LEANN 相比传统向量数据库节省了 97% 的存储空间。\")\nbuilder.add_text(\"咚咚咚，开斋饭叫他们——他们需要把香蕉鳄鱼杂交种还回来\")\nbuilder.build_index(INDEX_PATH)\n\n# 搜索\nsearcher = LeannSearcher(INDEX_PATH)\nresults = searcher.search(\"奇幻的 AI 生成生物\", top_k=1)\n\n# 与您的数据对话\nchat = LeannChat(INDEX_PATH, llm_config={\"type\": \"hf\", \"model\": \"Qwen\u002FQwen3-0.6B\"})\nresponse = chat.ask(\"LEANN 能节省多少存储空间？\", top_k=1)\n```\n\n## 对一切进行 RAG！\n\nLEANN 支持对多种数据源进行 RAG，包括文档（`.pdf`、`.txt`、`.md`）、Apple Mail、Google 搜索历史、WeChat、ChatGPT 对话、Claude 对话、iMessage 对话，以及 **通过 MCP（模型上下文协议）服务器从任何平台获取的实时数据**——包括 Slack、Twitter 等。\n\n\n\n### 生成模型设置\n\n#### LLM 后端\n\nLEANN 支持众多 LLM 提供商进行文本生成（HuggingFace、Ollama、Anthropic，以及任何兼容 OpenAI API 的服务）。\n\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>🔑 OpenAI API 设置（默认）\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n将您的 OpenAI API 密钥设置为环境变量：\n\n```bash\nexport OPENAI_API_KEY=\"your-api-key-here\"\n```\n\n使用 CLI 时，请务必使用 `--llm openai` 标志。您还可以使用 `--llm-model \u003Cmodel-name>` 标志指定模型名称。\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>🛠️ 支持的 LLM 和嵌入提供商（通过 OpenAI 兼容性）\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n得益于 OpenAI API 格式的广泛采用，LEANN 出厂即与大量 LLM 和嵌入提供商兼容。只需设置 `OPENAI_BASE_URL` 和 `OPENAI_API_KEY` 环境变量，即可连接到您首选的服务。\n\n```sh\nexport OPENAI_API_KEY=\"xxx\"\nexport OPENAI_BASE_URL=\"http:\u002F\u002Flocalhost:1234\u002Fv1\" # 提供商的基本 URL\n```\n\n若要在 CLI 界面中使用兼容 OpenAI 的端点：\n\n如果您用于文本生成，请确保使用 `--llm openai` 标志，并用 `--llm-model \u003Cmodel-name>` 标志指定模型名称。\n\n如果您用于嵌入，则应设置 `--embedding-mode openai` 标志，并用 `--embedding-model \u003CMODEL>` 标志指定模型名称。\n\n-----\n\n\n以下是常见提供商的基本 URL 列表，供您参考。\n\n\n### 🖥️ 本地推理引擎（建议用于完全隐私保护）\n\n| 提供商         | 示例基本 URL             |\n| ---------------- | --------------------------- |\n| **Ollama** | `http:\u002F\u002Flocalhost:11434\u002Fv1` |\n| **LM Studio** | `http:\u002F\u002Flocalhost:1234\u002Fv1`  |\n| **vLLM** | `http:\u002F\u002Flocalhost:8000\u002Fv1`  |\n| **llama.cpp** | `http:\u002F\u002Flocalhost:8080\u002Fv1`  |\n| **SGLang** | `http:\u002F\u002Flocalhost:30000\u002Fv1` |\n| **LiteLLM** | `http:\u002F\u002Flocalhost:4000`     |\n\n-----\n\n### ☁️ 云服务提供商\n\n> **🚨 隐私提示：** 在选择云服务提供商之前，请仔细阅读其隐私和数据保留政策。根据他们的条款，您的数据可能会被用于其自身目的，包括但不限于人工审核和模型训练，若处理不当，可能导致严重后果。\n\n\n| 服务提供商         | 基础 URL                                                   |\n| ---------------- | ---------------------------------------------------------- |\n| **OpenAI** | `https:\u002F\u002Fapi.openai.com\u002Fv1`                                |\n| **OpenRouter** | `https:\u002F\u002Fopenrouter.ai\u002Fapi\u002Fv1`                             |\n| **Gemini** | `https:\u002F\u002Fgenerativelanguage.googleapis.com\u002Fv1beta\u002Fopenai\u002F` |\n| **x.AI (Grok)** | `https:\u002F\u002Fapi.x.ai\u002Fv1`                                      |\n| **Groq AI** | `https:\u002F\u002Fapi.groq.com\u002Fopenai\u002Fv1`                           |\n| **DeepSeek** | `https:\u002F\u002Fapi.deepseek.com\u002Fv1`                              |\n| **SiliconFlow** | `https:\u002F\u002Fapi.siliconflow.cn\u002Fv1`                            |\n| **Zhipu (BigModel)** | `https:\u002F\u002Fopen.bigmodel.cn\u002Fapi\u002Fpaas\u002Fv4\u002F`                |\n| **Mistral AI** | `https:\u002F\u002Fapi.mistral.ai\u002Fv1`                                |\n| **Anthropic** | `https:\u002F\u002Fapi.anthropic.com\u002Fv1`                             |\n| **Jina AI**（嵌入） | `https:\u002F\u002Fapi.jina.ai\u002Fv1`                         |\n\n> **💡 小贴士：使用不同的嵌入服务提供商**\n>\n> 若要为嵌入使用不同的提供商（例如 Jina AI），同时为 LLM 使用另一家提供商，请使用 `--embedding-api-base` 和 `--embedding-api-key`：\n> ```bash\n> leann build my-index --docs .\u002Fdocs \\\n>   --embedding-mode openai \\\n>   --embedding-model jina-embeddings-v3 \\\n>   --embedding-api-base https:\u002F\u002Fapi.jina.ai\u002Fv1 \\\n>   --embedding-api-key $JINA_API_KEY\n> ```\n\n如果您的提供商未在此列表中，也不用担心！请查阅其文档以找到与 OpenAI 兼容的端点——很可能它也是 OpenAI 兼容的！\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>🔧 Ollama 设置（推荐用于完全隐私保护）\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n**macOS：**\n\n首先，[下载 Ollama for macOS](https:\u002F\u002Follama.com\u002Fdownload\u002Fmac)。\n\n```bash\n# 拉取一个轻量级模型（推荐用于消费级硬件）\nollama pull llama3.2:1b\n```\n\n**Linux：**\n\n```bash\n# 安装 Ollama\ncurl -fsSL https:\u002F\u002Follama.ai\u002Finstall.sh | sh\n\n# 手动启动 Ollama 服务\nollama serve &\n\n# 拉取一个轻量级模型（推荐用于消费级硬件）\nollama pull llama3.2:1b\n```\n\n\u003C\u002Fdetails>\n\n\n## ⭐ 灵活配置\n\nLEANN 提供了灵活的参数设置，涵盖嵌入模型、检索策略和数据处理等方面，以满足您的特定需求。\n\n📚 **需要配置最佳实践吗？** 请查看我们的[配置指南](docs\u002Fconfiguration-guide.md)，其中包含详细的优化技巧、模型选择建议以及解决常见问题的方法，例如嵌入速度慢或检索质量不佳等。\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：常用参数（所有示例均适用）\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n所有 RAG 示例都共享这些常用参数。**交互模式**在所有示例中均可使用——只需不带 `--query` 参数运行，即可开始连续问答会话，您可以在其中提出多个问题。输入 'quit' 即可退出。\n\n```bash\n# 环境变量（GPU 设备选择）\nLEANN_EMBEDDING_DEVICE       # 用于嵌入模型的 GPU（例如 cuda:0, cuda:1, cpu）\nLEANN_LLM_DEVICE             # 用于 HFChat LLM 的 GPU（例如 cuda:1，或 \"cuda\" 表示多 GPU 自动分配）\n\n# 核心参数（所有示例的通用预处理）\n--index-dir DIR              # 存储索引的目录（默认：当前目录）\n--query \"YOUR QUESTION\"      # 单次查询模式。省略则进入交互式聊天模式（输入 'quit' 可退出），此时您可以与索引进行交互式操作\n--max-items N                # 限制数据预处理的数量（默认：-1，即处理全部数据）\n--force-rebuild              # 强制重建索引，即使索引已存在\n\n# 嵌入参数\n--embedding-model MODEL      # 例如 facebook\u002Fcontriever, text-embedding-3-small, mlx-community\u002FQwen3-Embedding-0.6B-8bit 或 nomic-embed-text\n--embedding-mode MODE        # sentence-transformers, openai, mlx 或 ollama\n\n# LLM 参数（文本生成模型）\n--llm TYPE                   # LLM 后端：openai, ollama, hf 或 anthropic（默认：openai）\n--llm-model MODEL            # 模型名称（默认：gpt-4o），例如 gpt-4o-mini, llama3.2:1b, Qwen\u002FQwen2.5-1.5B-Instruct\n--thinking-budget LEVEL      # 思考预算，适用于推理模型：low\u002Fmedium\u002Fhigh（支持 o3, o3-mini, GPT-Oss:20b 等推理模型）\n\n# 检索参数\n--top-k N                    # 返回的结果数量（默认：20）\n--search-complexity N        # 图遍历的搜索复杂度（默认：32）\n\n# 分块参数\n--chunk-size N               # 文本分块的大小（默认因来源而异：大多数为 256，微信为 192）\n--chunk-overlap N            # 分块之间的重叠部分（默认因来源而异：25–128）\n\n# 索引构建参数\n--backend-name NAME          # 使用的后端：hnsw 或 diskann（默认：hnsw）\n--graph-degree N             # 构建索引时的图度数（默认：32）\n--build-complexity N         # 索引构建的复杂度（默认：64）\n--compact \u002F --no-compact     # 是否使用紧凑存储（默认：true）。若要进行“不重新计算”的构建，则必须设置为“no-compact”。\n--recompute \u002F --no-recompute # 是否启用嵌入重新计算（默认：启用）。不应在“重新计算”的构建中执行“不重新计算”的检索。\n```\n\n\u003C\u002Fdetails>\n\n### 📄 个人数据管理器：处理任意文档（`.pdf`、`.txt`、`.md`）！\n\n直接针对您的个人 PDF 文件、文档以及任何包含文件的目录提问吧！\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_9dfa481133de.gif\" alt=\"LEANN 文档搜索演示\" width=\"600\">\n\u003C\u002Fp>\n\n以下示例询问关于我们论文摘要的问题（使用 `data\u002F` 中的默认数据，该目录包含多种数据源：两篇论文、《傲慢与偏见》以及一篇关于华为 LLM 的中文技术报告），这是此处**最简单的示例**：\n\n```bash\nsource .venv\u002Fbin\u002Factivate # 别忘了激活虚拟环境\npython -m apps.document_rag --query \"LEANN 探索的主要技术有哪些？\"\n```\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：文档专用参数\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### 参数\n```bash\n--data-dir DIR           # 包含待处理文档的目录（默认：data）\n--file-types .ext .ext   # 按特定文件类型筛选（可选；若省略则处理所有 LlamaIndex 支持的类型）\n```\n\n#### 示例命令\n```bash\n# 处理所有文档，并为学术论文使用更大的分块\npython -m apps.document_rag --data-dir \"~\u002FDocuments\u002FPapers\" --chunk-size 1024\n\n# 仅筛选 Markdown 和 Python 文件，并使用较小的分块\npython -m apps.document_rag --data-dir \".\u002Fdocs\" --chunk-size 256 --file-types .md .py\n\n# 为代码文件启用 AST 感知分块\npython -m apps.document_rag --enable-code-chunking --data-dir \".\u002Fmy_project\"\n\n# 或者使用专门的代码 RAG 以更好地理解代码\npython -m apps.code_rag --repo-dir \".\u002Fmy_codebase\" --query \"认证是如何工作的？\"\n```\n\n\u003C\u002Fdetails>\n\n### 🎨 ColQwen：基于视觉-语言模型的多模态 PDF 检索\n\n使用 ColQwen2\u002FColPali 模型，结合文本和视觉理解能力，对 PDF 文件进行搜索。非常适合用于科研论文、技术文档以及包含复杂版面、图表或示意图的各类 PDF 文件。\n\n> **🍎 Mac 用户**：ColQwen 已针对 Apple Silicon 进行优化，并支持 MPS 加速，从而实现更快的推理速度！\n\n```bash\n# 从 PDF 文件构建索引\npython -m apps.colqwen_rag build --pdfs .\u002Fmy_papers\u002F --index research_papers\n\n# 使用文本查询进行搜索\npython -m apps.colqwen_rag search research_papers \"注意力机制是如何工作的？\"\n\n# 交互式问答\npython -m apps.colqwen_rag ask research_papers --interactive\n```\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：ColQwen 的安装与使用\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### 先决条件\n```bash\n# 安装依赖\nuv pip install colpali_engine pdf2image pillow matplotlib qwen_vl_utils einops seaborn\nbrew install poppler  # 仅限 macOS，用于 PDF 处理\n```\n\n#### 构建索引\n```bash\npython -m apps.colqwen_rag build \\\n  --pdfs .\u002Fpdf_directory\u002F \\\n  --index my_index \\\n  --model colqwen2  # 或 colpali\n```\n\n#### 搜索\n```bash\npython -m apps.colqwen_rag search my_index \"你的问题在这里\" --top-k 5\n```\n\n#### 模型\n- **ColQwen2** (`colqwen2`)：最新视觉-语言模型，性能更优\n- **ColPali** (`colpali`)：经过验证的多模态检索器\n\n有关详细用法，请参阅 [ColQwen 指南](docs\u002FCOLQWEN_GUIDE.md)。\n\n\u003C\u002Fdetails>\n\n### 📧 你的私人邮件秘书：基于 Apple Mail 的 RAG！\n\n> **注意**：以下示例目前仅支持 macOS。Windows 支持即将推出。\n\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_179b5f3e4ec2.gif\" alt=\"LEANN 邮件搜索演示\" width=\"600\">\n\u003C\u002Fp>\n\n在运行下面的示例之前，你需要在系统偏好设置 → 隐私与安全性 → 全盘访问中，授予终端\u002FVS Code 全盘访问权限。\n\n```bash\npython -m apps.email_rag --query \"我最常通过 DoorDash 或 Uber Eats 订购的食物是什么？\"\n```\n**78 万个邮件片段 → 78MB 存储空间。** 终于可以像在 Google 上搜索一样搜索你的电子邮件了。\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：邮件专用参数\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### 参数\n```bash\n--mail-path PATH         # 特定邮件目录的路径（省略时自动检测）\n--include-html          # 在处理中包含 HTML 内容（适用于新闻通讯）\n```\n\n#### 示例命令\n```bash\n# 搜索来自特定账户的工作邮件\npython -m apps.email_rag --mail-path \"~\u002FLibrary\u002FMail\u002FV10\u002FWORK_ACCOUNT\"\n\n# 查找所有收据和订单确认邮件（包含 HTML）\npython -m apps.email_rag --query \"收据 订单确认 发票\" --include-html\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：你可以尝试的示例查询\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n索引构建完成后，你可以提出如下问题：\n- “查找我老板关于截止日期的邮件”\n- “John 对项目时间表说了什么？”\n- “给我看看关于差旅费用的邮件”\n\u003C\u002Fdetails>\n\n### 🔍 网页时光机：将你的整个 Chrome 浏览器历史转化为 RAG！\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_7d911b7eae0a.gif\" alt=\"LEANN 浏览器历史搜索演示\" width=\"600\">\n\u003C\u002Fp>\n\n```bash\npython -m apps.browser_rag --query \"告诉我我的浏览器历史中关于机器学习的内容吧？\"\n```\n**3.8 万条浏览器记录 → 6MB 存储空间。** 你的浏览器历史将成为你个人的搜索引擎。\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：浏览器专用参数\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### 参数\n```bash\n--chrome-profile PATH    # Chrome 配置文件目录的路径（省略时自动检测）\n```\n\n#### 示例命令\n```bash\n# 搜索浏览历史中的学术研究\npython -m apps.browser_rag --query \"arxiv 论文 机器学习 变压器架构\"\n\n# 跟踪工作配置文件中的竞争对手分析\npython -m apps.browser_rag --chrome-profile \"~\u002FLibrary\u002FApplication Support\u002FGoogle\u002FChrome\u002FWork Profile\" --max-items 5000\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：如何找到你的 Chrome 配置文件\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n默认的 Chrome 配置文件路径是为典型的 macOS 设置配置的。如果你需要找到自己的特定 Chrome 配置文件：\n\n1. 打开终端\n2. 输入：`ls ~\u002FLibrary\u002FApplication\\ Support\u002FGoogle\u002FChrome\u002F`\n3. 查看类似“Default”、“Profile 1”、“Profile 2”等文件夹\n4. 将完整路径作为 `--chrome-profile` 参数使用\n\n**常见的 Chrome 配置文件位置：**\n- macOS：`~\u002FLibrary\u002FApplication Support\u002FGoogle\u002FChrome\u002FDefault`\n- Linux：`~\u002F.config\u002Fgoogle-chrome\u002FDefault`\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>💬 点击展开：你可以尝试的示例查询\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n索引构建完成后，你可以提出如下问题：\n\n- “我访问过哪些关于机器学习的网站？”\n- “查找我关于编程的搜索历史”\n- “我最近看了哪些 YouTube 视频？”\n- “给我看看我访问过的旅行规划相关网站”\n\u003C\u002Fdetails>\n\n### 💬 微信侦探：解锁你的珍贵回忆！\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_0d2ddb2515cf.gif\" alt=\"LEANN 微信搜索演示\" width=\"600\">\n\u003C\u002Fp>\n\n```bash\npython -m apps.wechat_rag --query \"给我看看所有关于周末计划的群聊\"\n```\n**40 万条消息 → 64MB 存储空间** 用任何语言搜索多年来的聊天记录。\n\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>🔧 点击展开：安装要求\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n首先，你需要安装 [WeChat 导出工具](https:\u002F\u002Fgithub.com\u002Fsunnyyoung\u002FWeChatTweak-CLI)，\n\n```bash\nbrew install sunnyyoung\u002Frepo\u002Fwechattweak-cli\n```\n\n或者手动安装（如果 Homebrew 出现问题）：\n\n```bash\nsudo packages\u002Fwechat-exporter\u002Fwechattweak-cli install\n```\n\n**故障排除：**\n- **安装问题**：请查看 [WeChatTweak-CLI 的问题页面](https:\u002F\u002Fgithub.com\u002Fsunnyyoung\u002FWeChatTweak-CLI\u002Fissues\u002F41)\n- **导出错误**：如果你遇到以下错误，请尝试重启微信：\n  ```bash\n  导出微信数据失败。请确保微信正在运行，并且已安装 WeChatTweak。\n  未找到或无法导出微信数据。退出。\n  ```\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：微信专用参数\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### 参数\n```bash\n--export-dir DIR         # 存储导出的微信数据的目录（默认：wechat_export_direct）\n--force-export          # 强制重新导出，即使已有数据\n```\n\n#### 示例命令\n```bash\n# 搜索群聊中讨论的旅行计划\npython -m apps.wechat_rag --query \"旅行计划\" --max-items 10000\n\n# 重新导出并搜索最近的聊天记录（新消息后很有用）\npython -m apps.wechat_rag --force-export --query \"工作日程\"\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>💬 点击展开：你可以尝试的示例查询\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n索引构建完成后，你可以提出如下问题：\n\n- “我想买魔术师约翰逊的球衣，给我一些对应聊天记录?” (中文：给我看看关于购买魔术师约翰逊球衣的聊天记录)\n\n\u003C\u002Fdetails>\n\n### 🤖 ChatGPT 聊天记录：您的个人 AI 对话档案！\n\n将您的 ChatGPT 对话转化为可搜索的知识库！在所有关于编码、研究、头脑风暴等方面的 ChatGPT 讨论中进行搜索。\n\n```bash\npython -m apps.chatgpt_rag --export-path chatgpt_export.html --query \"如何在 Python 中创建列表？\"\n```\n\n**解锁您的 AI 对话历史。** 再也不用担心丢失 ChatGPT 讨论中的宝贵见解了。\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：如何导出 ChatGPT 数据\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n**分步导出流程：**\n\n1. **登录 ChatGPT**\n2. **点击右上角的个人资料图标**\n3. **前往设置** → **数据控制**\n4. **在“导出数据”下点击“导出”**\n5. **确认导出请求**\n6. **从邮件链接下载 ZIP 文件**（有效期 24 小时）\n7. **解压或直接使用** LEANN 工具\n\n**支持的格式：**\n- ChatGPT 导出的 `.html` 文件\n- ChatGPT 的 `.zip` 存档\n- 包含多个导出文件的目录\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：ChatGPT 特定参数\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### 参数\n```bash\n--export-path PATH           # ChatGPT 导出文件（.html\u002F.zip）或目录的路径（默认：.\u002Fchatgpt_export）\n--separate-messages         # 分别处理每条消息，而非合并后的对话\n--chunk-size N              # 文本块大小（默认：512）\n--chunk-overlap N           # 块之间的重叠部分（默认：128）\n```\n\n#### 示例命令\n```bash\n# 使用 HTML 导出的基本用法\npython -m apps.chatgpt_rag --export-path conversations.html\n\n# 处理来自 ChatGPT 的 ZIP 存档\npython -m apps.chatgpt_rag --export-path chatgpt_export.zip\n\n# 使用特定查询进行搜索\npython -m apps.chatgpt_rag --export-path chatgpt_data.html --query \"Python 编程帮助\"\n\n# 处理单个消息以实现精细化搜索\npython -m apps.chatgpt_rag --separate-messages --export-path chatgpt_export.html\n\n# 处理包含多个导出文件的目录\npython -m apps.chatgpt_rag --export-path .\u002Fchatgpt_exports\u002F --max-items 1000\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>💡 点击展开：您可以尝试的示例查询\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n当您的 ChatGPT 对话被索引后，您可以使用以下查询进行搜索：\n- “我曾向 ChatGPT 询问过哪些关于 Python 编程的问题？”\n- “给我展示关于机器学习算法的对话”\n- “查找关于 Web 开发框架的讨论”\n- “ChatGPT 给了我哪些编程建议？”\n- “搜索关于调试技巧的对话”\n- “找到 ChatGPT 推荐的学习资源”\n\n\u003C\u002Fdetails>\n\n### 🤖 Claude 聊天记录：您的个人 AI 对话档案！\n\n将您的 Claude 对话转化为可搜索的知识库！在所有关于编码、研究、头脑风暴等方面的 Claude 讨论中进行搜索。\n\n```bash\npython -m apps.claude_rag --export-path claude_export.json --query \"我曾询问过关于 Python 字典的哪些问题？\"\n```\n\n**解锁您的 AI 对话历史。** 再也不用担心丢失 Claude 讨论中的宝贵见解了。\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：如何导出 Claude 数据\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n**分步导出流程：**\n\n1. **在浏览器中打开 Claude**\n2. **前往设置**（寻找齿轮图标或设置菜单）\n3. **在账户设置中找到导出\u002F下载选项**\n4. **下载对话数据**（通常为 JSON 格式）\n5. **将文件放置**在项目目录中\n\n*注意：Claude 的导出方法可能因您使用的界面而异。请查阅 Claude 的帮助文档，以获取最新的导出说明。*\n\n**支持的格式：**\n- `.json` 文件（推荐）\n- 包含 JSON 数据的 `.zip` 存档\n- 包含多个导出文件的目录\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：Claude 特定参数\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### 参数\n```bash\n--export-path PATH           # Claude 导出文件（.json\u002F.zip）或目录的路径（默认：.\u002Fclaude_export）\n--separate-messages         # 分别处理每条消息，而非合并后的对话\n--chunk-size N              # 文本块大小（默认：512）\n--chunk-overlap N           # 块之间的重叠部分（默认：128）\n```\n\n#### 示例命令\n```bash\n# 使用 JSON 导出的基本用法\npython -m apps.claude_rag --export-path my_claude_conversations.json\n\n# 处理来自 Claude 的 ZIP 存档\npython -m apps.claude_rag --export-path claude_export.zip\n\n# 使用特定查询进行搜索\npython -m apps.claude_rag --export-path claude_data.json --query \"机器学习建议\"\n\n# 处理单个消息以实现精细化搜索\npython -m apps.claude_rag --separate-messages --export-path claude_export.json\n\n# 处理包含多个导出文件的目录\npython -m apps.claude_rag --export-path .\u002Fclaude_exports\u002F --max-items 1000\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>💡 点击展开：您可以尝试的示例查询\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n当您的 Claude 对话被索引后，您可以使用以下查询进行搜索：\n- “我曾向 Claude 询问过哪些关于 Python 编程的问题？”\n- “给我展示关于机器学习算法的对话”\n- “查找关于软件架构模式的讨论”\n- “Claude 曾给我哪些调试建议？”\n- “搜索关于数据结构的对话”\n- “找到 Claude 推荐的学习资源”\n\n\u003C\u002Fdetails>\n\n### 💬 iMessage 历史：你的个人对话档案！\n\n将你的 iMessage 对话转化为可搜索的知识库！在所有短信、群聊以及与朋友、家人和同事的对话中进行搜索。\n\n```bash\npython -m apps.imessage_rag --query \"我们讨论了哪些周末计划？\"\n```\n\n**解锁你的消息历史。** 再也不用担心错过重要的对话、分享的链接或 iMessage 历史中的难忘时刻。\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：如何访问 iMessage 数据\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n**iMessage 数据位置：**\n\niMessage 对话存储在你 Mac 上的 SQLite 数据库中，路径为：\n```\n~\u002FLibrary\u002FMessages\u002Fchat.db\n```\n\n**重要设置要求：**\n\n1. **授予终端或 IDE 完全磁盘访问权限**：\n   - 打开 **系统偏好设置** → **安全性与隐私** → **隐私**\n   - 在左侧栏选择 **完全磁盘访问权限**\n   - 点击 **+** 按钮，添加你的终端应用（Terminal、iTerm2）或 IDE（VS Code 等）\n   - 授予访问权限后，请重启你的终端\u002FIDE\n\n2. **替代方案：使用备份数据库**\n   - 如果你有 Time Machine 备份或手动复制的数据库\n   - 使用 `--db-path` 指定自定义路径\n\n**支持的格式：**\n- 直接访问 `~\u002FLibrary\u002FMessages\u002Fchat.db`（默认）\n- 使用 `--db-path` 指定自定义数据库路径\n- 也适用于数据库的备份副本\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：iMessage 特定参数\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n#### 参数\n```bash\n--db-path PATH                    # chat.db 文件路径（默认：~\u002FLibrary\u002FMessages\u002Fchat.db）\n--concatenate-conversations       # 按对话分组消息（默认：True）\n--no-concatenate-conversations    # 将每条消息单独处理\n--chunk-size N                    # 文本块大小（默认：1000）\n--chunk-overlap N                 # 文本块之间的重叠量（默认：200）\n```\n\n#### 示例命令\n```bash\n# 基本用法（需要完全磁盘访问权限）\npython -m apps.imessage_rag\n\n# 使用特定查询进行搜索\npython -m apps.imessage_rag --query \"家庭聚餐计划\"\n\n# 使用自定义数据库路径\npython -m apps.imessage_rag --db-path \u002Fpath\u002Fto\u002Fbackup\u002Fchat.db\n\n# 不按对话分组，而是单独处理每条消息\npython -m apps.imessage_rag --no-concatenate-conversations\n\n# 限制处理数量以进行测试\npython -m apps.imessage_rag --max-items 100 --query \"周末\"\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>💡 点击展开：你可以尝试的示例查询\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n一旦你的 iMessage 对话被索引，你就可以使用以下查询进行搜索：\n- “我们讨论过哪些度假计划？”\n- “查找关于餐厅推荐的消息”\n- “给我显示与 John 关于项目的对话”\n- “搜索关于科技的分享链接”\n- “查找关于周末活动的群聊讨论”\n- “妈妈对家庭聚会说了什么？”\n\n\u003C\u002Fdetails>\n\n### MCP 集成：跨平台实时数据的 RAG 检索\n\n通过模型上下文协议（MCP）连接到实时数据源。LEANN 现在支持通过标准化的 MCP 服务器，在 Slack、Twitter 等平台上进行实时 RAG 检索。\n\n**主要优势：**\n- **实时数据访问**：无需手动导出即可获取实时数据\n- **标准化协议**：可使用任何兼容 MCP 的服务器\n- **易于扩展**：只需少量代码即可添加新平台\n- **安全访问**：MCP 服务器负责身份验证\n\n#### 💬 Slack 消息：搜索团队对话\n\n将你的 Slack 工作区转化为可搜索的知识库！在所有频道中查找讨论、决策和共享的知识。\n\n```bash\n# 测试 MCP 服务器连接\npython -m apps.slack_rag --mcp-server \"slack-mcp-server\" --test-connection\n\n# 索引并搜索 Slack 消息\npython -m apps.slack_rag \\\n  --mcp-server \"slack-mcp-server\" \\\n  --workspace-name \"my-team\" \\\n  --channels general dev-team random \\\n  --query \"我们关于产品发布做出了什么决定？\"\n```\n\n**📖 全面设置指南**：有关详细的设置说明、常见问题排查（如“用户缓存尚未就绪”）以及高级配置选项，请参阅我们的 [**Slack 设置指南**](docs\u002Fslack-setup-guide.md)。\n\n**快速设置：**\n1. 安装 Slack MCP 服务器（例如：`npm install -g slack-mcp-server`）\n2. 创建 Slack 应用并获取 API 凭证（详见上述指南）\n3. 设置环境变量：\n   ```bash\n   export SLACK_BOT_TOKEN=\"xoxb-your-bot-token\"\n   export SLACK_APP_TOKEN=\"xapp-your-app-token\"  # 可选\n   ```\n4. 使用 `--test-connection` 标志测试连接\n\n**参数：**\n- `--mcp-server`：启动 Slack MCP 服务器的命令\n- `--workspace-name`：用于组织的 Slack 工作空间名称\n- `--channels`：要索引的特定频道（可选）\n- `--concatenate-conversations`：按频道分组消息（默认：是）\n- `--max-messages-per-channel`：每个频道的最大消息数（默认：100）\n- `--max-retries`：缓存同步问题的最大重试次数（默认：5）\n- `--retry-delay`：每次重试之间的初始延迟时间，单位为秒（默认：2.0）\n\n#### 🐦 Twitter 书签：你的个人推文图书馆\n\n搜索你的 Twitter 书签！找到你保存下来以备后用的那篇文章、话题串或精彩见解。\n\n```bash\n# 测试 MCP 服务器连接\npython -m apps.twitter_rag --mcp-server \"twitter-mcp-server\" --test-connection\n\n# 索引并搜索 Twitter 书签\npython -m apps.twitter_rag \\\n  --mcp-server \"twitter-mcp-server\" \\\n  --max-bookmarks 1000 \\\n  --query \"我在机器学习方面收藏了哪些 AI 文章？\"\n```\n\n**设置要求：**\n1. 安装一个 Twitter MCP 服务器（例如：`npm install -g twitter-mcp-server`）\n2. 获取 Twitter API 凭证：\n   - 在 [developer.twitter.com](https:\u002F\u002Fdeveloper.twitter.com) 申请 Twitter 开发者账号\n   - 在 Twitter 开发者门户中创建一个新的应用\n   - 生成具有“读取”权限的 API 密钥和访问令牌\n   - 若要访问书签，可能需要使用具有相应作用域的 Twitter API v2\n   ```bash\n   export TWITTER_API_KEY=\"your-api-key\"\n   export TWITTER_API_SECRET=\"your-api-secret\"\n   export TWITTER_ACCESS_TOKEN=\"your-access-token\"\n   export TWITTER_ACCESS_TOKEN_SECRET=\"your-access-token-secret\"\n   ```\n3. 使用 `--test-connection` 标志测试连接\n\n**参数：**\n- `--mcp-server`: 用于启动 Twitter MCP 服务器的命令\n- `--username`: 按用户名筛选书签（可选）\n- `--max-bookmarks`: 最大获取书签数量（默认：1000）\n- `--no-tweet-content`: 排除推文内容，仅保留元数据\n- `--no-metadata`: 排除互动元数据\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>💡 点击展开：你可以尝试的示例查询\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n**Slack 查询：**\n- “团队讨论了关于项目截止日期的哪些内容？”\n- “查找有关新功能发布的消息”\n- “向我展示关于预算规划的对话”\n- “开发团队频道中做出了哪些决定？”\n\n**Twitter 查询：**\n- “上个月我收藏了哪些 AI 文章？”\n- “查找有关机器学习技术的推文”\n- “向我展示有关创业建议的已收藏话题串”\n- “我保存了哪些 Python 教程？”\n\n\u003C\u002Fdetails>\n\u003Csummary>\u003Cstrong>🔧 使用 CLI 命令与 MCP 集成\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n**想将 MCP 数据与常规 LEANN CLI 结合使用吗？** 你可以将 MCP 应用与 CLI 命令结合：\n\n```bash\n# 第一步：使用 MCP 应用获取并索引数据\npython -m apps.slack_rag --mcp-server \"slack-mcp-server\" --workspace-name \"my-team\"\n\n# 第二步：数据现已索引，可通过 CLI 使用\nleann search slack_messages \"project deadline\"\nleann ask slack_messages \"What decisions were made about the product launch?\"\n\n# 对于 Twitter 书签也是一样\npython -m apps.twitter_rag --mcp-server \"twitter-mcp-server\"\nleann search twitter_bookmarks \"machine learning articles\"\n```\n\n**MCP 与手动导出的区别：**\n- **MCP**：实时数据，自动更新，需要设置服务器\n- **手动导出**：一次性设置，可离线使用，需手动导出数据\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>🔧 添加新的 MCP 平台\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n希望添加对其他平台的支持吗？LEANN 的 MCP 集成设计为易于扩展：\n\n1. **找到或创建适用于你平台的 MCP 服务器**\n2. **按照 `apps\u002Fslack_data\u002Fslack_mcp_reader.py` 中的模式创建读取类**\n3. **按照 `apps\u002Fslack_rag.py` 中的模式创建 RAG 应用程序**\n4. **测试后贡献回社区！**\n\n**可探索的热门 MCP 服务器：**\n- GitHub 仓库和问题\n- Discord 消息\n- Notion 页面\n- Google Drive 文档\n- 以及 MCP 生态系统中的更多选项！\n\n\u003C\u002Fdetails>\n\n### 🚀 Claude Code 集成：变革你的开发工作流！\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>AST‑感知代码分块\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nLEANN 具有智能代码分块功能，能够保留语义边界（函数、类、方法），适用于 Python、Java、C# 和 TypeScript，相比基于文本的分块方式，能更好地理解代码。\n\n📖 阅读 [AST 分块指南 →](docs\u002Fast_chunking_guide.md)\n\n\u003C\u002Fdetails>\n\n**代码辅助的未来已经到来。** 通过 LEANN 与 Claude Code 的原生 MCP 集成，索引你的整个代码库，并在 IDE 中直接获得智能代码辅助。\n\n**主要特性：**\n- 🔍 **语义代码搜索** 覆盖整个项目，完全本地化且轻量级\n- 🧠 **AST 感知分块** 保留代码结构（函数、类）\n- 📚 **上下文感知辅助** 用于调试和开发\n- 🚀 **零配置设置** 自动检测语言\n\n```bash\n# 全局安装 LEANN 以实现 MCP 集成\nuv tool install leann-core --with leann\nclaude mcp add --scope user leann-server -- leann_mcp\n# 设置自动完成——只需开始使用 Claude Code！\n```\n体验我们的全代理式流程，包括自动查询重写、语义搜索规划等：\n\n![LEANN MCP 集成](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_bc9d89ebc3e9.png)\n\n**🔥 准备好提升你的编码能力了吗？** [完整设置指南 →](packages\u002Fleann-mcp\u002FREADME.md)\n\n## 命令行界面\n\nLEANN 包含一个强大的命令行界面，用于文档处理和搜索。非常适合快速索引文档和进行交互式聊天。\n\n### 安装\n\n如果你遵循了快速入门指南，`leann` 已经安装在你的虚拟环境中：\n```bash\nsource .venv\u002Fbin\u002Factivate\nleann --help\n```\n\n**若要使其全局可用：**\n```bash\n# 使用 uv 工具全局安装 LEANN CLI\nuv tool install leann-core --with leann\n\n\n# 现在你可以在任何地方使用 leann，无需激活虚拟环境\nleann --help\n```\n\n> **注意**：全球安装是集成 Claude Code 所必需的。`leann_mcp` 服务器依赖于全局可用的 `leann` 命令。\n\n\n\n### 使用示例\n\n```bash\n# 从特定目录构建索引，my_docs 是索引名称（这里也可以从多个目录或文件构建）\nleann build my-docs --docs .\u002Fyour_documents\n\n# 搜索你的文档\nleann search my-docs \"machine learning concepts\"\n\n# 与你的文档进行交互式聊天\nleann ask my-docs --interactive\n\n# 提问单个问题（非交互式）\nleann ask my-docs \"提示在哪里配置？\"\n\n# 检测自上次构建\u002F监视检查点以来的文件变化\nleann watch my-docs\n\n# 列出所有索引\nleann list\n\n# 删除一个索引\nleann remove my-docs\n```\n\n**关键 CLI 功能：**\n- 自动检测文档格式（PDF、TXT、MD、DOCX、PPTX 以及代码文件）\n- 针对 Python、Java、C#、TypeScript 文件的 **🧠 AST 感知分块**\n- 对其他内容进行带重叠的智能文本分块\n- 通过 Merkle 树快照实现 **📂 文件变更检测**（`leann watch`）\n- 支持多个 LLM 提供商（Ollama、OpenAI、HuggingFace）\n- 索引以有序方式存储在 `.leann\u002Findexes\u002F` 目录中（项目本地）\n- 支持高级搜索参数\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>📋 点击展开：完整 CLI 参考\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n您可以使用 `leann --help`，或 `leann build --help`、`leann search --help`、`leann watch --help`、`leann ask --help`、`leann list --help`、`leann remove --help` 来获取完整的 CLI 参考。\n\n**构建命令：**\n```bash\nleann build INDEX_NAME --docs DIRECTORY|FILE [DIRECTORY|FILE ...] [OPTIONS]\n\n选项：\n  --backend {hnsw,diskann}     使用的后端（默认：hnsw）\n  --embedding-model MODEL      嵌入模型（默认：facebook\u002Fcontriever）\n  --graph-degree N             图的度数（默认：32）\n  --complexity N               构建复杂度（默认：64）\n  --force                      强制重建现有索引\n  --compact \u002F --no-compact     使用紧凑存储（默认：true）。若选择不重新计算，则必须设置为 --no-compact。\n  --recompute \u002F --no-recompute 启用重新计算（默认：true）\n```\n\n**搜索命令：**\n```bash\nleann search INDEX_NAME QUERY [OPTIONS]\n\n选项：\n  --top-k N                     结果数量（默认：5）\n  --complexity N                搜索复杂度（默认：64）\n  --recompute \u002F --no-recompute  是否启用嵌入重新计算（默认：启用）。在重新计算模式下构建的索引不应使用不重新计算的搜索。\n  --pruning-strategy {global,local,proportional}\n```\n\n**监听命令：**\n```bash\nleann watch INDEX_NAME\n\n# 将当前文件系统状态与上次检查点（Merkle 树快照）进行比较，\n# 并报告哪些文件被添加、删除或修改，以及它们对应的分块 ID。\n#\n# - 检测到更改后会自动保存新的检查点\n# - 每次运行都会与最近的检查点进行对比\n# - 文件变更检测采用 SHA-256 内容哈希算法，并通过 Merkle 树实现\n#\n# 示例输出：\n#   === 自上次检查点以来的变更 ===\n#   已修改 (1):\n#     - \u002Fpath\u002Fto\u002Ffile.py\n#       分块：42、43、44\n```\n\n**提问命令：**\n```bash\nleann ask INDEX_NAME [OPTIONS]\n\n选项：\n  --llm {ollama,openai,hf,anthropic}    LLM 提供商（默认：ollama）\n  --model MODEL                         模型名称（默认：qwen3:8b）\n  --interactive                         交互式聊天模式\n  --top-k N                             检索数量（默认：20）\n```\n\n**列出命令：**\n```bash\nleann list\n\n# 列出所有项目中的所有索引，并附带状态标识：\n# ✅ - 索引已完成且可使用\n# ❌ - 索引不完整或已损坏\n# 📁 - 由 CLI 创建的索引（位于 .leann\u002Findexes\u002F 目录中）\n# 📄 - 由应用创建的索引（*.leann.meta.json 文件）\n```\n\n**移除命令：**\n```bash\nleann remove INDEX_NAME [OPTIONS]\n\n选项：\n  --force, -f    强制移除，无需确认\n\n# 智能移除：自动查找并安全移除索引\n# - 显示跨项目的所有匹配索引\n# - 跨项目移除需要确认\n# - 当找到多个匹配项时支持交互式选择\n# - 同时支持 CLI 和应用创建的索引\n```\n\n\u003C\u002Fdetails>\n\n## 🚀 高级功能\n\n### 🎯 元数据过滤\n\nLEANN 支持简单的元数据过滤系统，可用于实现复杂的使用场景，例如按日期\u002F类型筛选文档、按文件扩展名搜索代码，以及基于自定义条件的内容管理。\n\n```python\n# 在索引过程中添加元数据\nbuilder.add_text(\n    \"def authenticate_user(token): ...\",\n    metadata={\"file_extension\": \".py\", \"lines_of_code\": 25}\n)\n\n# 带过滤条件的搜索\nresults = searcher.search(\n    query=\"authentication function\",\n    metadata_filters={\n        \"file_extension\": {\"==\": \".py\"},\n        \"lines_of_code\": {\"\u003C\": 100}\n    }\n)\n```\n\n**支持的操作符**：`==`、`!=`、`\u003C`、`\u003C=`、`>`、`>=`、`in`、`not_in`、`contains`、`starts_with`、`ends_with`、`is_true`、`is_false`\n\n📖 **[完整元数据过滤指南 →](docs\u002Fmetadata_filtering.md)**\n\n### 🔍 Grep 搜索\n\n若需进行精确文本匹配而非语义搜索，可使用 `use_grep` 参数：\n\n```python\n# 精确文本搜索\nresults = searcher.search(\"banana‑crocodile\", use_grep=True, top_k=1)\n```\n\n**适用场景**：查找特定的代码模式、错误信息、函数名或确切短语，当不需要语义相似性时。\n\n📖 **[完整 grep 搜索指南 →](docs\u002Fgrep_search.md)**\n\n## 🏗️ 架构与工作原理\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_3f5d5b6e0f1d.png\" alt=\"LEANN 架构\" width=\"800\">\n\u003C\u002Fp>\n\n**其奥秘在于**：大多数向量数据库会存储每一个嵌入向量（成本高昂）。而 LEANN 则存储经过修剪的图结构（成本低廉），并在需要时才重新计算嵌入向量（速度快）。\n\n**核心技术：**\n- **基于图的按需重新计算**：仅计算搜索路径上的节点嵌入\n- **高阶保留式修剪**：保留重要的“枢纽”节点，同时移除冗余连接\n- **动态批处理**：高效地将嵌入计算分批处理，以充分利用 GPU 资源\n- **两级搜索**：智能图遍历，优先探索最有希望的节点\n\n**后端：**\n- **HNSW**（默认）：适用于大多数数据集，在完全重新计算的情况下可实现最大的存储节省\n- **DiskANN**：高级选项，具有更出色的搜索性能，采用基于 PQ 的图遍历结合实时重排序，可在速度和准确率之间取得最佳平衡\n\n## 基准测试\n\n**[DiskANN 与 HNSW 性能对比 →](benchmarks\u002Fdiskann_vs_hnsw_speed_comparison.py)** - 比较两种后端的搜索性能\n\n**[简单示例：LEANN 与 FAISS 对比 →](benchmarks\u002Fcompare_faiss_vs_leann.py)** - 观察存储节省的实际效果\n\n### 📊 存储对比\n\n| 系统 | DPR (2.1M) | Wiki (60M) | Chat (400K) | Email (780K) | Browser (38K) |\n|--------|-------------|------------|-------------|--------------|---------------|\n| 传统向量数据库（如 FAISS） | 3.8 GB      | 201 GB     | 1.8 GB     | 2.4 GB      | 130 MB        |\n| LEANN  | 324 MB      | 6 GB       | 64 MB       | 79 MB       | 6.4 MB        |\n| 节省| 91%         | 97%        | 97%         | 97%         | 95%           |\n\n\n\n## 复现我们的结果\n\n```bash\nuv run benchmarks\u002Frun_evaluation.py    # 自动下载评估数据并运行基准测试\nuv run benchmarks\u002Frun_evaluation.py benchmarks\u002Fdata\u002Findices\u002Frpj_wiki\u002Frpj_wiki --num-queries 2000    # 下载数据后，您可以用我们最大的索引运行基准测试\n```\n\n评估脚本会在首次运行时自动下载数据。最后三次的结果是使用部分个人数据测试的，您也可以用自己的数据来复现这些结果！\n\n## 🔬 论文\n\n如果您觉得 Leann 有用，请引用：\n\n**[LEANN：一种低存储向量索引](https:\u002F\u002Farxiv.org\u002Fabs\u002F2506.08276)**\n\n```bibtex\n@misc{wang2025leannlowstoragevectorindex,\n      title={LEANN: A Low-Storage Vector Index},\n      author={Yichuan Wang and Shu Liu and Zhifei Li and Yongji Wu and Ziming Mao and Yilong Zhao and Xiao Yan and Zhiying Xu and Yang Zhou and Ion Stoica and Sewon Min and Matei Zaharia and Joseph E. Gonzalez},\n      year={2025},\n      eprint={2506.08276},\n      archivePrefix={arXiv},\n      primaryClass={cs.DB},\n      url={https:\u002F\u002Farxiv.org\u002Fabs\u002F2506.08276},\n}\n```\n\n## ✨ [详细功能 →](docs\u002Ffeatures.md)\n\n## 🤝 [贡献指南 →](docs\u002FCONTRIBUTING.md)\n\n\n## ❓ [常见问题 →](docs\u002Ffaq.md)\n\n\n## 📈 [路线图 →](docs\u002Froadmap.md)\n\n## 📄 许可证\n\nMIT 许可证 - 详情请参阅 [LICENSE](LICENSE)。\n\n## 🙏 致谢\n\n核心贡献者：[Yichuan Wang](https:\u002F\u002Fyichuan-w.github.io\u002F) 和 [Zhifei Li](https:\u002F\u002Fgithub.com\u002Fandylizf)。\n\n活跃贡献者：[Gabriel Dehan](https:\u002F\u002Fgithub.com\u002Fgabriel-dehan)、[Aakash Suresh](https:\u002F\u002Fgithub.com\u002FASuresh0524)。\n\n我们欢迎更多贡献者！欢迎随时提出问题或提交拉取请求。\n\n本工作由 [**伯克利天空计算实验室**](https:\u002F\u002Fsky.cs.berkeley.edu\u002F) 完成。\n\n## 星标历史\n\n[![星标历史图表](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_readme_d664a156587f.png)](https:\u002F\u002Fwww.star-history.com\u002F#yichuan-w\u002FLEANN&Date)\n\u003Cp align=\"center\">\n  \u003Cstrong>⭐ 如果 Leann 对您的研究或应用有帮助，请在 GitHub 上给它点个 Star 吧！\u003C\u002Fstrong>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  由 Leann 团队用心制作 ❤️\n\u003C\u002Fp>\n\n## 🤖 使用 AI 探索 LEANN\n\nLEANN 已被收录至 [DeepWiki](https:\u002F\u002Fdeepwiki.com\u002Fyichuan-w\u002FLEANN)，您可以通过 Deep Research 向大型语言模型提问，以探索代码库并获得帮助来添加新功能。","# LEANN 快速上手指南\n\nLEANN 是一款创新的轻量级向量数据库，旨在将您的笔记本电脑转变为强大的个人 RAG（检索增强生成）系统。它通过基于图的选择性重计算技术，相比传统方案节省 **97%** 的存储空间，同时保持搜索精度无损，且数据完全本地化，保障隐私。\n\n## 环境准备\n\n### 系统要求\n- **操作系统**: Ubuntu, Arch Linux, WSL, macOS (ARM64\u002FIntel), Windows\n- **Python 版本**: 3.9, 3.10, 3.11, 3.12, 3.13\n- **磁盘空间**: 极小占用（例如：6000 万文本块仅需约 6GB）\n\n### 前置依赖\nLEANN 推荐使用 `uv` 作为包管理器和虚拟环境工具。\n\n**安装 uv:**\n```bash\ncurl -LsSf https:\u002F\u002Fastral.sh\u002Fuv\u002Finstall.sh | sh\n```\n\n> **注意**:\n> - **macOS**: 若需构建 DiskANN 后端，需 macOS 13.3+，并安装 `libomp`, `boost`, `protobuf` 等。\n> - **Linux**: 可能需要安装 `libmkl-full-dev` (Intel MKL) 或 `libopenblas-dev`。\n> - **Windows**: 需要 Visual Studio 2022 Build Tools (含 C++ 桌面开发负载) 和 vcpkg。\n\n## 安装步骤\n\n### 1. 克隆项目\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN.git leann\ncd leann\n```\n\n### 2. 创建虚拟环境并安装\n推荐使用 PyPI 版本进行快速体验：\n\n```bash\nuv venv\nsource .venv\u002Fbin\u002Factivate  # Windows 用户请使用: .venv\\Scripts\\activate\nuv pip install leann\n```\n\n> **可选**: 如果仅需 CPU 运行（Linux），可安装 `leann[cpu]`。\n> **开发\u002F高级用户**: 若需要从源码构建以支持 DiskANN 等高级特性，请使用 `uv sync --extra diskann`（需先安装各平台对应的系统级依赖库，详见原文详细构建说明）。\n\n## 基本使用\n\nLEANN 提供声明式 API，只需几行代码即可构建索引、搜索并与数据对话。\n\n### 示例代码\n\n创建一个 Python 文件（如 `demo.py`）或在交互式环境中运行：\n\n```python\nfrom leann import LeannBuilder, LeannSearcher, LeannChat\nfrom pathlib import Path\n\n# 设置索引保存路径\nINDEX_PATH = str(Path(\".\u002F\").resolve() \u002F \"demo.leann\")\n\n# 1. 构建索引\nbuilder = LeannBuilder(backend_name=\"hnsw\")\nbuilder.add_text(\"LEANN saves 97% storage compared to traditional vector databases.\")\nbuilder.add_text(\"Tung Tung Tung Sahur called—they need their banana‑crocodile hybrid back\")\nbuilder.build_index(INDEX_PATH)\n\n# 2. 语义搜索\nsearcher = LeannSearcher(INDEX_PATH)\nresults = searcher.search(\"fantastical AI-generated creatures\", top_k=1)\nprint(\"搜索结果:\", results)\n\n# 3. 与数据对话 (RAG)\n# 需配置 LLM，此处示例使用 HuggingFace 本地模型\nchat = LeannChat(INDEX_PATH, llm_config={\"type\": \"hf\", \"model\": \"Qwen\u002FQwen3-0.6B\"})\nresponse = chat.ask(\"How much storage does LEANN save?\", top_k=1)\nprint(\"回答:\", response)\n```\n\n### 配置 LLM (可选)\n默认支持 OpenAI 兼容接口。若使用 OpenAI 服务：\n```bash\nexport OPENAI_API_KEY=\"your-api-key-here\"\n```\n在代码或 CLI 中指定 `--llm openai` 即可。LEANN 同样支持 Ollama、Anthropic 及任何兼容 OpenAI 格式的本地或远程模型服务。","资深数据分析师李明需要在本地笔记本上构建一个涵盖数百万份历史研报、邮件往来及即时通讯记录的私有知识库，以支持高频次的语义检索与决策辅助。\n\n### 没有 LEANN 时\n- **存储成本高昂**：传统向量数据库需全量存储嵌入向量，导致索引文件体积庞大，迅速占满笔记本有限的 SSD 空间。\n- **隐私泄露风险**：为节省资源被迫将数据上传至云端 RAG 服务，敏感的商业研报和内部沟通记录面临外泄隐患。\n- **检索响应迟缓**：受限于本地硬件性能，大规模数据下的相似度搜索延迟极高，严重打断分析思路。\n- **数据孤岛严重**：难以统一处理文件系统、邮件、微信及浏览器历史等多源异构数据，知识关联挖掘困难。\n\n### 使用 LEANN 后\n- **极致存储压缩**：凭借基于图的选择性重计算技术，LEANN 在保持精度不变的前提下节省了 97% 的存储空间，轻松容纳百万级文档。\n- **100% 本地隐私**：所有索引构建与推理过程完全在个人设备运行，无需联网，彻底杜绝数据出域风险。\n- **毫秒级极速响应**：即使在普通笔记本上，也能对海量数据进行快速的语义搜索，实现流畅的交互式问答。\n- **全域数据融合**：原生支持集成文件、邮件、聊天记录及实时 MCP 数据源，将分散的个人数字足迹转化为统一的知识网络。\n\nLEANN 让普通笔记本电脑瞬间变身为一台高效、安全且超大规模的私有 AI 知识引擎，真正实现了“万物皆可 RAG\"。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyichuan-w_LEANN_73108177.png","yichuan-w","Yichuan Wang","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fyichuan-w_0c27bc25.jpg","EECS PhD SkyLab@UC Berkeley, Undergraduate ACM Class SJTU",null,"https:\u002F\u002Fyichuan-w.github.io\u002F","https:\u002F\u002Fgithub.com\u002Fyichuan-w",[80,84,88,92,96],{"name":81,"color":82,"percentage":83},"Python","#3572A5",98.9,{"name":85,"color":86,"percentage":87},"Shell","#89e051",0.5,{"name":89,"color":90,"percentage":91},"CMake","#DA3434",0.3,{"name":93,"color":94,"percentage":95},"Jupyter Notebook","#DA5B0B",0.2,{"name":97,"color":98,"percentage":99},"Dockerfile","#384d54",0,10760,942,"2026-04-09T11:49:45","MIT","Linux (Ubuntu, Arch, RHEL\u002FCentOS), macOS (ARM64\u002FIntel, 需 13.3+), Windows","未说明 (默认支持 CPU，GPU 加速功能需通过社区投票决定)","未说明 (强调低内存占用，适合笔记本电脑运行)",{"notes":108,"python":109,"dependencies":110},"1. 推荐使用 'uv' 进行包管理和环境构建。2. macOS 需 13.3 及以上版本以支持 DiskANN。3. Windows 编译需安装 Visual Studio 2022 Build Tools (C++ 桌面开发工作负载) 和 vcpkg。4. 该工具主打轻量级和本地隐私，可在笔记本上运行，无需云端成本。5. 若仅需构建 HNSW 索引，可省略 DiskANN 相关依赖（如 MKL）。","3.9 | 3.10 | 3.11 | 3.12 | 3.13",[111,112,113,114,115,116,117,118,119],"uv","libomp-dev","libboost-all-dev","protobuf-compiler","libzmq3-dev","libabsl-dev","libaio-dev","libmkl-full-dev (可选，用于 DiskANN)","libopenblas-dev",[121,16,15,13,14,35],"其他",[123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138],"ai","faiss","langchain","llama-index","llm","localstorage","offline-first","ollama","privacy","python","rag","retrieval-augmented-generation","vector-database","vector-search","vectors","gpt-oss","2026-03-27T02:49:30.150509","2026-04-10T01:06:22.696706",[142,147,152,157,162,167],{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},26923,"如何在 Mac M4 (ARM64) 架构上解决安装失败或依赖解析错误的问题？","该问题通常是因为使用了 x86_64 架构的 Python（通过 Rosetta 运行），而项目仅提供 arm64 的预编译包。解决方法是强制使用原生 arm64 架构安装 Python 和工具：\n1. 卸载现有的 uv：`pip uninstall uv`\n2. 通过 brew 重新安装 uv：`brew install uv`\n3. 确认当前架构为 arm64 (`arch`)\n4. 安装原生 arm64 Python：`uv python install cpython-3.12.4-macos-aarch64-none` (或 3.13)\n5. 使用指定架构安装 LEANN：`arch -arm64 uv tool install --python 3.12 --with leann-backend-hnsw leann-core`\n注意：必须确保 Python 解释器和 shell 环境均为 arm64 架构。","https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN\u002Fissues\u002F34",{"id":148,"question_zh":149,"answer_zh":150,"source_url":151},26924,"如何配置 LEANN 以配合 LM Studio 使用？MCP Server 的 URL 应该填什么？","LEANN 与 LM Studio 有两种主要集成方式：\n1. **在 LEANN 界面中使用 LM Studio 模型**：这是推荐方式。LEANN 作为前端，调用 LM Studio 提供的 OpenAI 兼容接口进行推理和嵌入生成。此时不需要在 LM Studio 中配置 LEANN 的 URL。\n2. **在 LM Studio 界面中使用 LEANN 数据 (RAG)**：如果你想在 LM Studio 应用中聊天并获取 LEANN 索引的上下文，需要将 LEANN 作为 MCP 服务添加到 LM Studio。但目前的 `leann_mcp` 是为 Claude 等设计的，直接在 LM Studio 的 mcp.json 中填写 `leann_mcp` 会报错（Invalid URL），因为 LM Studio 期望的是 HTTP URL 而非本地命令。目前建议通过 LEANN 自身的 CLI 或 Python 接口来聊天，由 LEANN 后端连接 LM Studio。","https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN\u002Fissues\u002F80",{"id":153,"question_zh":154,"answer_zh":155,"source_url":156},26925,"执行 `leann build` 时，为什么有些 PDF 文件被跳过并提示“Skipping file outside directory scope”？","这通常是一个已修复的 Bug（见 PR #84）。该问题导致即使文件在指定目录内，也被错误地判断为在范围之外。如果你遇到此问题，请确保升级到最新版本。此外，如果重新运行 `leann build` 命令，默认行为通常是重建索引（覆盖旧索引），而不是增量追加。如果需要增量更新，目前可能需要手动删除旧索引后重新构建，或者等待后续版本支持基于 Merkle tree 的增量构建功能。","https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN\u002Fissues\u002F81",{"id":158,"question_zh":159,"answer_zh":160,"source_url":161},26926,"如何控制 `leann build` 过程中的文本分块大小（chunk-size）？","默认的分块大小可能较小（如 256 tokens），导致无法覆盖完整的函数或类。虽然具体命令行参数在早期版本中可能未直接暴露，但你可以通过检查项目配置文件或源代码中的分块逻辑进行调整。对于使用长上下文模型（如 Qwen3-Embedding-0.6B 支持 32k）的用户，增大分块尺寸能更好地保留代码语义。建议查看 `leann build` 的帮助文档或相关配置文件（如 `.leannrc` 或代码库中的 chunking 设置）来自定义 token 限制。如果当前版本不支持直接参数控制，可能需要修改源码中的默认分块参数。","https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN\u002Fissues\u002F48",{"id":163,"question_zh":164,"answer_zh":165,"source_url":166},26927,"使用 Ollama 生成嵌入时速度极慢，如何处理性能瓶颈？","这是一个已确认的性能 Bug。原因是代码在调用 Ollama API 时是串行处理每个文本块，而没有利用 Ollama `\u002Fapi\u002Fembeddings` 接口支持的批量（batch）处理功能。这导致了大量的网络开销和 GPU 利用率低下。该问题已在后续的 PR（#152）中被修复。如果你遇到此问题，请务必更新到包含该修复的最新版本。更新后，嵌入生成将改为批量发送请求，显著提升索引速度。","https:\u002F\u002Fgithub.com\u002Fyichuan-w\u002FLEANN\u002Fissues\u002F151",{"id":168,"question_zh":169,"answer_zh":170,"source_url":156},26928,"重新运行 `leann build` 命令时，是会追加新数据到现有索引，还是覆盖原有索引？","目前的实现逻辑是直接重建索引（即覆盖）。如果你运行 `leann build` 且索引已存在，它会使用新数据重新生成整个索引，而不是增量追加。维护者提到，真正的增量构建功能（例如使用 Merkle tree 追踪文件变化）仍在开发计划中。因此，如果需要保留旧数据并添加新数据，目前需要确保源目录包含所有需要的文件然后全量重建，或者等待未来的版本更新支持增量模式。",[172,177,182,187,192,197,202,207,212,217,222,227,232,237,242,247,252,257,262,267],{"id":173,"version":174,"summary_zh":175,"released_at":176},180010,"v0.3.7","🚀 已发布至 PyPI：https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.3.7\u002F","2026-03-08T21:37:22",{"id":178,"version":179,"summary_zh":180,"released_at":181},180011,"v0.3.6","🚀 已发布到 PyPI：https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.3.6\u002F","2026-01-11T10:38:24",{"id":183,"version":184,"summary_zh":185,"released_at":186},180012,"v0.3.5","🚀 已发布至 PyPI：https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.3.5\u002F","2025-11-12T06:49:49",{"id":188,"version":189,"summary_zh":190,"released_at":191},180013,"v0.3.4","🚀 已发布至 PyPI：https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.3.4\u002F","2025-09-18T21:51:37",{"id":193,"version":194,"summary_zh":195,"released_at":196},180014,"v0.3.3","🚀 已发布至 PyPI：https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.3.3\u002F","2025-09-02T22:57:12",{"id":198,"version":199,"summary_zh":200,"released_at":201},180015,"v0.3.2","🚀 已发布至 PyPI：https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.3.2\u002F","2025-08-19T11:13:01",{"id":203,"version":204,"summary_zh":205,"released_at":206},180016,"v0.3.1","🚀 已发布至 PyPI：https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.3.1\u002F","2025-08-19T07:04:54",{"id":208,"version":209,"summary_zh":210,"released_at":211},180017,"v0.3.0","🚀 已发布至 PyPI：https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.3.0\u002F","2025-08-16T06:12:03",{"id":213,"version":214,"summary_zh":215,"released_at":216},180018,"v0.2.9","🚀 已发布至 PyPI：https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.2.9\u002F","2025-08-12T23:46:15",{"id":218,"version":219,"summary_zh":220,"released_at":221},180019,"v0.2.8","🚀 已发布至 PyPI：https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.2.8\u002F","2025-08-12T19:55:54",{"id":223,"version":224,"summary_zh":225,"released_at":226},180020,"v0.2.7","🚀 Released to PyPI: https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.2.7\u002F","2025-08-11T03:26:52",{"id":228,"version":229,"summary_zh":230,"released_at":231},180021,"v0.2.6","🚀 Released to PyPI: https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.2.6\u002F","2025-08-10T03:58:22",{"id":233,"version":234,"summary_zh":235,"released_at":236},180022,"v0.2.5","🚀 Released to PyPI: https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.2.5\u002F","2025-08-08T22:48:51",{"id":238,"version":239,"summary_zh":240,"released_at":241},180023,"v0.2.4","🚀 Released to PyPI: https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.2.4\u002F","2025-08-08T07:30:03",{"id":243,"version":244,"summary_zh":245,"released_at":246},180024,"v0.2.2","🚀 Released to PyPI: https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.2.2\u002F","2025-08-08T02:17:09",{"id":248,"version":249,"summary_zh":250,"released_at":251},180025,"v0.2.1","🚀 Released to PyPI: https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.2.1\u002F","2025-08-05T06:10:58",{"id":253,"version":254,"summary_zh":255,"released_at":256},180026,"v0.2.0","🚀 Released to PyPI: https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.2.0\u002F","2025-08-04T21:58:31",{"id":258,"version":259,"summary_zh":260,"released_at":261},180027,"v0.1.16","🚀 Released to PyPI: https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.1.16\u002F","2025-07-29T00:32:45",{"id":263,"version":264,"summary_zh":265,"released_at":266},180028,"v0.1.15","🚀 Released to PyPI: https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.1.15\u002F","2025-07-28T05:16:16",{"id":268,"version":269,"summary_zh":270,"released_at":271},180029,"v0.1.14","🚀 Released to PyPI: https:\u002F\u002Fpypi.org\u002Fproject\u002Fleann\u002F0.1.14\u002F","2025-07-27T09:01:17"]