LightRAG README

The project's README from github.com/HKUDS/LightRAG. As one markdown file: README.md.

LightRAG Logo

🚀 LightRAG: Simple and Fast Retrieval-Augmented Generation

GitHub Trending Repository of the Day HKUDS/LightRAG | Trendshift Star History Rank

Selected organizations among the 304 identified from self-reported LightRAG stargazer affiliations on GitHub on November 23, 2026. Stars are personal.

LightRAG Diagram

🎉 News

Algorithm Flowchart

LightRAG Indexing Flowchart Figure 1: LightRAG Indexing Flowchart - Img Caption : Source LightRAG Retrieval and Querying Flowchart Figure 2: LightRAG Retrieval and Querying Flowchart - Img Caption : Source

Installation

💡 Using uv for Package Management: This project uses uv for fast and reliable Python package management. Install uv first: curl -LsSf https://astral.sh/uv/install.sh | sh (Unix/macOS) or powershell -c "irm https://astral.sh/uv/install.ps1 | iex" (Windows)

Note: You can also use pip if you prefer, but uv is recommended for better performance and more reliable dependency management.

📦 Offline Deployment: For offline or air-gapped environments, see the Offline Deployment Guide for instructions on pre-installing all dependencies and cache files.

[!WARNING] Secure the server before you start it on a shared network. lightrag-server binds to all interfaces (HOST=0.0.0.0) and ships with authentication off, so on a cloud host every endpoint is public — and spends your LLM quota. Before the first start, either bind to a private address in .env (HOST=127.0.0.1, or a VPN / tunnel address), or configure authentication: LIGHTRAG_API_KEY, or AUTH_ACCOUNTS together with TOKEN_SECRET (generate one with openssl rand -hex 32). Once LIGHTRAG_API_KEY is set, the Ollama-compatible /api/* routes require it too (Ollama clients send it as Authorization: Bearer <key>); without a key they stay open for client compatibility. This applies to every installation method below.

Install from PyPI

The PyPI package ships a prebuilt WebUI, so no frontend build is needed.

# Install LightRAG Server as a tool using uv (recommended)
uv tool install "lightrag-hku[api]"

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

# Get the configuration template and edit it (see "Minimum .env Changes" below)
curl -O https://raw.githubusercontent.com/HKUDS/LightRAG/main/env.example
cp env.example .env

lightrag-server

Install from Source

Prerequisites

Tool Used for How to install
git Cloning the repository Your system package manager
uv Virtual environment and Python dependencies. Downloads a suitable Python (3.11+) if the system has none See the uv note above
bun Building the WebUI curl -fsSL https://bun.sh/install | bash (Windows: powershell -c "irm bun.sh/install.ps1 | iex"). The Linux script needs unzip, which minimal Debian / Ubuntu images lack: sudo apt-get install -y unzip
make Optional: the make dev shortcut and the make env-* setup wizard Your system package manager

Step 1 — Clone the repository

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

Step 2 — Install the Python dependencies. Pick one of the two options:

# Option A: just run the server (API + WebUI) — the smallest install
uv sync --extra api
# Option B: contributing — the test toolchain plus every storage backend
# and LLM provider integration
uv sync --extra test --extra offline

uv sync creates the virtual environment in .venv/. Activate it with source .venv/bin/activate (Windows: .venv\Scripts\activate). With pip instead of uv: python -m venv .venv, activate it, then pip install -e ".[api]" (or pip install -e ".[test,offline]").

Step 3 — Build the WebUI

cd lightrag_webui
bun install --frozen-lockfile
bun run build
cd ..

make dev runs Step 2 Option B and Step 3 in one command. If you used it, continue with Step 4.

Step 4 — Create .env. Either run the interactive wizard, make env-base (see Create .env File With Setup Tool), or copy the template and edit it by hand (see Minimum .env Changes):

cp env.example .env

Step 5 — Start the server

lightrag-server

Open http://localhost:9621/webui for the WebUI. The interactive REST API docs are at http://localhost:9621/docs. Replace the host and port if you changed HOST / PORT.

Updating after git pull. Re-sync with the extras you installed in Step 2, plus --locked --inexact. For Option B:

git pull
uv sync --locked --inexact --extra test --extra offline   # Option A: --locked --inexact --extra api

If the pull changed lightrag_webui/, repeat Step 3 as well.

Launch with Docker Compose

git clone https://github.com/HKUDS/LightRAG.git
cd LightRAG
cp env.example .env  # edit it first: see "Minimum .env Changes" below
docker compose up

Historical versions of LightRAG docker images can be found here: LightRAG Docker Images

Official GHCR images published by GitHub Actions are signed with Sigstore Cosign using GitHub OIDC. See docs/DockerDeployment.md for verification commands.

On Apple Silicon (macOS 26) without Docker Desktop, you can run the same Postgres/Neo4j/Milvus storage stack on Apple's native container runtime — see docs/AppleContainerSetup.md.

Minimum .env Changes

env.example works out of the box with local file-based storage, no reranker, and the built-in document parser, so no database or extra service is needed. Only the model settings need attention. With the default OpenAI models:

Variable What to do
LLM_BINDING_API_KEY Required. Set your OpenAI API key
EMBEDDING_BINDING_API_KEY Required. Set your OpenAI API key (it can be the same key)
OPENAI_LLM_REASONING_EFFORT Recommended. Uncomment it and keep low. The default model gpt-6-luna is a reasoning model whose API default effort is medium, which makes entity extraction — one LLM call per text chunk — noticeably slower and more expensive

Using another provider? Also set LLM_BINDING_HOST and LLM_MODEL (keep LLM_BINDING=openai for any OpenAI-compatible API), and EMBEDDING_BINDING_HOST, EMBEDDING_MODEL and EMBEDDING_DIM. EMBEDDING_DIM must equal the embedding model's output dimension. See Key Configuration Guide for model choices.

Settle the embedding model before your first upload. Changing it later means re-indexing every document (see Embedding Models).

Next step: once the server runs, Exploring LightRAG (🇨🇳) walks through enabling the rest, one step at a time and with measured results: PostgreSQL storage, authentication, role-specific LLMs, reranking, image analysis, Word smart headings, MinerU and concurrency tuning.

Create .env File With Setup Tool

Instead of editing env.example by hand, use the interactive setup wizard to generate a configured .env and, when needed, docker-compose.final.yml:

make env-base           # Required first step: LLM, embedding, reranker
make env-storage        # Optional: storage backends and database services
make env-server         # Optional: server port, auth, and SSL
make env-base-rewrite   # Optional: force-regenerate wizard-managed compose services
make env-storage-rewrite # Optional: force-regenerate wizard-managed compose services
make env-security-check # Optional: audit the current .env for security risks

For full description of every target see docs/InteractiveSetup.md.

Optional: spaCy Models for docx smart_heading

The native docx parser's opt-in smart_heading engine parameter uses spaCy for sentence/NER heuristics. The spaCy runtime is already included in the api extra — only the two pinned language models (zh_core_web_sm / en_core_web_sm 3.8.0, GitHub release wheels not published on PyPI) need one extra step:

lightrag-download-cache --spacy-install

In a uv sync environment (which has no pip) the command installs through uv pip install instead. The models are not in uv.lock, so a plain uv sync removes them again; use uv sync --inexact afterwards to keep them.

Enable smart_heading per file/rule (e.g. LIGHTRAG_PARSER=docx:native(smart_heading=true)), or globally in .env:

# .docx files routed to the native engine get smart_heading by default;
# opt a file back out with an explicit native(smart_heading=false) rule/hint.
DOCX_SMART_HEADING=true

When the global switch is on (or a LIGHTRAG_PARSER rule carries native(smart_heading=true)), the server verifies the models at startup and fails fast with install guidance if they are missing. Deployments that never enable smart_heading need no models. The main Docker image ships the models pre-installed (the lite image does not); for air-gapped hosts see the Offline Deployment Guide.

Optional: libcairo for SVG Rasterization (native md/textpack)

The native markdown/textpack parser rasterizes embedded SVG images to PNG via cairosvg. cairosvg is a cffi binding: pip install cairosvg (pulled in by the api extra) always succeeds, but rendering only works if the native libcairo shared library is also present on the host — pip/uv cannot install system libraries. Without it, rasterization fails at runtime and the affected SVG is skipped (the rest of the document is unaffected); the server logs a warning at startup so the gap is visible before it shows up as a per-document warning later.

Install the system package for your platform:

# Debian / Ubuntu (the official Docker image already includes this)
sudo apt-get install -y libcairo2

# RHEL / Fedora
sudo dnf install -y cairo

# macOS (Homebrew)
brew install cairo

# Windows: install the GTK3 runtime, which bundles libcairo-2.dll

Deployments that never process markdown/textpack documents with embedded SVGs can ignore the startup warning.

About LightRAG

A Lightweight, Graph-Based RAG Framework

LightRAG is a lightweight knowledge-graph RAG framework and an efficient alternative to Microsoft GraphRAG. It adopts a dual-layer architecture to manage both knowledge graphs (KGs) and vector embeddings, effectively bridging the gap between traditional vector-based RAG and graph-based RAG approaches. Designed for high scalability, LightRAG addresses key challenges in large-scale graph indexing and retrieval, including heavy computational overhead, slow response times, and the high cost of incremental updates. While supporting large datasets, LightRAG can still deliver exceptionally high RAG quality, even when paired with a 30B open-source large language model (LLM).

Features & Advantages

Multimodal Capability Upgrades

Traditional RAG systems lack an effective way to process multimodal content such as images, formulas, and tables in documents. Starting with v1.5, LightRAG seamlessly integrates multimodal processing into its document pipeline and query flow. Through the knowledge graph, LightRAG connects multimodal content with the body text and can use that information when answering queries to produce more accurate and reliable responses. This capability can substantially improve RAG quality for documents rich in multimodal content, such as operation manuals and academic papers.

LightRAG API Server

The LightRAG server offers not only a web-based UI for exploring LightRAG functionalities but also a comprehensive REST API. For more information about the LightRAG server, please refer to LightRAG Server.

iShot_2025-03-23_12.40.08

Key Configuration Guide

Selecting LLM Models

LightRAG requires LLM/VLMs of four different roles during its workflow. You should configure models with different capabilities and speeds for different roles to strike a balance between performance and processing speed. LightRAG has higher capability requirements for Large Language Models (LLMs) than traditional RAG because it requires LLMs to perform complex entity-relation extraction tasks from documents. During the query phase, the LLM needs to process a large volume of retrieved information, including entities, relationships, and text chunks. This requires the model to have the capability of generating high-quality responses in long, noisy contexts.

Recommended models by role:

Within your acceptable latency and cost budget, prefer the highest-scoring model available (based on public benchmarks/leaderboards). For detailed model configurations, please refer to RoleSpecificLLMConfiguration.md

Selecting Query Modes

LightRAG supports five query modes:

The default query mode for LightRAG is mix. Using mix mode generally yields the most ideal query results. The mix mode takes slightly longer than naive, while other query modes are roughly comparable in latency.

Embedding Models

When choosing an Embedding model, pay attention to its multilingual support capabilities. Since LightRAG's retrieval quality has limited dependency on the Embedding model, it is recommended to choose low-dimensional and fast models. The env.example default, OpenAI text-embedding-3-large (3072 dimensions), favors multilingual quality; text-embedding-3-small (1536 dimensions, set EMBEDDING_DIM=1536) is cheaper and faster. Any mainstream, up-to-date embedding model works well; for local deployment, BAAI/bge-m3 is a solid choice. We highly recommend deploying the Embedding model locally to achieve the best performance.

Important Note: Choose the Embedding model before document indexing and use the same model for queries. Changing it requires re-embedding text chunks, entities, and relationships. Use the supported lightrag-rebuild-vdb utility to rebuild vectors from the graph and text chunks; see Switching embedding models. Do not delete vector tables or the working directory as a substitute.

Enabling Reranking

Enabling the Rerank option during the query phase can significantly improve query quality. However, enabling Rerank typically introduces a 1–2 second delay. To minimize latency, it is highly recommended to deploy the Rerank model locally. Any mainstream, up-to-date reranker works; for local deployment, BAAI/bge-reranker-v2-m3 is recommended. For configuration details, please refer to the env.example file. Unlike Embedding models, the Rerank model can be changed at any time during the query phase.

Document Processing Pipeline Configuration

The default pipeline configuration in LightRAG does not allow the system to perform at its best. The quality of document parsing greatly impacts document indexing and querying. Therefore, we recommend configuring the pipeline to enable the MinerU parsing engine and activating the pipeline's image analysis features. Suggested configuration:

LIGHTRAG_PARSER=*:native-iteP,*:mineru-iteP,*:legacy-R

VLM_PROCESS_ENABLE=true
VLM_LLM_MODEL=<your_vlm_model_name>

Since the cloud-based MinerU service has limitations on usage, file size, and page count, it is recommended to use a locally deployed MinerU. For details on configuring the file processing pipeline, please refer to FileProcessingPipeline.md

Concurrency Optimization for File Processing

For large-scale document processing, you need to improve concurrency. Key environment variables related to concurrent file processing include:

# Sample Configuration
MAX_ASYNC_LLM=8
MAX_PARALLEL_INSERT=3
EMBEDDING_FUNC_MAX_ASYNC=16
EMBEDDING_BATCH_NUM=32

Selecting Backend Storage

LightRAG requires four types of backend storage:

All four default storages are in-memory databases (JsonKVStorage, NanoVectorDBStorage, NetworkXStorage, JsonDocStatusStorage): the whole dataset resides in the server process's memory and local files under WORKING_DIR serve only as persistence, so capacity is bounded by available RAM. The defaults are therefore intended only for small-scale testing, evaluation, and debugging, and are not suitable for production.

For production, PostgreSQL is the recommended backend — it can serve all four storage types on its own; MongoDB and OpenSearch are the other single-backend options. Alternatively, you can select specialized databases for vector or graph storage, such as using Milvus or Qdrant for vector storage, and Neo4j or Memgraph for graph storage.

For the complete list of available implementations per storage type, see Storage Types Supported.

Other Important Configurations for Document Processing

During the document insertion stage, you may also want to adjust the following environment variables based on your needs:

Resolving LLM Timeouts During Entity-Relation Extraction

LLM timeouts during entity-relation extraction usually trace back to one of three causes. Identify the cause, then apply the matching remedy (the parameters can be combined):

Resolving Embedding Timeouts

An error such as Embedding func: Worker execution timeout after 60s comes from the embedding queue, which has its own timeout and does not follow LLM_TIMEOUT:

Other Important Configurations for Document Querying

During the document query stage, you may also want to adjust the following environment variables based on your needs:

WebUI Entries and the Default Entry

The server mounts two WebUI entries from a single frontend build. /webui is the admin console: document management, knowledge-graph exploration, and query debugging with the full query-parameter panel. /workspace is a query-only entry for everyday knowledge-base users: the chat surface and nothing else (no document management, no knowledge graph, no query-parameter sidebar, no API-docs links), designed for mobile use, and showing a welcome page to visitors who are not signed in.

Two things to know before pointing end users at /workspace. First, query parameters there are inherited, not editable: each query uses the settings /webui saved in the same browser (frontend defaults when none were saved), which is per-browser local state, not a server-wide policy. Second, hiding the admin UI is a UX split, not a security boundary — the API still authorizes every endpoint server-side. For the complete behavior of the query entry, see LightRAG-API-Server.md.

WebUI authentication migration: Protected /webui and /workspace access requires AUTH_ACCOUNTS and a strong, non-default TOKEN_SECRET. API keys are for programmatic access, no longer entered or sent by the WebUI. Existing API-key-only WebUI users must keep their key, configure accounts and the secret, restart, reload all tabs, and sign in. Fully open deployments (neither accounts nor an effective API key) keep the guest-token flow. See migration details.

Using LightRAG As SDK

⚠️ For integration into your project, we strongly recommend using the REST API provided by the LightRAG Server. The LightRAG SDK is primarily intended for embedded applications or academic research and evaluation purposes.

Install LightRAG SDK

cd LightRAG
# 注意: uv sync 会自动在 .venv/ 目录创建虚拟环境
uv sync
source .venv/bin/activate  # 激活虚拟环境 (Linux/macOS)
# Windows 系统: .venv\Scripts\activate

# 或: pip install -e .
uv pip install lightrag-hku
# 或: pip install lightrag-hku

LightRAG SDK Sample Code

To get started with LightRAG core, refer to the sample codes available in the examples folder. Additionally, a video demo demonstration is provided to guide you through the local setup process. If you already possess an OpenAI API key, you can run the demo right away:

### you should run the demo code with project folder
cd LightRAG
### provide your API-KEY for OpenAI
export OPENAI_API_KEY="sk-...your_opeai_key..."
### download the demo document of "A Christmas Carol" by Charles Dickens
curl https://raw.githubusercontent.com/gusye1234/nano-graphrag/main/tests/mock_data.txt > ./book.txt
### run the demo code
python examples/lightrag_openai_demo.py

For a streaming response implementation example, please see examples/lightrag_openai_compatible_demo.py. Prior to execution, ensure you modify the sample code's LLM and embedding configurations accordingly.

Note 1: When running the demo program, please be aware that different test scripts may use different embedding models. Vectors written by one model are unusable by another, so switching models requires rebuilding them. For the demo data specifically, the simplest route is to delete the demo directory (./dickens) and re-run — the corpus is small and disposable; keep kv_store_llm_response_cache.json if you want the LLM cache. For a real deployment, do not delete the working directory: it holds the knowledge graph and the text chunks, and deleting it turns a re-embedding job into a full re-ingestion of every document. Run lightrag-rebuild-vdb instead — see Switching embedding models.

Note 2: Only lightrag_openai_demo.py and lightrag_openai_compatible_demo.py are officially supported sample codes. Other sample files are community contributions that haven't undergone full testing and optimization.

Notes on SDK Usage

For detailed instructions on using the SDK, please refer to docs/ProgramingWithCore.md. Some LightRAG features are not exposed via the REST API and are accessible only through the SDK. These features are typically experimental and may not be compatible with future versions.

Replicating Findings in the Paper

LightRAG consistently outperforms NaiveRAG, RQ-RAG, HyDE, and GraphRAG across agriculture, computer science, legal, and mixed domains. For the full evaluation methodology, prompts, and reproduce steps, see docs/Reproduce.md.

Overall Performance Table

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%

📚 Documentation and Tools

Reference Documentation (docs/)

Entries marked 🇨🇳 also ship a Chinese translation as *-zh.md in the same folder.

Deployment and Setup

Document What it covers
ExploreLightRAG.md 🇨🇳 From the default setup to production: PostgreSQL, auth, role LLMs, rerank, VLM, smart headings, MinerU and concurrency, step by step with measured results
InteractiveSetup.md The make env-* setup wizard: generating .env and the wizard-managed docker-compose.final.yml
DockerDeployment.md Docker / Docker Compose deployment, image variants, and Cosign verification of the official GHCR images
AppleContainerSetup.md Running the Postgres / Neo4j / Milvus storage stack on Apple's native container runtime (Apple Silicon, no Docker Desktop)
OfflineDeployment.md Air-gapped installs: pre-installing dependencies, the tiktoken cache, and the spaCy models
MultiSiteDeployment.md Several isolated instances behind one reverse proxy, sharing a single WebUI build (LIGHTRAG_API_PREFIX)
FrontendBuildGuide.md How the WebUI is built and shipped (Bun / Node), and which install scenarios require a build

Server and API

Document What it covers
LightRAG-API-Server.md 🇨🇳 The complete server guide: startup, configuration, authentication, REST endpoints, and WebUI usage
UserDefinedUI.md 🇨🇳 Replacing the welcome page, login-page text, user agreement, query empty state, copyright line and brand logo per language (UI_TEMPLATES_DIR)

Document Processing

Document What it covers
FileProcessingPipeline.md 🇨🇳 Pipeline specification: LIGHTRAG_PARSER routing rules, per-engine parameters, multimodal analysis, document status lifecycle
ParserServiceDeployment.md 🇨🇳 Self-hosting the external MinerU and docling-serve parsing services (Docker, GPU, model weights)
ParagraphSemanticChunking.md 🇨🇳 The Paragraph semantic (P) chunking strategy: heading/paragraph/table-aware boundaries, reference dropping
LightRAGSidecarFormat.md 🇨🇳 The sidecar (*.parsed/) interchange format every multimodal-capable parser engine must emit
ThirdPartyParser.md 🇨🇳 Developing and registering your own parser engine
ParserDebugCLI.md 🇨🇳 python -m lightrag.parser.cli — parse a single file offline and inspect the result without a server

Models and Storage

Document What it covers
RoleSpecificLLMConfiguration.md 🇨🇳 Per-role (EXTRACT / QUERY / KEYWORD / VLM) LLM and VLM configuration
LLMProviderOptions.md Complete reference for provider generation options (OPENAI_LLM_*, OLLAMA_LLM_*, GEMINI_LLM_*, BEDROCK_LLM_*, *_EMBEDDING_*)
AsymmetricEmbedding.md Query/document asymmetric embedding (EMBEDDING_ASYMMETRIC) and per-model prefixes
MilvusConfigurationGuide.md Tuning Milvus index parameters through vector_db_storage_cls_kwargs

SDK and Development

Document What it covers
ProgramingWithCore.md Using LightRAG as a Python SDK, including features that are not exposed over REST
Reproduce.md Reproducing the evaluation results reported in the paper
UV_LOCK_GUIDE.md When and how to update uv.lock

Maintenance Tools (lightrag/tools/)

Storage-facing tools read .env and environment variables exactly like the server does, so run them from the project root with the same configuration. Several of them rewrite storage in place — check the linked guide for whether the server (and any other writer) has to be stopped first; rebuild_vdb and clear_storage require it.

rebuild_vdb.py — lightrag-rebuild-vdb — README_REBUILD_VDB.md

Drops and rebuilds every vector storage from its authoritative source (graph nodes/edges and the text_chunks KV store). The recovery path after a failed vector write, and after changing the embedding model or dimension. Also offers a read-only consistency check.

clear_storage.py — lightrag-clear-storage — README_CLEAR_STORAGE.md

Drops every data storage of one workspace offline, exactly as the WebUI Clear button does, after showing what it is about to delete and requiring a typed confirmation. The way out of a startup refusal over an empty or unreadable vector index when the data is disposable and a rebuild would be wasted. Never touches the LLM response cache. Requires the server to be stopped.

clean_llm_query_cache.py — lightrag-clean-llmqc — README_CLEAN_LLM_QUERY_CACHE.md

Deletes query-mode LLM cache entries (mix:*, hybrid:*, local:*, global:*, naive:*) while preserving the expensive extraction cache.

gc_llm_cache.py — lightrag-gc-llm-cache [--apply] — README_GC_LLM_CACHE.md

Deletes chunk-scoped LLM cache rows whose owning chunk no longer exists and that no live chunk still references — rows a document deletion could not reach, still holding the extraction prompt and its result. Reports by default; --apply deletes, and only after a strict read confirms the chunk is gone.

migrate_llm_cache.py — lightrag-migrate-llm-cache — README_MIGRATE_LLM_CACHE.md

Migrates default-mode caches (extraction, summary, multimodal analysis, smart-heading) between KV storage backends, preserving workspace isolation.

kg_integrity_repair.py — python -m lightrag.tools.kg_integrity_repair [--apply] — README_KG_INTEGRITY_REPAIR.md

Audits the whole graph for contributions missing from the full_entities / full_relations recovery anchors, reports irrecoverable orphans, and optionally repairs the anchors so delete/retry can discover them again.

source_conflict_repair.py — python -m lightrag.tools.source_conflict_repair list / ... repair — README_SOURCE_CONFLICT_REPAIR.md

Lists documents that claim the same canonical source key, and demotes the candidates the operator did not choose to duplicates. It never picks a winner on its own and never deletes content.

download_cache.py — lightrag-download-cache [--spacy-install] — OfflineDeployment.md

Pre-downloads the tiktoken encodings and the pinned spaCy models required for offline deployment and the docx smart_heading engine parameter.

hash_password.py — lightrag-hash-password [--username USER] — LightRAG-API-Server.md

Generates a bcrypt value ready to paste into AUTH_ACCOUNTS.

check_initialization.py — python -m lightrag.tools.check_initialization --demo — ProgramingWithCore.md

SDK diagnostic: verifies that a LightRAG instance is fully initialized, catching the common "forgot await rag.initialize_storages()" mistake.

Ecosystem & Extensions

📸
RAG-Anything
Multimodal RAG
🎥
VideoRAG
Extreme Long-Context Video RAG
✨
MiniRAG
Extremely Simple RAG

🤝 Contribution

We welcome contributions of all kinds — bug fixes, new features, documentation improvements, and more.
Please read our Contributing Guide before submitting a pull request.

We thank all our contributors for their valuable contributions.

📖 Citation

@article{guo2024lightrag,
title={LightRAG: Simple and Fast Retrieval-Augmented Generation},
author={Zirui Guo and Lianghao Xia and Yanhua Yu and Tu Ao and Chao Huang},
year={2024},
eprint={2410.05779},
archivePrefix={arXiv},
primaryClass={cs.IR}
}

⭐ Thank you for visiting LightRAG! ⭐

LightRAG (HKUDS/LightRAG)

vector-database
Searching Database…

What is this?LightRAG is an open-source, graph-based RAG framework (EMNLP 2025) by HKUDS. It indexes your documents into a knowledge graph plus vector embeddings so you can query them — a lighter, faster alternative to Microsoft GraphRAG.
Is it a library I code against, or a ready-to-run app?Both: it's a Python framework you can integrate into your own code, and it ships with a server providing a web UI to insert, query and visualize your knowledge base, plus a comprehensive REST API.
How do I get it running?Install from PyPI using uv (recommended) or pip, or launch the server with Docker Compose. Then run the interactive setup wizard to generate a configured .env instead of editing env.example by hand.
Do I need to bring my own LLM?Yes — you supply the models: LLM/VLMs in four roles (EXTRACT, QUERY, KEYWORDS and VLM), each with independent settings. Graph extraction also works well with open-source models like Qwen3-30B-A3B.
Is the default storage setup fine for production?No. The default in-memory KV, vector and graph stores with local file persistence are for small-scale testing only; for production with large datasets, PostgreSQL is recommended (Neo4j, MongoDB and OpenSearch also work).
What kinds of domains does it handle best?Knowledge-heavy verticals: the README calls out legal and financial work needing global comprehension or logical reasoning. It is also built to stay efficient on large datasets while keeping RAG quality high.
Can I run it on an air-gapped server with no internet?Yes — a dedicated Offline Deployment Guide covers pre-installing all dependencies and cache files for air-gapped hosts, and the official Docker images are signed with Sigstore Cosign for verification.
How is this different from plain vector RAG?It indexes a knowledge graph alongside vector embeddings and retrieves at two levels — concrete facts and broader concepts — capturing entity relationships that chunk-based search misses. It skips community reports and multi-hop reasoning, cutting LLM calls, latency and cost.
What document formats can it ingest?Through RAG-Anything integration: PDFs, images, Office documents, tables and formulas. Parsing runs on MinerU, Docling or the built-in Native engine, which also handles images, tables and formulas inside Word and Markdown files.
Does updating the knowledge base mean re-indexing everything?No — documents can be added incrementally, and deleting one triggers automatic knowledge-graph regeneration, reusing the LLM cache from indexing to rebuild only the affected entities and relationships.
Can I measure how good its answers are?Yes — RAGAS is integrated for evaluation and Langfuse for tracing, and the API can return retrieved contexts alongside query results so you can score context precision.
Creator
HKUDS
Size
124.6 MB
Stars
40.8K
Age
2y
Commits · 90 Days