Skip to content

LightRAG

Serve layer · HKUDS/LightRAG · README (zh)

LightRAG is a simple, fast Retrieval-Augmented Generation framework with a dual-layer architecture managing both knowledge graphs (KG) and vector embeddings. Suited for legal, medical, financial document analysis; an efficient alternative to GraphRAG.

Key Features

CapabilityDescription
Deep contextGraph indexing captures semantic dependencies between entities
Dual-level retrievalCombines detailed facts and abstract concepts
Efficient & low-costFewer LLM calls during index and query
Incremental updatesNew data merges into existing graph without full rebuild
Multimodal (v1.5+)MinerU / Docling for PDF, images, tables, formulas

Query Modes

ModeUse
localLocal entities and direct attributes
globalMacro topics, cross-document relations
hybridlocal + global (workflow P0 default)
naiveVector chunks only, no KG
mixFull fusion (LightRAG server default)

Workflow

P0 query_text uses mode: hybrid, only_need_context: true. See MCP Tools · LightRAG.

Installation

bash
curl -LsSf https://astral.sh/uv/install.sh | sh
uv tool install "lightrag-hku[api]"

From source

bash
git clone https://github.com/HKUDS/LightRAG.git
cd LightRAG && make dev && source .venv/bin/activate
cd lightrag_webui && bun install --frozen-lockfile && bun run build && cd ..
make env-base
lightrag-server

Docker Compose

bash
git clone https://github.com/HKUDS/LightRAG.git
cd LightRAG && cp env.example .env && docker compose up

Key Configuration

  • Four LLM roles: EXTRACT, QUERY, KEYWORDS, VLM — configure per role
  • Embedding: Must be fixed before indexing; cannot change at query time; recommend BAAI/bge-m3 locally
  • Rerank: Improves quality; adds ~1–2s; deploy locally when possible

Team Deployment

ComponentPathNotes
LightRAG APIProject/LightRAGlightrag-server, default http://127.0.0.1:9621
daniel-lightrag-mcpProject/daniel-lightrag-mcpMCP bridge, 22 tools
Start scriptStartScript/MCP_LightRAG_start.shHTTP bridge, port 9622
bash
cd Project/LightRAG && lightrag-server
bash StartScript/MCP_LightRAG_start.sh
json
{ "daniel-lightrag": { "url": "http://127.0.0.1:9622/mcp/" } }