Part 18: LightRAG — Graph RAG That Actually Works banner
OnlyTerp OnlyTerp

Part 18: LightRAG — Graph RAG That Actually Works

Development community intermediate

Description

*From "find similar text" to "reason about relationships." The single biggest intelligence upgrade you can make.* ---

Installation

Terminal
claude install-skill https://github.com/OnlyTerp/openclaw-optimization-guide

README

Part 18: LightRAG — Graph RAG That Actually Works

*From "find similar text" to "reason about relationships." The single biggest intelligence upgrade you can make.*


The Problem With Basic Vector Search

Part 4 and Part 9 gave you memory. Part 10 gave you better embeddings. But vector search has a fundamental ceiling: **it finds what's similar, not what's connected.**

Ask "what hardware decisions were made and why?" and vector search returns 8 files that all mention GPUs. It can't traverse from a decision → the person who made it → the project it affected → the lesson learned afterward. That's not a retrieval problem — it's an architecture problem.

**Graph RAG fixes this.** It builds a knowledge graph (entities + relationships) alongside your vector database, then searches both simultaneously.

Naive RAG vs Graph RAG

Naive RAG (Parts 4, 9, 10) Graph RAG (This Part)
Indexes Text chunks as vectors Entities, relationships, AND text chunks
Retrieves Similar text (cosine similarity) Connected knowledge (graph traversal + similarity)
Answers "Here's what the docs say about X" "Here's how X relates to Y, who decided Z, and why"
Scales Degrades at 500+ docs (too many partial matches) Improves with more docs (richer graph)
Cost Cheap (embedding only) More expensive upfront (LLM extracts entities) but cheaper at query time

LightRAG: The Best Graph RAG For Personal Use

[LightRAG](https://github.com/HKUDS/LightRAG) is an open-source graph RAG framework from HKU (EMNLP 2025 paper). It competes with Microsoft's GraphRAG at a fraction of the cost.

**Why LightRAG over alternatives:**

Tool Graph Vector Web UI Self-Hosted MCP/API LangFuse Cost
LightRAG ✅ REST API ✅ Built-in Free
Microsoft GraphRAG 10-50x more
Graphiti + Neo4j ❌ (separate) ❌ (Neo4j browser) ❌ (build your own) Free but manual
Plain vector search Free

LightRAG does vector DB + knowledge graph **in parallel** during ingestion. One system, both capabilities.


How It Works

Ingestion

flowchart LR
    D[Document] --> C[Chunking]
    C --> E[Embedding Model]
    C --> L[LLM Entity Extraction]
    E --> VDB[(Vector Database)]
    L --> KG[(Knowledge Graph)]
    KG -.->|entities| N1((Terp))
    KG -.->|entities| N2((5090 PC))
    N1 ---|"owns"| N2

For each document, LightRAG:

    undefined

Query (Dual-Level Retrieval)

flowchart LR
    Q[Question] --> VS[Vector Search]
    Q --> GT[Graph Traversal]