explaingit

hkuds/lightrag

📈 Trending35,346PythonAudience · developerComplexity · 3/5ActiveLicenseSetup · hard

TLDR

Python library for building question-answering systems over large document collections using knowledge graphs instead of flat text search.

Mindmap

mindmap
  root((LightRAG))
    What it does
      Extracts entities and relationships
      Builds knowledge graphs
      Answers questions with context
    Retrieval approach
      Local entity search
      Global pattern reasoning
      Dual-level retrieval
    Storage options
      Neo4j
      PostgreSQL
      MongoDB
      OpenSearch
    Use cases
      Company knowledge bases
      Research literature
      Legal documents
      Technical documentation
    Features
      Web UI for documents
      Interactive graph visualization
      Pluggable backends

Things people build with this

USE CASE 1

Build a question-answering system over internal company documentation that understands both specific facts and broad themes.

USE CASE 2

Create a research paper search tool that retrieves relevant studies and synthesizes answers across multiple papers.

USE CASE 3

Set up a legal document search system that finds relevant clauses and explains how they relate to a query.

USE CASE 4

Develop a technical documentation assistant that answers both narrow how-to questions and high-level architecture questions.

Tech stack

PythonNeo4jPostgreSQLMongoDBOpenSearchLanguage Models

Getting it running

Difficulty · hard Time to first run · 1day+

Requires running multiple external services (Neo4j, PostgreSQL/MongoDB, OpenSearch) and LLM API keys before any working example is possible.

Use freely for any purpose including commercial, as long as you keep the copyright notice.

In plain English

LightRAG is a Python library for building Retrieval-Augmented Generation (RAG) systems that can answer questions about large document collections. RAG is a technique where an AI language model does not answer questions purely from its training data; instead, it first searches a document collection for relevant passages and then uses those passages as context to generate a grounded answer. LightRAG's distinguishing feature is that it structures its document knowledge as a knowledge graph rather than a flat list of text chunks. When you feed documents into LightRAG, it uses a language model to extract entities (people, places, concepts) and the relationships between them, building a graph where nodes are concepts and edges capture how they connect. When you ask a question, LightRAG can retrieve relevant information at two levels: local, focusing on specific entities and their direct neighbors in the graph, and global, reasoning about high-level patterns and themes across the entire document set. This dual-level retrieval means it can handle both narrow factual questions and broad, synthesizing questions better than approaches that only do flat text similarity search. Storage backends are pluggable: you can store the knowledge graph and vector embeddings in Neo4j, PostgreSQL, MongoDB, or OpenSearch, giving flexibility to choose the database that fits your infrastructure. There is also a web UI for inserting documents, querying, and visualizing the knowledge graph interactively. You would use LightRAG when building a question-answering system over a large corpus of documents, internal company knowledge bases, research literature, legal documents, or technical documentation, where you need the system to handle both specific detail questions and broad thematic questions well. It is a Python library, published as the package lightrag-hku, and presented as research at the EMNLP 2025 natural language processing conference.

Copy-paste prompts

Prompt 1
Show me how to set up LightRAG with PostgreSQL as the backend and load a folder of PDF documents into the knowledge graph.
Prompt 2
How do I use LightRAG's local and global retrieval modes to answer both specific factual questions and broad synthesis questions?
Prompt 3
Walk me through extracting entities and relationships from documents using LightRAG and visualizing the resulting knowledge graph in the web UI.
Prompt 4
How do I switch LightRAG's storage backend from Neo4j to MongoDB without losing my existing knowledge graph data?
Prompt 5
Show me how to integrate LightRAG into a Python application to answer questions about a custom document collection.
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.