Token导航 LogoToken导航

Agent Skill · 研究检索

leann(leann 搜索)

leann 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

leann 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为调用外部服务;许可证为 MIT,暂无第三方扫描结果,按安装量在研究检索类的 73,675 个 Skill 里排第 62,001。

总安装 343周安装 14GitHub Stars 公开资料未说明下载 110核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:leann(leann 搜索)
来源仓库:https://github.com/zpankz/mcp-skillset
仓库路径:skills/leann
安装命令:
npx skills add zpankz/mcp-skillset --skill "leann"
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

AgentSkills.tonpx skills
npx skills add zpankz/mcp-skillset --skill "leann"

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于快速查找、检索和筛选相关信息。leann 属于研究检索类 Skill,可作为该场景下的辅助能力补充。适合根据关键词或任务场景定位候选结果。可结合来源仓库和原始 README 核验具体用法。安装命令:npx skills add zpankz/mcp-skillset --skill "leann"。

建议确认权限范围及是否涉及联网或文件读写。

来源仓库内路径:skills/leann

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add zpankz/mcp-skillset --skill "leann";命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要调用外部服务,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

leann 怎么安装?

在终端执行 npx skills add zpankz/mcp-skillset --skill "leann"。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

leann 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

leann 需要什么权限?

权限级别是调用外部服务。该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

leann 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

leann 用的人多吗?

公开数据是累计安装 343 次,近一周安装 14 次,下载 110 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

leann 安全吗?

没有查到第三方扫描结果,安全性无法从公开资料判断,安装前请自行审查源码、依赖和命令行为。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 没有第三方扫描结果,安全性只能靠自己读源码判断。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 要求有安全扫描结论才肯安装的团队。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
leann

leann 搜索 · 本页

343—调用外部服务MIT未收录

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

name
leann
description
Local RAG indexing with 97% storage reduction via anchor-based lazy recomputation. Graph-based selective embedding storage for memory-efficient semantic code search.
version
1.0.0
triggers
tags
[rag, vector-search, graph, compression, local-first, semantic-search]

LEANN Skill

LEANN (Learned Embedding ANchor Navigation) - A graph-based selective recomputation system achieving 97% storage reduction for local RAG indexes while maintaining fast retrieval performance.


Core Principle

Use leann for persistent local code indexes with minimal storage overhead.

Instead of storing all embeddings at full precision (3 GB for 1M files), leann stores only strategic anchors and reconstructs others on-demand (128 MB for same dataset - 95.8% reduction).


When to Use LEANN

Primary Use Cases

1. Large Codebase Indexing (10K+ files)

  • Monorepos with multiple services
  • Enterprise codebases that exceed vector database free tiers
  • Projects requiring fast local semantic search without cloud dependencies

2. Memory-Constrained Environments

  • Development machines with limited RAM
  • CI/CD pipelines needing index validation
  • Edge deployments or air-gapped systems

3. Cost-Sensitive RAG Applications

  • Avoiding Pinecone/Weaviate monthly costs
  • Self-hosted vector search with minimal infrastructure
  • Batch processing of large document collections

4. Real-Time Code Navigation

  • IDE integrations for semantic code search
  • Developer tools needing instant relevance feedback
  • Documentation search within editors

When NOT to Use LEANN

Use traditional vector DBs instead when:

  • Dataset is small (<1K items) - overhead not worth it
  • Cloud infrastructure is required (multi-tenant, global CDN)
  • Need advanced features (hybrid search, filtering, multi-tenancy)
  • Absolute lowest latency required (<5ms) - leann trades latency for storage

Architecture Overview

Two-Stage Query Process

Query → [Stage 1: Anchor Graph Search] → [Stage 2: Lazy Reconstruction] → Results

Stage 1: Fast HNSW/DiskANN traversal (1-5ms)
Stage 2: Reconstruct top candidates (5-25ms)
Total: 10-30ms (HNSW) or 50-200ms (DiskANN)

Storage Model

Naive:  N × D × 4 bytes (full embeddings)
LEANN:  M × D × 4 + N × (D / 8) bytes (anchors + compressed deltas)

