能力标签
🛠
AI工具

LEANN AI技能包

基于 Python · 开源免费,本地部署,数据完全自主可控
英文名:LEANN
⭐ 11.0k Stars 🍴 962 Forks 💻 Python 📄 MIT 🏷 AI 8.2分
8.2AI 综合评分
RAG检索增强向量数据库存储优化LangChain
✦ AI Skill Hub 推荐

经 AI Skill Hub 精选评估,LEANN AI技能包 获评「强烈推荐」。在 GitHub 上收获超过 11.0k 颗 Star,这款AI工具在功能完整性、社区活跃度和易用性方面表现出色,AI 评分 8.2 分,适合有一定技术背景的用户使用。

📚 深度解析
LEANN AI技能包 是一款基于 Python 的开源工具,在 GitHub 上收获 11k+ Star,是RAG、检索增强、向量数据库、存储优化领域中的优质开源项目。开源工具的最大优势在于代码完全透明,你可以审计每一行代码的安全性,也可以根据自身需求进行二次开发和定制。

**为什么要使用开源工具而非商业 SaaS?**
对于个人开发者和有隐私需求的用户,本地部署的开源工具意味着数据不离本机,不受第三方服务商的数据政策约束。同时,开源工具通常没有使用次数限制和月度费用,一次安装即可长期使用,对于高频使用场景的总拥有成本(TCO)远低于订阅制商业工具。

**安装与环境准备**
LEANN AI技能包 依赖 Python 运行环境。建议通过 pyenv(Python)或 nvm(Node.js)管理 Python 版本,避免全局环境污染。对于新手用户,推荐先创建虚拟环境(python -m venv venv && source venv/bin/activate),再安装依赖,这样即使出现问题也可以随时删除虚拟环境重新开始,不影响系统稳定性。

**社区与维护**
GitHub Issue 和 Discussion 是获取帮助的最快渠道。在提问前建议先检查 Closed Issues(已关闭的问题),大多数常见问题都已有解答。遇到 Bug 时,提供 pip list 的输出、完整错误堆栈和最小可复现示例,能显著提高开发者响应速度。AI Skill Hub 将持续追踪 LEANN AI技能包 的版本更新,及时通知重要功能变化。
📋 工具概览

LEANN AI技能包 是一款基于 Python 开发的开源工具,专注于 RAG、检索增强、向量数据库 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

GitHub Stars
⭐ 11.0k
开发语言
Python
支持平台
Windows / macOS / Linux
维护状态
活跃维护,更新频繁
开源协议
MIT
AI 综合评分
8.2 分
工具类型
AI工具
Forks
962
📖 中文文档
以下内容由 AI Skill Hub 根据项目信息自动整理,如需查看完整原始文档请访问底部「原始来源」。

LEANN AI技能包 是一款基于 Python 开发的开源工具,专注于 RAG、检索增强、向量数据库 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

📌 核心特色
  • 开源免费,支持本地部署,数据完全自主可控
  • 活跃的 GitHub 开源社区,持续迭代更新
  • 提供详细文档和使用示例,新手友好
  • 支持自定义配置,灵活适配不同使用环境
  • 可作为基础组件集成进现有技术栈或进行二次开发
🎯 主要使用场景
  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发
以下安装命令基于项目开发语言和类型自动生成,实际以官方 README 为准。
安装命令
# 方式一:pip 安装(推荐)
pip install leann

# 方式二:虚拟环境安装(推荐生产环境)
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install leann

# 方式三:从源码安装(获取最新功能)
git clone https://github.com/yichuan-w/LEANN
cd LEANN
pip install -e .

# 验证安装
python -c "import leann; print('安装成功')"
📋 安装步骤说明
  1. 访问 GitHub 仓库页面
  2. 按照 README 文档完成依赖安装
  3. 根据系统环境完成初始化配置
  4. 参考官方示例或文档开始使用
  5. 遇到问题可在 GitHub Issues 中查找解答
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 命令行使用
leann --help

# 基本用法
leann input_file -o output_file

# Python 代码中调用
import leann

# 示例
result = leann.process("input")
print(result)
以下配置示例基于典型使用场景生成,具体参数请参照官方文档调整。
配置示例
# leann 配置文件示例(config.yml)
app:
  name: "leann"
  debug: false
  log_level: "INFO"

