Skip to content

VijayMakkad/Deep-Researcher-RAG-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”¬ Deep Researcher - RAG Document Analysis System

A powerful Retrieval-Augmented Generation (RAG) system that enables intelligent document querying with multiple AI backends. Upload documents, ask questions, and get comprehensive answers powered by state-of-the-art language models.

🌟 Features

  • πŸ“„ Multi-format Document Support: PDF processing and text extraction
  • πŸ€– Multiple AI Backends:
    • LexRank: Extractive summarization for quick insights
    • DistilBART: Abstractive summarization for coherent responses
    • Ollama (LLaMA3): Large language model for comprehensive analysis
  • πŸ” Vector Search: FAISS-powered semantic search with sentence transformers
  • 🌐 Web Interface: Clean Streamlit UI with real-time backend switching
  • πŸš€ REST API: FastAPI backend with comprehensive documentation
  • 🐳 Docker Support: Containerized deployment with docker-compose
  • ☁️ Cloud Access: Cloudflare tunnel integration for public deployment

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Streamlit UI  │───▢│   FastAPI Backend │───▢│  AI Backends    β”‚
β”‚   (Port 8501)   β”‚    β”‚   (Port 8000)    β”‚    β”‚  - LexRank      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚  - DistilBART   β”‚
                                β”‚               β”‚  - Ollama       β”‚
                                β–Ό               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚  FAISS Vector DB β”‚
                       β”‚  + Document Store β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Live Demo

🌐 Main Application: https://deepresearcher.page
πŸ“– API Documentation: https://api.deepresearcher.page/docs

πŸ“‹ Prerequisites

πŸ› οΈ Installation

Option 1: Local Development

  1. Clone the repository

    git clone <your-repo-url>
    cd deep-researcher
  2. Create virtual environment

    python3 -m venv venv310
    source venv310/bin/activate  # On Windows: venv310\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Download NLTK data

    python -c "import nltk; nltk.download('punkt'); nltk.download('punkt_tab')"
  5. Install and start Ollama

    # Install Ollama from https://ollama.ai/
    ollama serve &
    ollama pull llama3

Option 2: Docker Deployment

  1. Start with Docker Compose

    docker-compose up -d --build
  2. Ensure Ollama is running on host

    ollama serve &
    ollama pull llama3

🎯 Usage

Starting the Application

Local Development:

# Terminal 1: Start FastAPI backend
source venv310/bin/activate
cd app
python main.py

# Terminal 2: Start Streamlit UI
source venv310/bin/activate
cd app
streamlit run streamlit_app.py --server.port 8501

# Terminal 3: Start Ollama (if not running)
ollama serve

Docker:

docker-compose up -d

Using the Interface

  1. Upload Documents: Drag and drop PDF files into the upload area
  2. Select AI Backend: Choose between LexRank, DistilBART, or Ollama
  3. Ask Questions: Type your questions about the uploaded documents
  4. Get Answers: Receive contextual responses based on document content

API Endpoints

  • POST /upload - Upload and process documents
  • POST /query - Query documents with specific backend
  • GET /backend - Get current active backend
  • POST /set_backend - Switch between AI backends
  • GET /docs - Interactive API documentation

πŸ”§ Configuration

Environment Variables

# Backend Configuration
SUMMARIZER_BACKEND=ollama          # Default backend: lexrank, distilbart, ollama
OLLAMA_MODEL=llama3               # Ollama model to use
OLLAMA_HOST=localhost:11434       # Ollama server address

# Docker Configuration
OLLAMA_HOST=host.docker.internal:11434  # For Docker deployments

Cloudflare Tunnel Setup

For public deployment with custom domain:

  1. Install cloudflared

    # macOS
    brew install cloudflare/cloudflare/cloudflared
    
    # Other platforms: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/
  2. Authenticate with Cloudflare

    cloudflared tunnel login
  3. Create tunnel

    cloudflared tunnel create deepresearcher
  4. Configure DNS routes

    cloudflared tunnel route dns deepresearcher deepresearcher.yourdomain.com
    cloudflared tunnel route dns deepresearcher api.deepresearcher.yourdomain.com
  5. Install as system service

    sudo cloudflared service install

πŸ—οΈ Project Structure

deep-researcher/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ main.py              # FastAPI backend server
β”‚   β”œβ”€β”€ streamlit_app.py     # Streamlit web interface
β”‚   β”œβ”€β”€ retreiver.py         # Document retrieval and vector search
β”‚   β”œβ”€β”€ summarizer.py        # AI backend implementations
β”‚   β”œβ”€β”€ ingest_and_index.py  # Document processing utilities
β”‚   β”œβ”€β”€ sample_docs/         # Example documents
β”‚   └── uploaded_docs/       # User uploaded documents
β”œβ”€β”€ venv310/                 # Python virtual environment
β”œβ”€β”€ .cloudflared/           # Cloudflare tunnel configuration
β”œβ”€β”€ docker-compose.yml      # Docker deployment configuration
β”œβ”€β”€ Dockerfile             # Container build instructions
β”œβ”€β”€ requirements.txt       # Python dependencies
└── README.md             # This file

🧠 AI Backends

LexRank

  • Type: Extractive summarization
  • Use Case: Quick document insights, key sentence extraction
  • Pros: Fast, preserves original text
  • Cons: Limited creativity, may miss context

DistilBART

  • Type: Abstractive summarization
  • Use Case: Coherent summaries, text generation
  • Pros: Natural language generation, contextual understanding
  • Cons: Moderate resource usage

Ollama (LLaMA3)

  • Type: Large Language Model
  • Use Case: Complex reasoning, detailed analysis
  • Pros: Comprehensive responses, advanced reasoning
  • Cons: Requires more computational resources

πŸ” Technical Details

Vector Search

  • Embedding Model: all-MiniLM-L6-v2 (384 dimensions)
  • Vector Database: FAISS with flat index
  • Similarity: Cosine similarity for document retrieval
  • Chunk Size: Optimized for document context

Document Processing

  • Supported Formats: PDF (via PyPDF2)
  • Text Extraction: Automatic preprocessing and cleaning
  • Storage: Local file system with metadata tracking

πŸš€ Deployment Options

Local Development

Perfect for testing and development with full control over all components.

Docker Container

Simplified deployment with consistent environment across platforms.

Cloud Deployment

Public access via Cloudflare tunnels with custom domain support.

πŸ›‘οΈ Security Considerations

  • Document uploads are stored locally
  • No data persistence beyond session for uploaded content
  • API endpoints are rate-limited
  • Cloudflare provides DDoS protection and SSL termination

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support

For questions, issues, or feature requests, please open an issue in the GitHub repository.


πŸ”¬ Happy Researching! πŸ”¬

About

πŸ”¬ Intelligent RAG system for document analysis with multi-AI backends (LexRank, DistilBART, Ollama). Upload PDFs, ask questions, get comprehensive answers. Features Streamlit UI, FastAPI, vector search, Docker deployment & Cloudflare tunnels.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors