salvirezwan/Research-Paper-RAG-chatbot
0
Research Paper RAG Chatbot
An AI-powered agentic RAG (Retrieval-Augmented Generation) system for students and researchers. Upload research papers or fetch them live from arXiv, then query across them in natural language with cited, context-aware responses — streamed in real time.
Live Demo: Hugging Face Spaces
Features
- Upload PDFs — ingest your own research papers with a 4-step checkpointed pipeline
- Fetch from arXiv — download and index papers directly by arXiv ID
- Agentic RAG pipeline — LangGraph StateGraph with adaptive routing, document grading, and cited answer generation
- Real-time streaming — chat responses streamed via Server-Sent Events (SSE)
- Session isolation — each browser session has its own paper library and vector search scope
- PDF Viewer — read papers in-browser with page navigation
Architecture
RAG Pipeline (LangGraph StateGraph)
User Query → Router → [retrieve | live_fetch] → grade_docs → generator → citation → ENDIngestion Pipeline (4-step, checkpointed)
PDF → Parse (PyMuPDF) → Clean → Chunk → Embed (BAAI/bge-base-en-v1.5) → ChromaDBEach step is checkpointed in MongoDB. Retrying a failed ingestion skips already-completed steps.
Storage
API Routes
Quick Start (Local)
Prerequisites
- Python 3.11+
- MongoDB running on
localhost:27017 - uv (recommended) or pip
1. Clone the repo
git clone https://github.com/salvirezwan/Research-Paper-RAG-chatbot.git
cd "Research-Paper-RAG-chatbot/Academic Research RAG"2. Install dependencies
# Using uv (recommended)
pip install uv
uv sync
# Or using pip
pip install -r requirements.txt3. Configure environment
cp .env.example .envEdit .env:
GROQ_API_KEY=your_groq_api_key_here
MONGODB_URL=mongodb://localhost:27017
MONGODB_DATABASE_NAME=academic_research_rag
CHROMA_PERSIST_PATH=./data/chroma_db
CHROMA_COLLECTION_NAME=research_papers
GROQ_MODEL=llama-3.3-70b-versatile
EMBED_MODEL_NAME=BAAI/bge-base-en-v1.5
UPLOAD_DIR=uploads/documentsGet a free Groq API key at console.groq.com
4. Run
# Option A — dev shortcut (Windows, opens two terminals)
.\dev.bat
# Option B — manual
python -m uvicorn backend.main:app --host 0.0.0.0 --port 8000 --reload
streamlit run frontend/app.py- Backend: http://localhost:8000
- Frontend: http://localhost:8501
- API Docs: http://localhost:8000/docs
Docker (Full Stack)
docker compose -f docker/docker-compose.yml up --build- Frontend: http://localhost:8501
- Backend: http://localhost:8000
Hugging Face Spaces Deployment
The app runs as a single Docker container on a free HF Space (2 vCPU / 16 GB RAM).
Process layout
supervisord (PID 1)
├── nginx → port 7860 (reverse proxy)
│ ├── /api/* → 127.0.0.1:8000 (FastAPI)
│ └── /* → 127.0.0.1:8501 (Streamlit)
├── uvicorn → port 8000
└── streamlit → port 8501Ephemeral storage
Since HF Spaces has no persistent disk, the app uses:
- ChromaDB
EphemeralClient(in-memory vectors) - mongomock-motor
AsyncMongoMockClient(in-memory MongoDB) /tmp/uploads/for uploaded files
All data is lost on restart — expected behaviour for the free tier.
Deploy your own
- Create a new Space at huggingface.co → Docker SDK
- Push this repo to the Space's git remote
- Space Settings → Secrets: add
GROQ_API_KEY - Space Settings → Variables: add
APP_PUBLIC_URL=https://<your-username>-<your-space-name>.hf.space - First startup takes ~5 min (downloads the ~450 MB embedding model)
