Enterprise RAG Platform
High-precision hybrid vector retrieval over 5M+ knowledge records with GraphRAG knowledge graph traversals.
π Project Overview
This project delivers a production-grade Retrieval-Augmented Generation (RAG) platform. It utilizes a hybrid retrieval strategy combining sparse keyword matching (BM25) with dense vector searches on Weaviate, followed by metadata filters and a re-ranking pipeline.
To address context limits and cross-document dependencies, it implements GraphRAG utilizing a Neo4j graph schema to map conceptual entities and their relationships. This allows the system to traverse multi-hop connections, providing contextually rich prompts to LLMs and cutting hallucination rates significantly.
βοΈ Deployment Checklist & Runbook
Initialize Weaviate Schema
Create schemas for vector indexes, configuring HNSW search parameters and distance metrics:
import weaviate
client = weaviate.Client("http://weaviate.rag-system.svc:8080")
class_obj = {
"class": "DocumentChunk",
"vectorizer": "text2vec-openai",
"vectorIndexConfig": {
"distance": "cosine",
"efConstruction": 128,
"maxConnections": 64
}
}
client.schema.create_class(class_obj)
Deploy Graph Schemas (Neo4j)
Establish graph constraints to ensure unique index keys for entities during imports:
CREATE CONSTRAINT unique_entity IF NOT EXISTS
FOR (e:Entity) REQUIRE e.id IS UNIQUE;
CREATE INDEX relationship_type FOR ()-[r:RELATED_TO]-() REQUIRE r.weight IS DEFINED;
Setup Ingestion Service
Provision the ingestion backend with hybrid index scaling triggers:
helm install rag-ingestion charts/rag-ingestion \
--set replicaCount=3 \
--set resources.requests.memory="2Gi" \
-n rag-platform
π Configuration & Key Parameters
| Param Key | Module Location | Purpose |
|---|---|---|
WEAVIATE_URL |
config.py |
The target URL for the vector repository. |
NEO4J_URI |
config.py |
Database connection address for entity mappings. |
HYBRID_ALPHA |
retriever.py |
Alpha parameter (0=BM25 only, 1=Vector only, 0.5=Equal weight). |
RERANK_MODEL |
reranker.py |
The cross-encoder model to re-evaluate top retrieval matches. |
π Architectural Workflow
π οΈ Useful CLI Reference
# Run schema indexing script:
python scripts/index_documents.py --dir ./data
# Monitor Weaviate container nodes:
curl -s http://localhost:8080/v1/nodes
# Audit Graph constraints in Neo4j:
cypher-shell -u neo4j -p password "SHOW CONSTRAINTS;"
# Test retrieval latency performance:
pytest tests/test_retrieval.py -s