PathRAG is an implementation of the paper "PathRAG: Pruning Graph-based Retrieval Augmented Generation with Relational Paths". This system improves retrieval-augmented generation by extracting and utilizing key relational paths from an indexing graph.
The application consists of four main components running in Docker containers:
-
Frontend (React + Vite)
- Modern UI built with Material-UI
- Interactive knowledge graph visualization
- File upload and query interface
- Real-time model selection and results display
-
Backend (FastAPI)
- RESTful API endpoints for data processing
- Knowledge graph construction
- Path-based retrieval implementation
- Integration with Weaviate and Ollama
-
Weaviate (Vector Database)
- Stores and indexes knowledge graph nodes
- Enables semantic similarity search
- Manages relationships between entities
-
Ollama (LLM Service)
- Local LLM deployment
- Handles query processing
- Generates natural language responses
-
Document Upload
- Support for PDF, TXT, and DOCX files
- Raw text input option
- Multiple file upload capability
- Progress tracking
-
Knowledge Base Management
- Create and manage multiple knowledge bases
- Add descriptions and metadata
- Organize documents by topic or domain
-
Knowledge Graph Visualization
- Interactive graph display
- Node and relationship exploration
- Path visualization for query results
-
Query Interface
- Natural language querying
- Model selection dropdown
- Query history tracking
- Detailed response visualization
-
Prerequisites
- Docker and Docker Compose
- Git
- 8GB+ RAM recommended
- NVIDIA GPU (optional, for improved LLM performance)
-
Clone the Repository
git clone https://github.com/your-username/PathRAG.git cd PathRAG
-
Environment Setup
# Start all services docker-compose up -d
-
Access the Application
- Frontend: http://localhost
- Backend API: http://localhost:8000
- Weaviate Console: http://localhost:8080
- Ollama API: http://localhost:11434
- Vite + React application
- Material-UI components
- Nginx for static file serving and API proxying
- Environment configuration via VITE_API_URL
- FastAPI application
- Uvicorn ASGI server
- File processing and KG construction
- Path-based retrieval implementation
- Vector database for KG storage
- RESTful and GraphQL APIs
- Configurable vectorizer modules
- Persistent data storage
- Local LLM service
- Multiple model support
- REST API for inference
- Model management
POST /upload/files
- Upload documentsPOST /upload/knowledge_base
- Create knowledge baseGET /query/kbs
- List knowledge bases
GET /query/models
- List available modelsPOST /query/query
- Execute queriesGET /query/graph
- Retrieve graph data
version: '3.8'
services:
frontend:
build: ./frontend
ports:
- "80:80"
environment:
- VITE_API_URL=
backend:
build: ./backend
expose:
- "8000"
environment:
- WEAVIATE_URL=http://weaviate:8080
- OLLAMA_URL=http://ollama:11434
weaviate:
image: semitechnologies/weaviate:1.24.1
environment:
- QUERY_DEFAULTS_LIMIT=20
- AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED=true
ollama:
image: ollama/ollama:latest
volumes:
- ollama-models:/root/.ollama
cd frontend
npm install
npm run dev
cd backend
pip install -r requirements.txt
uvicorn main:app --reload
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
[Add your license information here]