Skip to content

Guide · Open source

How to use LightRAG: install, build a knowledge graph and query

Updated · written with AI from the project's own documentation and checked against our catalogue data

LightRAG is an open-source Python library for retrieval-augmented generation, where a language model answers questions using information from your own documents. It extracts entities and relationships from text into a knowledge graph and combines that graph with vector search to find context for a query. This guide explains what you need before installing, how the project is set up, and where it fits compared with other tools, so you can decide whether to try it.

LightRAGHKUDS/LightRAG · ★ 40.5k · MIT

Quick start

  1. 1Check Python 3.10. Confirm you have Python 3.10 installed. The README lists it as the prerequisite.
  2. 2Install uv. Install uv, the package manager the README recommends, using the link in the README.
  3. 3Clone the repository. Run the git clone command from the README to download LightRAG from GitHub.
  4. 4Set up your model services. Prepare a language model and an embedding model, since the README relies on external model services.
  5. 5Choose a storage backend. Decide which storage backend to use, such as the default setup or one of the supported databases listed in the README.
  6. 6Insert documents and query. Use the Python library or API described in the README to insert your documents and ask questions.

What LightRAG does

LightRAG takes your text, pulls out entities and the relationships between them, and stores those as a knowledge graph. When you ask a question, it uses that graph together with vector search to find relevant context, then passes that context to a language model to write the answer.

The project is licensed under MIT and written in Python. Its README describes a web UI, Docker-based deployment and support for several storage backends.

  • Builds a knowledge graph from your documents
  • Uses graph and vector search together to find context
  • Licensed under MIT, self-hosted

Check the prerequisites before you install

The README lists Python 3.10 as the prerequisite. LightRAG relies on external model services, so you need access to a language model and an embedding model. If you cannot pay for or run these, LightRAG will not work for you as described in the README.

  • Python 3.10
  • Access to a language model and an embedding model
  • Basic comfort with the command line

Install LightRAG with uv

The README recommends uv, a Python package manager, for managing the project's dependencies. Install uv first by following the link in the README, then clone the repository from GitHub.

The README's install step shows the clone command below. Follow the rest of the Installation section in the README for the remaining commands.

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

Know the optional features before you configure

The project's news section lists features you can enable or use. Among them are a setup wizard for local deployment via Docker, support for PostgreSQL, MongoDB, Neo4j and OpenSearch as storage, a reranker, and RAGAS and Langfuse integrations for evaluation and tracing.

Text chunking has four selectable strategies named Fix, Recursive, Vector and Paragraph, and the README lists role-specific LLM configuration for EXTRACT, QUERY, KEYWORDS and VLM.

  • Storage backends: PostgreSQL, MongoDB, Neo4j, OpenSearch
  • Chunking strategies: Fix, Recursive, Vector, Paragraph
  • Evaluation and tracing: RAGAS and Langfuse
  • Web UI for inserting, querying and visualising knowledge

Choose LightRAG or a comparable project

LightRAG is a good fit when you want a graph-based alternative to plain vector-search RAG and a self-hosted setup. Comparable projects named in this directory include GraphRAG, RAG-Anything, MiniRAG and LlamaIndex. RAG-Anything is related to LightRAG, and the README notes that its functionality has been merged into LightRAG.

  • Pick LightRAG for graph-based retrieval and self-hosting
  • Pick LlamaIndex if you want a broader general framework
  • Pick a hosted service if you do not want to run anything yourself

What people use it for

  • Question-answering over your own internal document collection
  • Experimenting with graph-based retrieval compared with vector-only RAG
  • Evaluating retrieval quality with RAGAS and tracing calls with Langfuse
  • Self-hosted document assistants with a choice of storage databases

Frequently asked questions

Is LightRAG free to use?

LightRAG is released under the MIT licence, which is a permissive open-source licence. You still need to pay for or run any language model and embedding model you connect to it, since the README relies on external model services.

What do I need to install LightRAG?

The README lists Python 3.10 as the prerequisite and recommends uv for package management. You also need access to a language model and an embedding model.

How do I install LightRAG?

The README recommends installing uv first, then running git clone https://github.com/HKUDS/LightRAG.git. Follow the remaining Installation steps in the README.

Does LightRAG have a web interface?

Yes, the README describes a LightRAG WebUI for inserting, querying and visualising knowledge. The README centres on the Python library and API, so the WebUI is an add-on to that core.

What is LightRAG an alternative to?

It is an alternative to plain vector-search RAG, using a knowledge graph built from your text. Comparable projects named in this directory are GraphRAG, RAG-Anything, MiniRAG and LlamaIndex.

Can I run LightRAG without an external LLM?

The README relies on external model services, so this project is not a good fit if you cannot run or pay for a language model and an embedding model.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

LightRAG suits developers and researchers who want self-hosted question-answering over their own documents with a graph-based retrieval approach. It is a poor choice for non-programmers who want a ready-made chat app, or for anyone who needs a fully managed service or cannot supply a language model and embedding model.

Install options & downloads