Skip to content

LightRAG


LightRAG 介绍

Simple and Fast Retrieval-Augmented Generation

\


性能评测

Agriculture CS Legal Mix
NaiveRAG LightRAG NaiveRAG LightRAG NaiveRAG LightRAG NaiveRAG LightRAG
Comprehensiveness 32.4% 67.6% 38.4% 61.6% 16.4% 83.6% 38.8% 61.2%
Diversity 23.6% 76.4% 38.0% 62.0% 13.6% 86.4% 32.4% 67.6%
Empowerment 32.4% 67.6% 38.8% 61.2% 16.4% 83.6% 42.8% 57.2%
Overall 32.4% 67.6% 38.8% 61.2% 15.2% 84.8% 40.0% 60.0%
RQ-RAG LightRAG RQ-RAG LightRAG RQ-RAG LightRAG RQ-RAG LightRAG
Comprehensiveness 31.6% 68.4% 38.8% 61.2% 15.2% 84.8% 39.2% 60.8%
Diversity 29.2% 70.8% 39.2% 60.8% 11.6% 88.4% 30.8% 69.2%
Empowerment 31.6% 68.4% 36.4% 63.6% 15.2% 84.8% 42.4% 57.6%
Overall 32.4% 67.6% 38.0% 62.0% 14.4% 85.6% 40.0% 60.0%
HyDE LightRAG HyDE LightRAG HyDE LightRAG HyDE LightRAG
Comprehensiveness 26.0% 74.0% 41.6% 58.4% 26.8% 73.2% 40.4% 59.6%
Diversity 24.0% 76.0% 38.8% 61.2% 20.0% 80.0% 32.4% 67.6%
Empowerment 25.2% 74.8% 40.8% 59.2% 26.0% 74.0% 46.0% 54.0%
Overall 24.8% 75.2% 41.6% 58.4% 26.4% 73.6% 42.4% 57.6%
GraphRAG LightRAG GraphRAG LightRAG GraphRAG LightRAG GraphRAG LightRAG
Comprehensiveness 45.6% 54.4% 48.4% 51.6% 48.4% 51.6% 50.4% 49.6%
Diversity 22.8% 77.2% 40.8% 59.2% 26.4% 73.6% 36.0% 64.0%
Empowerment 41.2% 58.8% 45.2% 54.8% 43.6% 56.4% 50.8% 49.2%
Overall 45.2% 54.8% 48.0% 52.0% 47.2% 52.8% 50.4% 49.6%

安装

git clone https://github.com/HKUDS/LightRAG.git
cd LightRAG

# Using uv (recommended)
# Note: uv sync automatically creates a virtual environment in .venv/
uv sync --extra api
source .venv/bin/activate  # Activate the virtual environment (Linux/macOS)
# Or on Windows: .venv\Scripts\activate

### Or using pip with virtual environment
# python -m venv .venv
### source .venv/bin/activate  # Windows: .venv\Scripts\activate
# pip install -e ".[api]"

# Build front-end artifacts
cd lightrag_webui
bun install --frozen-lockfile
bun run build
cd ..

# setup env file
cp env.example .env  # Update the .env with your LLM and embedding configurations
# Launch API-WebUI server
lightrag-server

Docker 启动

cd LightRAG
cp env.example .env  # Update the .env with your LLM and embedding configurations
# modify LLM and Embedding settings in .env
docker compose up

初始化配置与启动脚本

  • 大模型配置
  • 嵌入模型配置
  • 向量存储配置
  • 图数据配置,默认 networkx
  • 系统参数配置
# 大模型配置
export LLM_MODEL=gpt-5-mini
export LLM_BINDING_HOST=$OPENAI_BASE_URL
export LLM_BINDING_API_KEY=$OPENAI_API_KEY

#export OPENAI_LLM_REASONING_EFFORT=minimal

# 嵌入模型配置
export EMBEDDING_BINDING_HOST=$OPENAI_BASE_URL
export EMBEDDING_BINDING_API_KEY=$OPENAI_API_KEY