# 运行时指定配置文件
leann --config config.yml

# 或通过环境变量配置
export LEANN_API_KEY="your-key"
export LEANN_OUTPUT_DIR="./output"
📑 README 深度解析 真实文档 完整度 95/100 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

简介

<p align="center"> <img src="assets/logo-text.png" alt="LEANN Logo" width="400"> </p>

<p align="center"> <a href="https://trendshift.io/repositories/15049" target="_blank"> <img src="https://trendshift.io/api/badge/repositories/15049" alt="yichuan-w/LEANN | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/> </a> </p>

<p align="center"> <img src="https://img.shields.io/badge/Python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue.svg" alt="Python Versions"> <img src="https://github.com/yichuan-w/LEANN/actions/workflows/build-and-publish.yml/badge.svg" alt="CI Status"> <img src="https://img.shields.io/badge/Platform-Ubuntu%20%26%20Arch%20%26%20WSL%20%7C%20macOS%20(ARM64%2FIntel)%20%7C%20Windows-lightgrey" alt="Platform"> <img src="https://img.shields.io/badge/License-MIT-green.svg" alt="MIT License"> <img src="https://img.shields.io/badge/MCP-Native%20Integration-blue" alt="MCP Integration"> <a href="https://join.slack.com/t/leann-e2u9779/shared_invite/zt-3ol2ww9ic-Eg_kB8omwe6xmYVd0epr4Q"> <img src="https://img.shields.io/badge/Slack-Join-4A154B?logo=slack&logoColor=white" alt="Join Slack"> </a>

</p>

Take Survey

We track zero telemetry. This survey is the ONLY way to tell us if you want
GPU Acceleration or More Integrations next.
👉 Click here to cast your vote (2 mins)

💬 Join our Slack community!

We'd love for you to be part of the LEANN community!
👉 Join LEANN Slack
If the invite link has expired or you have trouble joining, please open an issue and we'll help you get in!

The smallest vector index in the world. RAG Everything with LEANN!

LEANN 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.

LEANN achieves this through graph-based selective recomputation with high-degree preserving pruning, computing embeddings on-demand instead of storing them all. Illustration Fig → | Paper →

Ready to RAG Everything? Transform your laptop into a personal AI assistant that can semantic search your file system, emails, browser history, chat history (WeChat, iMessage), agent memory (ChatGPT, Claude), live data (Slack, Twitter), codebase\* , or external knowledge bases (i.e., 60M documents) - all on your laptop, with zero cloud costs and complete privacy.

\* 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 →

🚀 Advanced Features

✨ [Detailed Features →](docs/features.md)

📦 Prerequisites: Install uv

Install uv first if you don't have it. Typically, you can install it with:

curl -LsSf https://astral.sh/uv/install.sh | sh

Install C++ dependencies via vcpkg

vcpkg install zeromq:x64-windows openblas:x64-windows lapack:x64-windows ` boost-program-options:x64-windows protobuf:x64-windows

Install dependencies

uv pip install colpali_engine pdf2image pillow matplotlib qwen_vl_utils einops seaborn brew install poppler # macOS only, for PDF processing


#### Build Index
bash python -m apps.colqwen_rag build \ --pdfs ./pdf_directory/ \ --index my_index \ --model colqwen2 # or colpali

#### Search
bash python -m apps.colqwen_rag search my_index "your question here" --top-k 5 ```

#### Models - ColQwen2 (colqwen2): Latest vision-language model with improved performance - ColPali (colpali): Proven multimodal retriever

For detailed usage, see the ColQwen Guide.

</details>

Basic usage (requires Full Disk Access)

python -m apps.imessage_rag

- Requires confirmation for cross-project removal

Installation

🚀 Quick Install

Clone the repository to access all examples and try amazing applications,

git clone https://github.com/yichuan-w/LEANN.git leann
cd leann

and install LEANN from PyPI to run them immediately:

