CoolFace
Apppublic

nvtitan/graphRAG

sourceHugging Facemitupdated 10mo agoView on Hugging Face
0likes
App README

πŸ•ΈοΈ GraphLLM - PDF Knowledge Graph + RAG System

Transform PDFs into interactive knowledge graphs with AI-powered Q&A.

πŸš€ Features

  • β€”πŸ“„ PDF Processing: Extract text, tables, and images from PDFs
  • β€”πŸ•ΈοΈ Knowledge Graph Generation: Build semantic graphs using Gemini AI
  • β€”πŸ” Vector Search: FAISS-powered semantic search with sentence transformers
  • β€”πŸ’¬ RAG Chat: Ask questions and get answers with source citations
  • β€”πŸŽ¨ Interactive Visualization: Explore knowledge graphs in your browser

πŸ› οΈ Technology Stack

  • β€”LLM: Google Gemini (gemini-2.5-flash)
  • β€”Embeddings: sentence-transformers/all-MiniLM-L6-v2
  • β€”Vector Store: FAISS with HNSW index
  • β€”Graph: NetworkX (in-memory)
  • β€”Backend: FastAPI + Uvicorn
  • β€”Frontend: Vanilla JS with D3.js/Cytoscape

πŸ“‹ Setup

Required: Gemini API Key

This app requires a Google Gemini API key:

  1. 1.Get your API key from Google AI Studio
  2. 2.Add it as a Secret in Hugging Face Spaces settings:
  3. 3.Name: GEMINI_API_KEY
  4. 4.Value: Your API key

Configuration (Optional)

You can set these environment variables in Space Settings:

bash
# LLM Settings
GEMINI_MODEL=gemini-2.5-flash     # Gemini model
LLM_TEMPERATURE=0.0               # Temperature for extraction

# Embedding Settings
EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2

# Environment
ENVIRONMENT=production
LOG_LEVEL=INFO

🎯 Usage

  1. 1.Upload PDF: Click "Upload PDF" and select your document
  2. 2.Wait for Processing: The system will:
  3. 3.Extract text chunks
  4. 4.Generate embeddings
  5. 5.Build knowledge graph with Gemini
  6. 6.Explore Graph: Click nodes to see details and related concepts
  7. 7.Ask Questions: Use the chat interface for Q&A with citations

πŸ“Š Graph Generation

  • β€”Per-Page Extraction: Max 2 concepts per page (quality over quantity)
  • β€”Parallel Processing: All pages processed concurrently via Gemini API
  • β€”Strict Filtering: Only technical/domain-specific concepts
  • β€”Co-occurrence Relationships: Concepts on same page are linked

🎨 Frontend

The frontend is a single-page application located in /frontend/:

  • β€”index.html - Main UI
  • β€”app.js - Graph visualization & API calls
  • β€”styles.css - Styling

Access it at: http://your-space-url.hf.space/frontend/

πŸ“¦ Docker

This Space uses Docker for deployment:

  • β€”Base: python:3.12-slim
  • β€”Port: 7860 (HF Spaces default)
  • β€”Health check enabled
  • β€”Persistent data directory

🀝 Credits

  • β€”LLM: Google Gemini
  • β€”Embeddings: Hugging Face sentence-transformers