Example (100K files, 768 dims):
Naive:  100,000 × 768 × 4     = 307 MB
LEANN:  1,000 × 768 × 4       = 3 MB (anchors)
        100,000 × 96          = 9.6 MB (deltas)
        Total                 ≈ 12.6 MB (95.9% reduction)

Key Components

  1. Anchor Graph: HNSW (in-memory) or DiskANN (disk-based) graph of anchor embeddings
  2. Product Quantization: Compress delta vectors (delta = embedding - anchor)
  3. ZMQ Embedding Server: GPU-accelerated embedding generation
  4. Delta Index: Incremental updates without full rebuild

Quick Start

1. Installation

# Via pip
pip install leann

# Via conda
conda install -c conda-forge leann

# From source
git clone https://github.com/leann-index/leann.git
cd leann && pip install -e .

2. Start Embedding Server

# Docker (recommended - GPU support)
docker run -d \
  --name leann-embeddings \
  --gpus all \
  -p 5555:5555 \
  -e MODEL=sentence-transformers/all-MiniLM-L6-v2 \
  leann/embedding-server:latest

# Python script (alternative)
python -m leann.server \
  --model sentence-transformers/all-MiniLM-L6-v2 \
  --port 5555 \
  --device cuda

3. Create Index

# Basic indexing
leann index create \
  --input /path/to/codebase \
  --output ./leann.index \
  --config leann.config.json

# With progress tracking
leann index create \
  --input /path/to/codebase \
  --output ./leann.index \
  --progress \
  --verbose

4. Query Index

# CLI query
leann query \
  --index ./leann.index \
  --query "JWT authentication middleware" \
  --top-k 10

# Watch mode (live updates)
leann serve \
  --index ./leann.index \
  --watch \
  --port 8080

Configuration

Minimal Configuration

{
  "backend": "hnsw",
  "complexity": "medium",
  "anchorSelection": {
    "type": "kmeans",
    "clusters": 300
  },
  "quantization": {
    "subVectors": 96,
    "codebookSize": 256
  },
  "embeddingServer": {
    "endpoint": "tcp://localhost:5555",
    "model": "sentence-transformers/all-MiniLM-L6-v2",
    "batchSize": 128,
    "timeout": 30000
  }
}

Production Configuration

{
  "backend": "hnsw",
  "complexity": "high",
  "anchorSelection": {
    "type": "kmeans",
    "clusters": 1000,
    "samples": 20000
  },
  "quantization": {
    "subVectors": 96,
    "codebookSize": 256,
    "trainingSamples": 50000
  },
  "embeddingServer": {
    "endpoint": "tcp://localhost:5555",
    "model": "sentence-transformers/all-MiniLM-L6-v2",
    "batchSize": 256,
    "timeout": 60000
  },
  "incremental": {
    "enabled": true,
    "deltaIndexThreshold": 1000,
    "rebuildSchedule": "0 2 * * *"
  },
  "hnsw": {
    "M": 32,
    "efConstruction": 400,
    "efSearch": 200
  }
}

Configuration Parameters

Backend Selection

backend: "hnsw" (In-Memory)

  • Use when index fits in RAM
  • Query latency: 10-30ms
  • Suitable for: <1M files, <50K anchors

backend: "diskann" (Disk-Based)

  • Use when index exceeds RAM
  • Query latency: 50-200ms
  • Suitable for: 1M+ files, massive monorepos
Complexity Levels
LevelMefConstructionefSearchBuild TimeAccuracy
low1210050FastGood
medium16200100ModerateBetter
high32400200SlowBest
Anchor Selection Strategies

1. Random (Fastest)

{
  "type": "random",
  "count": 300
}
  • Speed: O(N)
  • Quality: Acceptable for homogeneous codebases
  • Use when: Prototyping or single-language projects

2. K-Means (Recommended)

{
  "type": "kmeans",
  "clusters": 300,
  "samples": 10000
}
  • Speed: O(N × k × iterations)
  • Quality: Excellent coverage
  • Use when: Production deployments (default)

3. Max-Coverage (Best Quality)

{
  "type": "max-coverage",
  "count": 300,
  "diversityThreshold": 0.2
}
  • Speed: O(N × M²)
  • Quality: Best for sparse distributions
  • Use when: High-value outliers must be findable

Common Workflows

Workflow 1: Initial Indexing