```bash uv venv source .venv/bin/activate uv pip install leann

Install toolchain (if not already present)

choco install cmake swig pkgconfiglite nuget.commandline -y

Build an index

builder = LeannBuilder(backend_name="hnsw") builder.add_text("LEANN saves 97% storage compared to traditional vector databases.") builder.add_text("Tung Tung Tung Sahur called—they need their banana‑crocodile hybrid back") builder.build_index(INDEX_PATH)

Generation Model Setup

LLM Backend

LEANN supports many LLM providers for text generation (HuggingFace, Ollama, Anthropic, and Any OpenAI compatible API).

<details> <summary><strong>🔑 OpenAI API Setup (Default)</strong></summary>

Set your OpenAI API key as an environment variable:

export OPENAI_API_KEY="your-api-key-here"

Make sure to use --llm openai flag when using the CLI. You can also specify the model name with --llm-model <model-name> flag.

</details>

<details> <summary><strong>🛠️ Supported LLM & Embedding Providers (via OpenAI Compatibility)</strong></summary>

Thanks 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.

export OPENAI_API_KEY="xxx"
export OPENAI_BASE_URL="http://localhost:1234/v1" # base url of the provider

To use OpenAI compatible endpoint with the CLI interface:

If you are using it for text generation, make sure to use --llm openai flag and specify the model name with --llm-model <model-name> flag.

If you are using it for embedding, set the --embedding-mode openai flag and specify the model name with --embedding-model <MODEL>.

-----

Below is a list of base URLs for common providers to get you started.

Install Ollama

curl -fsSL https://ollama.ai/install.sh | sh

Index Building Parameters

--backend-name NAME # Backend to use: hnsw or diskann (default: hnsw) --graph-degree N # Graph degree for index construction (default: 32) --build-complexity N # Build complexity for index construction (default: 64) --compact / --no-compact # Use compact storage (default: true). Must be no-compact for no-recompute build. --recompute / --no-recompute # Enable/disable embedding recomputation (default: enabled). Should not do a no-recompute search in a recompute build. ```

</details>

Build index from PDFs

python -m apps.colqwen_rag build --pdfs ./my_papers/ --index research_papers

Install LEANN globally for MCP integration

uv tool install leann-core --with leann claude mcp add --scope user leann-server -- leann_mcp

Setup is automatic - just start using Claude Code!

``` Try our fully agentic pipeline with auto query rewriting, semantic search planning, and more:

LEANN MCP Integration

🔥 Ready to supercharge your coding? Complete Setup Guide →

Installation

If you followed the Quick Start, leann is already installed in your virtual environment:

source .venv/bin/activate
leann --help

To make it globally available: ```bash

Install the LEANN CLI globally using uv tool

uv tool install leann-core --with leann

build from a specific directory, and my_docs is the index name(Here you can also build from multiple dict or multiple files)

leann build my-docs --docs ./your_documents

Detect file changes since last build/watch checkpoint

leann watch my-docs

Quick Start

Our declarative API makes RAG as easy as writing a config file.

Check out demo.ipynb or Open In Colab

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

Core Parameters (General preprocessing for all examples)

--index-dir DIR # Directory to store the index (default: current directory) --query "YOUR QUESTION" # Single query mode. Omit for interactive chat (type 'quit' to exit), and now you can play with your index interactively --max-items N # Limit data preprocessing (default: -1, process all data) --force-rebuild # Force rebuild index even if it exists

Basic usage with HTML export

python -m apps.chatgpt_rag --export-path conversations.html

Basic usage with JSON export

python -m apps.claude_rag --export-path my_claude_conversations.json

Usage Examples

```bash

Example output:

Set environment variables (adjust VCPKG_ROOT to your vcpkg path)

$env:CMAKE_PREFIX_PATH = "$env:VCPKG_ROOT\installed\x64-windows" $env:PKG_CONFIG_PATH = "$env:VCPKG_ROOT\installed\x64-windows\lib\pkgconfig" $env:PKG_CONFIG_EXECUTABLE = "C:\ProgramData\chocolatey\bin\pkg-config.exe" $env:OPENBLAS_LIB = "$env:VCPKG_ROOT\installed\x64-windows\lib\openblas.lib" $env:PATH += ";$env:VCPKG_ROOT\installed\x64-windows\bin" $env:PATH += ";$env:VCPKG_ROOT\installed\x64-windows\tools\protobuf"

uv sync --extra diskann ```

</details>

⭐ Flexible Configuration

LEANN provides flexible parameters for embedding models, search strategies, and data processing to fit your specific needs.

📚 Need configuration best practices? Check our Configuration Guide for detailed optimization tips, model selection advice, and solutions to common issues like slow embeddings or poor search quality.

