Build a GraphRAG system combining knowledge graph traversal with vector retrieval for enhanced multi-hop question answering.
You are a knowledge retrieval specialist. Build a GraphRAG system combining graph and vector retrieval. ## Configuration - **Graph Database**: [GRAPH e.g. Neo4j / Amazon Neptune / Memgraph] - **Vector Store**: [VECTOR e.g. Pinecone / Qdrant / pgvector] - **LLM**: [LLM e.g. Claude 4 Opus / GPT-5] - **Document Corpus**: [CORPUS e.g. technical docs / research papers / enterprise wiki] - **Framework**: [FRAMEWORK e.g. LangChain / LlamaIndex / custom] ## Architecture ### 1. Graph Construction (`graph/build.py`) - Extract entities and relationships from [CORPUS] using LLM - Entity types: concept, person, organization, technology, event, metric - Relationship types: uses, relates_to, part_of, causes, precedes, authored_by - Community detection using Leiden algorithm - Community summaries at multiple hierarchy levels - Graph statistics and quality metrics ### 2. Dual Index (`indexing/`) - **Vector index**: Chunk-level embeddings in [VECTOR] - **Graph index**: Entity embeddings + graph structure in [GRAPH] - **Community index**: Community summary embeddings - Cross-reference: link chunks to graph entities - Incremental indexing for new documents ### 3. Retrieval Strategies (`retrieval/`) - **Local search**: Start from entities mentioned in query, traverse nearby nodes, retrieve associated chunks - **Global search**: Use community summaries for broad thematic queries - **Hybrid search**: Combine vector similarity + graph proximity scoring - **Multi-hop reasoning**: Follow relationship chains for complex queries - **Subgraph extraction**: Pull relevant subgraph for context - Dynamic strategy selection based on query classification ### 4. Query Processing (`query/`) - Entity extraction from user query - Entity linking to knowledge graph - Query decomposition for multi-hop questions - Cypher/SPARQL query generation for structured retrieval - Result merging from vector and graph sources ### 5. Response Generation (`generation/`) - Graph-aware context assembly - Relationship-based reasoning prompts - Source attribution with entity and chunk references - Confidence scoring combining graph and vector evidence - Explanation generation showing reasoning path through graph ### 6. Evaluation (`eval/`) - Multi-hop QA accuracy - Comparison: GraphRAG vs standard RAG vs graph-only - Retrieval precision and recall - Reasoning path quality assessment Provide complete implementation with graph visualization and demo queries.
Free to copy and use. Compatible with Claude 4 Opus, GPT-5, Gemini 2.5 Pro.
Index your document corpus to build the knowledge graph and vector store. Test with simple entity queries first, then progress to multi-hop questions. Compare retrieval quality against standard RAG.
Initial release
Sign in and download this prompt to leave a review.