# 1. Discover codebase
find /path/to/codebase -type f \( -name "*.py" -o -name "*.ts" \) | wc -l
# Output: 15,000 files

# 2. Calculate recommended anchors
# Rule: M = √N → √15000 ≈ 122 → recommend 300 for better coverage

# 3. Create config
cat > leann.config.json <<EOF
{
  "backend": "hnsw",
  "complexity": "medium",
  "anchorSelection": {
    "type": "kmeans",
    "clusters": 300,
    "samples": 5000
  },
  "quantization": {
    "subVectors": 96,
    "codebookSize": 256
  },
  "embeddingServer": {
    "endpoint": "tcp://localhost:5555",
    "model": "sentence-transformers/all-MiniLM-L6-v2",
    "batchSize": 128,
    "timeout": 30000
  }
}
EOF

# 4. Build index
leann index create \
  --config leann.config.json \
  --input /path/to/codebase \
  --output ./leann.index \
  --progress

# 5. Validate
leann index validate ./leann.index

# 6. Test query
leann query \
  --index ./leann.index \
  --query "database connection pooling" \
  --top-k 5

Workflow 2: CI/CD Integration

# .github/workflows/update-index.yml
name: Update LEANN Index

on:
  push:
    branches: [main]
  schedule:
    - cron: '0 2 * * 0'  # Weekly full rebuild

jobs:
  update-index:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Setup LEANN
        run: |
          pip install leann
          docker run -d -p 5555:5555 leann/embedding-server:latest

      - name: Incremental Update
        run: |
          leann index update \
            --index ./leann.index \
            --git-diff origin/main HEAD \
            --output ./leann-updated.index

      - name: Validate Index
        run: |
          leann index validate ./leann-updated.index
          if [ $? -ne 0 ]; then
            # Validation failed - trigger full rebuild
            leann index create \
              --config leann.config.json \
              --input . \
              --output ./leann-updated.index
          fi

      - name: Upload Artifact
        uses: actions/upload-artifact@v3
        with:
          name: leann-index
          path: ./leann-updated.index

Workflow 3: IDE Integration

# VS Code extension example
from leann import LEANNIndex

class SemanticSearchProvider:
    def __init__(self, index_path):
        self.index = LEANNIndex.load(index_path)

    def search(self, query, top_k=10):
        results = self.index.query(
            query=query,
            top_k=top_k,
            mode='retrieve',
            filters={'languages': ['python', 'typescript']}
        )
        return [
            {
                'path': item.item.path,
                'score': item.score,
                'preview': self._get_preview(item.item)
            }
            for item in results.items
        ]

Workflow 4: Polyglot Codebase

{
  "backend": "hnsw",
  "complexity": "medium",
  "anchorSelection": {
    "type": "stratified-kmeans",
    "totalClusters": 500,
    "stratification": {
      "enabled": true,
      "groupBy": "language",
      "minPerGroup": 20,
      "allocation": "proportional"
    }
  },
  "filters": {
    "languages": ["python", "typescript", "go", "rust"],
    "excludePaths": ["node_modules/", "__pycache__/", "vendor/", "target/"]
  }
}

Benefit: Ensures each language gets proportional representation in anchors, preventing Python from dominating a Python/TypeScript/Go codebase.


Performance Tuning

Query Latency Optimization

Problem: Queries taking >50ms

Diagnosis:

leann index stats ./leann.index

# Check:
# - Avg candidates evaluated (should be <1000)
# - efSearch parameter (default: 100)

Solutions:

  1. Reduce efSearch (faster, lower recall)
{
  "hnsw": {
    "efSearch": 50
  }
}
  1. Increase anchor count (more memory, better coverage)
leann index rebuild \
  --index ./leann.index \
  --new-anchor-count 1000 \
  --output ./leann-improved.index
  1. Use early termination
leann query \
  --index ./leann.index \
  --query "authentication" \
  --top-k 10 \
  --early-terminate \
  --confidence-threshold 0.9

Storage Optimization

Problem: Index larger than expected

Diagnosis:

leann index stats ./leann.index

# Check:
# - Anchor count (should be ~√N)
# - PQ configuration (96 subvectors × 256 codebook is standard)

Solutions:

  1. Reduce anchor count (lower quality, less storage)
{
  "anchorSelection": {
    "clusters": 100  // Reduced from 300
  }
}
  1. Increase PQ compression (lower quality, less storage)
{
  "quantization": {
    "subVectors": 128,  // More aggressive compression
    "codebookSize": 128
  }
}

Accuracy Improvement

Problem: Poor retrieval relevance

Diagnosis:

leann index validate ./leann.index --verbose

# Check:
# - Coverage score (target: >0.80)
# - Quantization error (target: <0.05)

Solutions:

  1. Increase anchor count
leann index rebuild \
  --index ./leann.index \
  --new-anchor-count 1000 \
  --output ./leann-improved.index
  1. Use k-means selection (better than random)
{
  "anchorSelection": {
    "type": "kmeans",  // Changed from "random"
    "clusters": 500
  }
}
  1. Enable re-ranking with cross-encoder
leann query \
  --index ./leann.index \
  --query "authentication middleware" \
  --mode rerank \
  --top-k 10

Monitoring & Health

Key Metrics

1. Coverage Score (target: >0.80)

leann index validate ./leann.index --metric coverage

Measures how uniformly anchors cover embedding space.

2. Quantization Error (target: <0.05)

leann index validate ./leann.index --metric quantization

Measures average reconstruction error from PQ compression.

3. Utilization Balance (target: >0.70)

leann index validate ./leann.index --metric balance

Checks if anchors are evenly utilized (no overloaded anchors).

Rebuild Triggers

Automatic rebuild when:

  • Coverage score drops below 0.70
  • Delta index exceeds threshold (default: 10% of main index)
  • Query latency degrades >30% from baseline
  • Manual trigger: leann index rebuild

Health Check Script

#!/bin/bash
# scripts/index-validator.sh

INDEX="./leann.index"

echo "LEANN Index Health Check"
echo "========================"

# Check coverage
COVERAGE=$(leann index validate $INDEX --metric coverage --json | jq -r '.score')
echo "Coverage: $COVERAGE (target: >0.80)"

# Check quantization error
QUANT_ERROR=$(leann index validate $INDEX --metric quantization --json | jq -r '.error')
echo "Quantization Error: $QUANT_ERROR (target: <0.05)"

# Check balance
BALANCE=$(leann index validate $INDEX --metric balance --json | jq -r '.score')
echo "Balance: $BALANCE (target: >0.70)"

# Check delta index size
DELTA_SIZE=$(leann index stats $INDEX --json | jq -r '.deltaIndexSize')
MAIN_SIZE=$(leann index stats $INDEX --json | jq -r '.mainIndexSize')
DELTA_RATIO=$(echo "scale=2; $DELTA_SIZE / $MAIN_SIZE * 100" | bc)
echo "Delta Index: $DELTA_RATIO% of main (rebuild at 10%)"

# Recommend actions
if (( $(echo "$COVERAGE < 0.70" | bc -l) )); then
  echo "⚠️  WARNING: Coverage too low - consider rebuilding with more anchors"
fi

if (( $(echo "$QUANT_ERROR > 0.05" | bc -l) )); then
  echo "⚠️  WARNING: High quantization error - consider reducing PQ compression"
fi

if (( $(echo "$DELTA_RATIO > 10" | bc -l) )); then
  echo "⚠️  WARNING: Delta index large - recommend full rebuild"
fi

Integration Patterns

Pattern 1: Python API

from leann import LEANNIndex, QueryRequest

# Load index
index = LEANNIndex.load('./leann.index')

# Basic query
results = index.query(
    query="database connection pooling",
    top_k=10,
    mode='retrieve'
)

for item in results.items:
    print(f"{item.item.path} (score: {item.score:.2f})")
    print(f"  {item.preview}\n")

# Query with filters
results = index.query(
    query="authentication middleware",
    top_k=5,
    filters={
        'languages': ['typescript'],
        'paths': ['src/middleware/*.ts']
    }
)

# Batch queries
queries = [
    "JWT authentication",
    "database migration",
    "error handling"
]
results_batch = index.batch_query(queries, top_k=5)

Pattern 2: REST API

from fastapi import FastAPI
from leann import LEANNIndex

app = FastAPI()
index = LEANNIndex.load('./leann.index')

