Knowledge2Model/GraphRAG
Hitesh Karakoti d740773dd1 update v1 2025-08-03 23:22:25 +02:00
..
backup_neo4j Improve rag 2025-07-10 07:59:03 +02:00
embedding Improve rag 2025-07-10 07:59:03 +02:00
Readme.md Improve rag 2025-07-10 07:59:03 +02:00
chatbot_backend.py update v1 2025-08-03 23:22:25 +02:00
chatbot_frontend.html add v1 Graph RAG 2025-06-03 07:23:41 +02:00
db2annoy.py update v1 2025-08-03 23:22:25 +02:00
db2neo4j.py add v1 Graph RAG 2025-06-03 07:23:41 +02:00
semantic_search.py update v1 2025-08-03 23:22:25 +02:00

Readme.md

README

This repository contains scripts and tools for processing, indexing, and querying a SQL-based knowledge graph, plus a simple chat interface. Below is an overview of each component and instructions for exporting/importing the Neo4j database.


Scripts

1. db2annoy.py

Stage 1 Preprocessing Generate the following files for semantic search:

  • model_metadata.json
  • model_index.ann

2. db2neo4j.py

Stage 2 Neo4j SQL → Neo4j Conversion

Convert the SQL knowledge graph into a Neo4j database using URI-style labels (similar to db2rdf).

3. semantic_search.py

Stage 1 Search Test

Load the Annoy index and perform nearest-neighbor queries on the embedding space (pre-step to GRAG; no Neo4j interaction).

4. chatbot_backend.py

Flask Backend

Implements the full two-stage GRAG pipeline (semantic search + graph queries), with optional conversation history. Connects to an LLM via LMStudio or any HTTP-based service.

5. chatbot_frontend.py

HTML Frontend

Minimal chat interface for testing the backend.

Neo4j Database Dump & Restore

Export (Dump)

sudo neo4j-admin dump system \
  --to-path=<path>/Knowledge2Model/GraphRAG/backup_neo4j

sudo neo4j-admin dump neo4j \
  --to-path=<path>/Knowledge2Model/GraphRAG/backup_neo4j

Import (Load)

sudo neo4j-admin database load system \
  --from-path=<path>/Knowledge2Model/GraphRAG/backup_neo4j \
  --overwrite-destination=true

sudo neo4j-admin database load neo4j \
  --from-path=<path>/Knowledge2Model/GraphRAG/backup_neo4j \
  --overwrite-destination=true

sudo chown -R neo4j:neo4j /var/lib/neo4j/data

Neo4j Credentials

Set environment variables or update your .env file:

NEO4J_URI="bolt://localhost:7687"
NEO4J_USER="neo4j"
NEO4J_PASSWORD="12345678"