<details> <summary><strong>📋 Click to expand: Common Parameters (Available in All Examples)</strong></summary>

All 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.

```bash

Environment Variables (GPU Device Selection)

LEANN_EMBEDDING_DEVICE # GPU for embedding model (e.g., cuda:0, cuda:1, cpu) LEANN_LLM_DEVICE # GPU for HFChat LLM (e.g., cuda:1, or "cuda" for multi-GPU auto)

Now you can use leann from anywhere without activating venv

leann --help ```

Note: Global installation is required for Claude Code integration. The leann_mcp server depends on the globally available leann command.

Command Line Interface

LEANN includes a powerful CLI for document processing and search. Perfect for quick document indexing and interactive chat.

- Supports both CLI and app-created indexes

```

</details>

MCP Integration: RAG on Live Data from Any Platform

Connect 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.

Key Benefits: - Live Data Access: Fetch real-time data without manual exports - Standardized Protocol: Use any MCP-compatible server - Easy Extension: Add new platforms with minimal code - Secure Access: MCP servers handle authentication

💬 Slack Messages: Search Your Team Conversations

Transform your Slack workspace into a searchable knowledge base! Find discussions, decisions, and shared knowledge across all your channels.

```bash

🚀 Claude Code Integration: Transform Your Development Workflow!

<details> <summary><strong>AST‑Aware Code Chunking</strong></summary>

LEANN 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.

📖 Read the AST Chunking Guide →

</details>

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.

Key features: - 🔍 Semantic code search across your entire project, fully local index and lightweight - 🧠 AST-aware chunking preserves code structure (functions, classes) - 📚 Context-aware assistance for debugging and development - 🚀 Zero-config setup with automatic language detection

