This repository explores the integration of OpenAI's GPT, Neo4j, and Langchain to facilitate communication with contracts through knowledge graphs. The project investigates the potential of utilizing knowledge graphs to address complex inquiries within contract documents.
This project aims to leverage knowledge graphs to enable advanced querying and analysis of contract documents. By combining the capabilities of OpenAI's GPT for natural language understanding, Neo4j for graph database management, and Langchain for document transformations, the goal is to extract valuable insights from unstructured text and structured data within contracts.
For a deeper understanding of the theoretical background behind using knowledge graphs for contract analysis, refer to this Medium article. In summary, knowledge graphs offer a transformative approach to interact with contract documents, unlocking new insights through contextual understanding and multi-hop reasoning.
A sample contract PDF obtained online serves as the dataset for this project.
The project addresses various complex questions, including:
- Cost-Benefit Analysis
- Timeframe and Scheduling
- Resource Allocation
The project workflow involves several key steps:
- Setup: Import necessary libraries and tools including OpenAI, Langchain, and Neo4j.
- Data Preparation: Load, tokenize, and split the contract text using appropriate tools.
- Graph Construction: Utilize Neo4j to construct a knowledge graph representing the contract's entities and relationships.
- Querying and Analysis: Employ different methods for querying the knowledge graph and retrieving relevant information, including vector search and Cypher queries.
- Agent Development: Develop an intelligent agent capable of interacting with multiple tools to answer complex questions.
The final agent incorporates tools for structured and unstructured information retrieval, as well as document transformation for long context reordering.
The repository provides a notebook detailing the project's implementation, including code snippets and responses to various questions posed to the contract document. Users are encouraged to experiment with their own contract data and explore different types of inquiries.
The project offers avenues for further exploration, including:
- Performance Metrics
- Risk Assessment
- Quality Standards
- Compliance and Legal Obligations
- Collaboration and Communication
- Technology and Tools
- Change Management
Feel free to reach out for questions or discussions!
Reference: Constructing Knowledge Graphs from Text using OpenAI Functions