Skip to content

Straits-AI/kg-experiment

Repository files navigation

Knowledge Graph Experiment

This project builds a multi-level supply chain graph with product reviews for root cause analysis using LangChain and Neo4j.

Setup

Prerequisites

  • Python 3.11
  • Conda (Miniconda or Anaconda)
  • Neo4j database (can be run via Docker)

Installation

  1. Create and activate the conda environment:
conda create -n ai python=3.11 -y
conda activate ai
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables: Copy the .env file and add your OpenAI API key:
# Edit .env file and add your OpenAI API key
OPENAI_API_KEY=your-actual-api-key-here
  1. Start Neo4j (if using Docker):
docker-compose up -d

Running the Script

conda activate ai
python main.py

Features

  • User Intent Understanding: Understands knowledge graph requirements
  • File Discovery: Automatically discovers and selects relevant files
  • Schema Design: Designs schema for structured data (CSV)
  • Entity Extraction: Extracts entities from unstructured data (Markdown)
  • Graph Construction: Builds the knowledge graph in Neo4j

Configuration

The main configuration options are in the .env file:

  • NEO4J_URI: Neo4j connection URI
  • NEO4J_USER: Neo4j username
  • NEO4J_PASSWORD: Neo4j password
  • OPENAI_API_KEY: OpenAI API key
  • OPENAI_BASE_URL: (Optional) Custom OpenAI-compatible endpoint
  • DATA_DIR: Directory containing data files

Project Structure

kg-experiment/
├── main.py           # Main pipeline script
├── requirements.txt  # Python dependencies
├── .env             # Environment variables
├── docker-compose.yaml # Neo4j Docker setup
├── data/            # Data directory for CSV and Markdown files
└── notebooks/       # Jupyter notebooks for experiments

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors