ToolsPromptsSkillsWorkflowsBlogAbout

Graph RAG — build knowledge graphs for multi-hop reasoning

Extract entities and relationships from documents into a knowledge graph, then traverse connections to answer questions that span multiple sources.

RAG4.4
Graph RAG — build knowledge graphs for multi-hop reasoning preview

Prompt template

Extract entities and relationships from the following text. Return as JSON with entities (name, type, description) and relationships (source, target, relation, confidence).

Text: {document_chunk}

Extracted knowledge:

How to use

  1. 1Chunk documents and run an LLM extraction pass to identify entities and typed relationships
  2. 2Load extracted triples into a graph database (Neo4j) with entity resolution and deduplication
  3. 3At query time, identify key entities in the user question and match them to graph nodes
  4. 4Traverse 1-3 hop neighborhoods around matched entities to collect connected subgraphs
  5. 5Optionally combine graph traversal results with vector retrieval for hybrid graph+vector RAG
  6. 6Format the subgraph as context and pass to the LLM with citation to source nodes

Pro tips

  • Use entity linking (e.g. spaCy + Wikidata) to merge duplicate entities across documents
  • Graph RAG shines for questions like 'who are the competitors of X's suppliers?' that need multi-hop joins
  • Store source document references as properties on edges for traceable citations
  • Community detection (Leiden) on the graph can auto-generate hierarchical summaries

Works best with

neo4jlangchainllamaindexnetworkx

Ratings & Reviews

Loading reviews…

Share your experience

Select a rating

Related Skills