@app.post('/search')
async def search(query: str, top_k: int = 10):
    results = index.query(query=query, top_k=top_k)
    return {
        'results': [
            {
                'path': item.item.path,
                'score': item.score,
                'preview': item.preview
            }
            for item in results.items
        ],
        'latency': results.latency
    }

@app.get('/health')
async def health():
    stats = index.get_stats()
    return {
        'status': 'healthy' if stats.healthScore > 70 else 'degraded',
        'healthScore': stats.healthScore,
        'indexSize': stats.storageSize,
        'avgLatency': stats.avgLatency
    }

Pattern 3: CLI Tool

#!/bin/bash
# Wrapper script for common queries

function search() {
  leann query \
    --index ~/.cache/leann/project.index \
    --query "$1" \
    --top-k "${2:-10}" \
    --format json | jq -r '.items[] | "\(.item.path):\(.item.startLine)"'
}

function update-index() {
  leann index update \
    --index ~/.cache/leann/project.index \
    --watch \
    --auto-rebuild
}

# Usage:
# search "database connection" 5
# update-index

Troubleshooting

Issue: Out of Memory During Indexing

Error:

Cannot allocate memory for k-means clustering

Solution: Reduce sampling in anchor selection:

{
  "anchorSelection": {
    "type": "kmeans",
    "clusters": 300,
    "samples": 5000  // Reduced from 10000
  }
}

Issue: Embedding Server Connection Failed

Error:

Connection refused: tcp://localhost:5555

Solution:

# Check if server is running
docker ps | grep leann-embeddings

# If not, start it
docker run -d -p 5555:5555 leann/embedding-server:latest

# Test connection
curl http://localhost:5555/health

Issue: Low Query Accuracy

Error:

Results not relevant to query

Diagnosis:

leann index validate ./leann.index --verbose
# Check coverage score and quantization error

Solution:

# Rebuild with more anchors and k-means selection
leann index rebuild \
  --index ./leann.index \
  --anchor-strategy kmeans \
  --anchor-count 1000 \
  --output ./leann-improved.index

Resources

Codebase Documentation:

  • Type definitions: @architect/leann-codebase/types/core.ts
  • Anchor selection principles: @architect/leann-codebase/principles/anchor-selection.md
  • Graph navigation: @architect/leann-codebase/principles/graph-navigation.md
  • Indexing workflows: @architect/leann-codebase/templates/indexing-workflow.md

References:

  • Quick commands: @architect/leann/assets/cheatsheet.md
  • Indexing patterns: @architect/leann/references/indexing-patterns.md
  • Configuration guide: @architect/leann/references/configuration.md

External:

  • GitHub: https://github.com/leann-index/leann
  • Documentation: https://leann-index.github.io
  • Paper: "LEANN: Learned Embedding Anchor Navigation"

Summary

Core Value Proposition:

  • 97% storage reduction vs traditional vector databases
  • 10-30ms query latency (local, no network overhead)
  • Zero cloud costs (self-hosted)
  • Incremental updates (no nightly rebuilds)

Best For:

  • Large codebases (10K+ files)
  • Memory-constrained environments
  • Cost-sensitive RAG applications
  • Local-first semantic search

Decision Tree:

Need semantic code search?
├─ Dataset < 1K items → Use simple vector DB (overhead not worth it)
└─ Dataset > 1K items
    ├─ Cloud infrastructure required → Use Pinecone/Weaviate
    └─ Local-first / cost-sensitive → Use LEANN
        ├─ Index < RAM → HNSW backend (10-30ms)
        └─ Index > RAM → DiskANN backend (50-200ms)

Golden Rules:

  1. Start with medium complexity, increase only if needed
  2. Use k-means anchor selection for production
  3. Monitor coverage score - rebuild if <0.70
  4. Enable incremental updates for CI/CD
  5. Use re-ranking for user-facing search

平台分布

OpenCode

31.36%
按下载量换算34

Claude Code

24.96%
按下载量换算27

windsurf

17.96%
按下载量换算20

Codex

11.68%
按下载量换算13

kiro-cli

7.73%
按下载量换算9

mcpjam

3.49%
按下载量换算4

安全审计

暂无安全审计结果可展示。

权限和风险

调用外部服务

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills