SuperAPI AI Directory

LightRAG

Lightweight RAG framework based on knowledge graphs — GraphRAG approach from HKU research (EMNLP 2025)

Open website

About this tool

LightRAG is a lightweight, knowledge-graph-based Retrieval-Augmented Generation (RAG) framework developed by the Hong Kong University Data Science Lab (HKUDS). Its paper was published at EMNLP 2025, and it is positioned as an efficient alternative to Microsoft GraphRAG. The project adopts a dual-layer architecture, managing both a knowledge graph (KG) and vector embeddings, aiming to bridge the gap between traditional vector-based RAG and graph-based RAG.

【Key Capabilities】

  • Deep contextual understanding: It captures complex semantic dependencies between entities through graph-structured indexing, overcoming the context fragmentation limitations of traditional chunk-based retrieval, and performs outstandingly in vertical domains requiring global understanding or logical reasoning (such as law and finance).
  • Comprehensiveness and diversity: The dual-layer retrieval mechanism can simultaneously integrate concrete facts and abstract concepts, improving the comprehensiveness and diversity of results in complex cross-document queries.
  • Retrieval efficiency and low cost: It does not rely on inefficient community reports or multi-hop reasoning, significantly reducing the number of LLM calls during indexing and querying, and lowering response latency and computational cost. Even when paired with a 30B open-source large model, it can maintain relatively high RAG quality.
  • Incremental updates and selective deletion: It supports incremental updates and selective deletion for the graph knowledge base; when deleting documents, it can use the LLM cache generated during indexing to quickly rebuild affected entities and relationships, improving update efficiency.
  • Multi-document parsing engines: The document processing pipeline supports MinerU, Docling, and Native, and can be extended with third-party parsers. The Native engine can parse images, tables, and formulas in Word and Markdown, and can also automatically detect and correct section headings in Word documents.
  • Multiple chunking strategies: It supports four strategies: fixed length (F), recursive character (R), vector semantic (V), and paragraph semantic (P); among them, the paragraph semantic strategy aligns chunk boundaries with the document's native semantic boundaries (headings, paragraphs, tables) as much as possible, reducing issues such as mismatches between headings and content and loss of table headers when splitting long tables.
  • Multiple storage backends: By default, KV, vector, and graph storage use in-memory databases plus local file persistence, which is only suitable for small-scale testing and evaluation and is not recommended for production; production environments support common backends such as PostgreSQL (recommended), Neo4J, MongoDB, OpenSearch, and Milvus.
  • Multimodal capabilities: Since v1.5, multimodal processing has been integrated into the document pipeline and query workflow, linking images, formulas, tables, and body text through the knowledge graph, thereby utilizing this information when answering queries. It is suitable for multimodal content-rich documents such as operation manuals and academic papers.
  • Services and interfaces: It provides a LightRAG API Server, including both a Web UI for exploring features and a complete REST API.

【How to Use】 The project uses uv for Python package management. You can first install uv: on Unix/macOS run curl -LsSf https://astral.sh/uv/install.sh | sh, and on Windows run powershell -c "irm https://astral.sh/uv/install.ps1 | iex". pip can also be used, but uv is officially recommended for better performance and more reliable dependency management. Installation methods include: installing from PyPI, installing from source, and starting the LightRAG Server with Docker Compose. For offline or isolated environments, refer to the offline deployment guide. The project provides an interactive setup wizard that can generate a configured .env and, when needed, generate docker-compose.final.yml, without the need to manually edit env.example. Docker images have historically been available at LightRAG Docker Images, and the official GHCR images published by GitHub Actions are signed using Sigstore Cosign and GitHub OIDC.

[Optional dependencies]

  • docx smart_heading: the optional smart_heading engine parameter of the native docx parser uses spaCy for sentence/NER heuristic processing. The spaCy runtime is already included in the api extra, but two pinned language models must be installed separately (zh_core_web_sm / en_core_web_sm 3.8.0; the corresponding wheels are not published on PyPI and must be obtained from GitHub releases). It can be enabled per file/rule via LIGHTRAG_PARSER=docx:native(smart_heading=true), or enabled globally in .env. When enabled globally, the server validates the models at startup; if missing, it fails fast and provides installation guidance. The main Docker image preinstalls the models (the lite image does not).
  • SVG rasterization: the native markdown/textpack parser rasterizes embedded SVG images to PNG via cairosvg; cairosvg is a cffi binding, and pip install cairosvg (pulled in by the api extra) always succeeds, but rendering requires the native libcairo shared library to be present on the host. When it is missing, rasterization fails at runtime and skips the affected SVGs, and the server logs a warning at startup.

[Configuration highlights] The LightRAG workflow requires four roles of LLM/VLM. It is recommended to configure them separately by capability and speed to balance performance and processing speed:

  • Extraction LLM (EXTRACT): entity-relation extraction runs on every text chunk, so a fast and economical mainstream model is sufficient. It is strongly recommended to use a non-thinking model (with reasoning/thinking mode disabled) to avoid slow and expensive extraction. Hosted options include GPT-5.6-luna, Claude Haiku, Gemini-mini, etc.; for local deployment, the minimum usable option is Qwen3-30B-A3B-Instruct.
  • Query LLM (QUERY): responsible for writing the final answer within a long and noisy retrieval context; it should be stronger than the extraction model. A higher-tier model from the same family may be chosen, and thinking models are allowed.
  • Keyword LLM (KEYWORD): a latency-sensitive lightweight step; a non-thinking model must be used to keep query latency low, and its speed only needs to be comparable to the extraction model.
  • VLM: any mainstream multimodal model that supports image input is acceptable; for local deployment, Qwen3.6-35B-A3B may be considered. Within an acceptable latency and cost budget, it is recommended to prioritize the models with the highest scores on public benchmarks/leaderboards.

LightRAG supports five query modes:

  • local: focuses on local context and exact matching of specific entities, retrieving candidate entities and their directly associated attributes from the knowledge graph. It is suitable for question answering about specific objects, concrete concepts, or detailed facts.
  • global: focuses on macro topics, cross-document reasoning, and deep relationships between entities, retrieving chains of relationships covering broad topics and concepts. It is suitable for summarizing across multiple contexts, trend analysis, or understanding complex semantic dependencies.
  • hybrid: merges the retrieval results of local and global, recalling both specific entities and global relational context for comprehensive reasoning and generation.
  • naive: traditional RAG retrieval based on text chunks, without using the knowledge graph, relying directly on vector similarity.