# 知识图谱配置
export LIGHTRAG_GRAPH_STORAGE=Neo4JStorage

export NEO4J_URI=neo4j://127.0.0.1:7687
export NEO4J_USERNAME=neo4j
export NEO4J_PASSWORD=ceshiren.com
export NEO4J_DATABASE=neo4j

# 日志
export LOG_LEVEL=DEBUG
export VERBOSE=True


# 清理数据
# rm -rf inputs rag_storage

lightrag-server --verbose

启动

(LightRAG) seveniruby-mac:LightRAG seveniruby$ bash env_openai.sh

LightRAG log file: /Users/seveniruby/projects/LightRAG/lightrag.log

WARNING:root:>> Forcing workers=1 in uvicorn mode(Ignoring workers=2)

    ╔══════════════════════════════════════════════════════════════╗
                    LightRAG Server v1.4.9.9/0262                              Fast, Lightweight RAG Server Implementation              ╚══════════════════════════════════════════════════════════════╝


📡 Server Configuration:
    ├─ Host: 0.0.0.0
    ├─ Port: 9621
    ├─ Workers: 1
    ├─ Timeout: 300
    ├─ CORS Origins: *
    ├─ SSL Enabled: False
    ├─ Ollama Emulating Model: lightrag:latest
    ├─ Log Level: DEBUG
    ├─ Verbose Debug: True
    ├─ API Key: Not Set
    └─ JWT Auth: Disabled

📂 Directory Configuration:
    ├─ Working Directory: /Users/seveniruby/projects/LightRAG/rag_storage
    └─ Input Directory: /Users/seveniruby/projects/LightRAG/inputs

🤖 LLM Configuration:
    ├─ Binding: openai
    ├─ Host: http://127.0.0.1:8001/v1
    ├─ Model: gpt-4o
    ├─ Max Async for LLM: 4
    ├─ Summary Context Size: 12000
    ├─ LLM Cache Enabled: True
    └─ LLM Cache for Extraction Enabled: True

📊 Embedding Configuration:
    ├─ Binding: openai
    ├─ Host: http://127.0.0.1:8001/v1
    ├─ Model: text-embedding-3-large
    └─ Dimensions: 3072

⚙️ RAG Configuration:
    ├─ Summary Language: English
    ├─ Entity Types: ['Person', 'Creature', 'Organization', 'Location', 'Event', 'Concept', 'Method', 'Content', 'Data', 'Artifact', 'NaturalObject']
    ├─ Max Parallel Insert: 2
    ├─ Chunk Size: 1200
    ├─ Chunk Overlap Size: 100
    ├─ Cosine Threshold: 0.2
    ├─ Top-K: 40
    └─ Force LLM Summary on Merge: 8

💾 Storage Configuration:
    ├─ KV Storage: JsonKVStorage
    ├─ Vector Storage: NanoVectorDBStorage
    ├─ Graph Storage: Neo4JStorage
    ├─ Document Status Storage: JsonDocStatusStorage
    └─ Workspace: -

✨ Server starting up...


🌐 Server Access Information:
    ├─ WebUI (local): http://localhost:9621
    ├─ Remote Access: http://<your-ip-address>:9621
    ├─ API Documentation (local): http://localhost:9621/docs
    └─ Alternative Documentation (local): http://localhost:9621/redoc

📝 Note:
    Since the server is running on 0.0.0.0:
    - Use 'localhost' or '127.0.0.1' for local access
    - Use your machine's IP address for remote access
    - To find your IP address:
      • Windows: Run 'ipconfig' in terminal
      • Linux/Mac: Run 'ifconfig' or 'ip addr' in terminal

快速开始


知识库上传


知识图谱


知识图谱数据


LightRAG 检索


工具调用


API


智能体对接

  • HTTP 协议的自定义工具对接
  • 面向智能体封装 MCP Skills
  • 编程 SDK