LightRAG tutorial: retrieval and incremental updates

Learn LightRAG's dual-level retrieval and follow a news chatbot lab using GPT-4o-mini, incremental inserts, and document deletion.

Player not loading? Watch on YouTube

This module explains LightRAG's retrieval design and walks through a news chatbot that changes as articles arrive or are retracted. The speaker compares it with Microsoft GraphRAG, whose community reports can be costly to query and rebuild, according to the paper figures cited in the lesson.

LightRAG extracts entities and relationships from text, creates searchable key-value profiles, and merges duplicates. It embeds profile keys in a vector store alongside the graph. At query time, specific keywords match entities, while broader themes match relationships. A one-hop expansion gathers nearby context, and hybrid mode combines both sets of profiles for the answer. The API discussion also covers naive, local, global, and mix modes.

The update workflow processes new documents into a subgraph and merges it into the existing graph. The speaker explains deletion through cached extraction profiles, with shared entities retaining support from other documents.

The lab uses the open source Python library with GPT-4o-mini and OpenAI embeddings. It configures disk storage, initializes the stores, inserts morning articles, queries in hybrid mode, then adds breaking news and retracts an article. NetworkX is the default graph store described; Neo4j is an alternative. This example uses external model services rather than demonstrating offline inference. The speaker reports comparable or better benchmark answers at lower retrieval cost, but notes a quality tie on the smallest mixed corpus.