```bash

Compares the current file system state against the last checkpoint (Merkle tree snapshot)

- Each subsequent run compares against the most recent checkpoint

📊 Storage Comparison

SystemDPR (2.1M)Wiki (60M)Chat (400K)Email (780K)Browser (38K)
Traditional vector database (e.g., FAISS)3.8 GB201 GB1.8 GB2.4 GB130 MB
LEANN324 MB6 GB64 MB79 MB6.4 MB
Savings91%97%97%97%95%

Interactive Q&A

python -m apps.colqwen_rag ask research_papers --interactive


<details>
<summary><strong>📋 Click to expand: ColQwen Setup & Usage</strong></summary>

#### Prerequisites
bash

Ask a single question (non-interactive)

leann ask my-docs "Where are prompts configured?"

❓ [FAQ →](docs/faq.md)

🇨🇳 中文文档镜像 AI 翻译 2026-05-23
英文原文章节由系统翻译为中文摘要,便于快速理解。完整原文见上方 "📑 README 深度解析"。
📌 简介

LEANN 是一个基于 AI 的文本处理框架,提供了高级文本分析和生成能力。它支持多种语言模型和搜索策略,能够处理大规模文本数据。

⚡ 功能介绍

LEANN 提供了多种高级功能,包括详细的特性列表、文本分析和生成能力、支持多种语言模型和搜索策略等。

📋 环境依赖

LEANN 需要安装 uv、C++ 依赖项(通过 vcpkg 安装)和其他依赖项(通过 pip 安装)。

🛠 安装步骤(Docker/pip/源码)

LEANN 可以通过多种方式安装,包括从源码克隆、通过 pip 安装、通过 Docker 安装等。

🚀 使用教程

LEANN 的使用教程包括如何使用 CLI、如何配置环境变量、如何使用 API 等。

⚙️ 配置说明(含 MCP / env)

LEANN 提供了多种配置选项,包括环境变量、MCP 集成、关键参数等。用户可以根据自己的需求进行配置。

🔌 API 说明

LEANN 的 API 提供了多种功能,包括文本分析和生成能力、搜索策略等。用户可以通过 API 来调用这些功能。

🔄 工作流/模块

LEANN 的工作流包括多种模块,包括文本分析和生成能力、搜索策略等。用户可以根据自己的需求来选择和配置这些模块。

❓ FAQ 摘要

LEANN 的 FAQ 提供了常见问题和答案,帮助用户解决问题。

🎯 aiskill88 AI 点评 A 级 2026-05-21

LEANN在RAG领域创新显著,存储优化技术突出,11k星标认可度高。架构完整,易用性强,是现阶段值得关注的开源RAG框架。

📚 实用指南(长尾问题)
适合谁
  • 需要让 Claude / Cursor 操作本地工具的 AI 工程师
  • 构建多智能体协作系统的 Agent 开发者
  • 构建企业知识库 / RAG 检索应用的团队
最佳实践
  • 配置 MCP 服务器时建议使用 stdio 传输 + JSON-RPC,避免暴露公网
  • 本地部署优先选 GGUF 量化模型,节省显存并保持响应速度
  • 分块大小建议 256-512 tokens,向量库优选 pgvector 或 Qdrant
  • Agent 任务先做 dry-run 验证工具调用链,再开启自主执行
常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • MCP 配置路径拼错或权限不足,重启 Claude Desktop 才生效
  • embedding 模型与查询模型不一致导致检索失效
  • 显存不足直接 OOM — 优先降低 context 或换更小的量化模型
  • Python 依赖冲突:建议用 venv / uv 隔离环境
部署方案
  • CLI:直接 npm install -g / pip install,命令行调用
  • 本地部署:CPU 8GB 起,GPU 推荐 16GB+ 显存
  • 云端托管:可放在 Vercel / Railway / Fly.io 等 PaaS 平台
相关搜索
LEANN 中文教程LEANN 安装报错怎么办LEANN MCP 配置LEANN Agent 工作流LEANN 与同类工具对比LEANN 最佳实践LEANN 适合谁用
⚡ 核心功能
👥 适合谁
  • 需要让 Claude / Cursor 操作本地工具的 AI 工程师
  • 构建多智能体协作系统的 Agent 开发者
  • 构建企业知识库 / RAG 检索应用的团队
⭐ 最佳实践
  • 配置 MCP 服务器时建议使用 stdio 传输 + JSON-RPC,避免暴露公网
  • 本地部署优先选 GGUF 量化模型,节省显存并保持响应速度
  • 分块大小建议 256-512 tokens,向量库优选 pgvector 或 Qdrant
  • Agent 任务先做 dry-run 验证工具调用链,再开启自主执行
⚠️ 常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • MCP 配置路径拼错或权限不足,重启 Claude Desktop 才生效
  • embedding 模型与查询模型不一致导致检索失效
  • 显存不足直接 OOM — 优先降低 context 或换更小的量化模型
👥 适合人群
AI 技术爱好者研究人员和学生开发者和工程师技术创业者
🎯 使用场景
  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发
⚖️ 优点与不足
✅ 优点
  • +GitHub 11.0k Star,社区高度认可
  • +MIT 协议,可免费商用
  • +完全开源免费,无授权费用
  • +本地部署,数据完全自主可控
  • +开发者社区支持,遇问题可查可问
⚠️ 不足
  • 安装和初始配置可能需要一定技术基础
  • 功能完整性通常不如成熟商业产品
  • 技术支持主要依赖开源社区,响应速度不稳定
⚠️ 使用须知

AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。

建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。

📄 License 说明

✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。

🔗 相关工具推荐
📰 相关 AI 新闻
🍿 AI 圈相关吃瓜
🗺️ 相关解决方案
🧩 你可能还需要
基于当前 Skill 的能力图谱,自动补全的工具组合
❓ 常见问题 FAQ
采用向量压缩、量化、索引优化等技术减少嵌入向量和索引占用空间。
💡 AI Skill Hub 点评

AI Skill Hub 点评:LEANN AI技能包 的核心功能完整,质量优秀。对于AI 技术爱好者来说,这是一个值得纳入个人工具库的选择。建议先在非生产环境试用,再逐步推广。

📚 深入学习 LEANN AI技能包
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 LEANN
原始描述 开源AI工具:MLsys2026: RAG on Everything with LEANN. Enjoy 97% storage savings while running。⭐11.0k · Python
Topics RAG检索增强向量数据库存储优化LangChain
GitHub https://github.com/yichuan-w/LEANN
License MIT
语言 Python
🔗 原始来源
🐙 GitHub 仓库  https://github.com/yichuan-w/LEANN 🌐 官方网站  https://arxiv.org/abs/2506.08276

收录时间:2026-05-14 · 更新时间:2026-05-16 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。