This project is inspired by the GraphRAG model from the paper "Retrieval-Augmented Graph Neural Networks". It integrates LangChain with Dgraph to create an advanced knowledge graph system that supports efficient entity extraction, knowledge representation, and query processing.
-
LangChain Integration:
- LangChain's language model framework is used to perform entity extraction, relation discovery, and question answering over the knowledge graph.
- The framework supports various models and workflows for handling text data and natural language queries.
-
Dgraph Backend:
- Dgraph is utilized as the backend graph database to store and manage entities, relationships, and semantic embeddings.
- Enables graph querying, relationship extraction, and structured data retrieval.
-
Entity and Relation Extraction:
- Text data is processed to extract entities and their relationships, which are dynamically stored in the knowledge graph.
- Supports various types of documents, leveraging the capabilities of LangChain for document processing and splitting.
-
Graph-Based Retrieval:
- Retrieval is augmented through both knowledge graph queries and text embeddings, enabling complex multi-hop reasoning.
- Combines retrieval-augmented generation (RAG) with graph-based relationships to enhance knowledge discovery.
-
Custom Querying System:
- The knowledge graph allows for structured querying over entities, relations, and their properties, providing powerful search and analytics capabilities.
- Integrates with the LangChain prompt templates for easy natural language querying.
-
Clone the Repository:
git clone <repository_url> cd knowledge_graph
-
Install Dependencies: Use the provided requirements file to install Python dependencies.
pip install -r requirements.txt
-
Dgraph Setup: Follow the instructions from the official Dgraph documentation to set up and run your Dgraph instance. Ensure it is properly configured to interface with the LangChain setup.
-
Entity Extraction:
- Use the LangChain text processing pipeline to extract entities from a document.
-
Storing Entities in Dgraph:
- Add extracted entities and relationships to the Dgraph backend.
-
Querying the Knowledge Graph:
- Perform structured queries to retrieve entities and their relationships.
-
Natural Language Queries:
- Leverage LangChain's question-answering module to query the graph using natural language.
Feel free to fork the repository, make pull requests, or submit issues for any feature requests or bugs you encounter.
This project is licensed under the MIT License. See the LICENSE file for details.