A comprehensive PDF Question-Answering system that combines Retrieval-Augmented Generation (RAG) with Qwen language models, cloud storage integration, and multilingual support. Upload PDFs from local storage, Google Drive, or Dropbox, and ask intelligent questions with context-aware, accurate answers.
- Dual Model Support: Choose between
Qwen/Qwen3-1.7BandQwen/Qwen3-4B - Intelligent GPU Management: Automatic model switching with memory optimization
- See Memory Usage: Track GPU usage and prevent OOM errors
- Dropbox Integration: Connect with access token, browse folders, select PDFs
- Google Drive Integration: OAuth2 and Service Account support
- Seamless File Management: List, select, and process files directly from cloud storage
- 15+ Languages: English, Hindi, Spanish, French, German, Portuguese, Russian, Japanese, Korean, Arabic, Chinese, Italian, Dutch, Turkish
- Hinglish Detection: Smart detection and handling of Hindi-English mixed text
- Language-Aware Responses: Automatically respond in the same language as the question
- Optimized Embeddings: Different embedding models for English-only vs multilingual mode
- Semantic Search: FAISS vector database with sentence-transformers embeddings
- Smart Document Chunking: Configurable text splitting with overlap control
- Context-Aware Responses: Only relevant document sections sent to the model
- Source Attribution: Track which document and page generated each answer
- Standalone AI Chat: Use the loaded model for general questions without documents
- Flexible Interface: Separate tab for non-document-based conversations
- Same Model, Multiple Uses: Switch between document Q&A and general chat
- Tabbed Interface: Organized workflow with Setup, Cloud Storage, Documents, General Chat, and Q&A tabs
- Real-time Status Updates: Detailed feedback for every operation
- Advanced Settings: Configurable parameters with helpful tooltips
- Responsive Design: Clean, intuitive design with proper spacing and styling
graph TD
A[Local PDFs] --> D[Document Processor]
B[Dropbox PDFs] --> C[Cloud Manager]
E[Google Drive PDFs] --> C
C --> D
D --> F[Text Splitter]
F --> G[Create Embeddings]
G --> H[FAISS Vector Store]
I[User Question] --> J[Language Detection]
J --> K[Semantic Search]
H --> K
K --> L[Retrieve Relevant Chunks]
L --> M[Qwen Language Model]
M --> N[Language-Aware Response]
N --> O[Source Attribution]
- Python 3.12
- CUDA 12.8 (for GPU acceleration)
- At least 4GB free disk space for models
- Internet connection for cloud storage features
git clone https://github.com/jaysheeldodia/QwInSight.git
cd QwInSightpython -m venv venv
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activatepip install -r requirements.txt# For Dropbox integration
pip install dropbox
# For Google Drive integration
pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib
# For multilingual support
pip install langdetectpython app.pyOpen your browser and navigate to:
http://localhost:7860
-
Choose Language Mode:
- English Only: Faster processing, optimized for English documents
- Multilingual: Supports 15+ languages with automatic detection
-
Select AI Model:
- Qwen/Qwen3-1.7B: Faster, requires ~3.5GB GPU memory
- Qwen/Qwen3-4B: More capable, requires ~8GB GPU memory
-
Load Model: Click "π Load Model" and wait for completion
- Go to Dropbox App Console
- Create a new app with "Full Dropbox" access
- Generate an access token
- Enter token in the Cloud Storage tab
- Connect and list your PDF files
Option A: Service Account (Recommended)
- Create a Google Cloud project
- Enable Google Drive API
- Create Service Account credentials
- Download JSON key file
- Share your Drive folder with the service account email
- Upload credentials and connect
Option B: OAuth2 (Not Recommended)
- Create OAuth2 credentials in Google Cloud Console
- Add
urn:ietf:wg:oauth:2.0:oobas redirect URI - Upload credentials JSON
- Complete authorization flow with the provided link
- Go to Documents β Local Upload tab
- Upload one or more PDF files
- Configure processing parameters:
- Chunk Size: 200-1000 characters (default: 500)
- Chunk Overlap: 0-200 characters (default: 50)
- Click "π Process Local Documents"
- Go to Documents β Cloud Files tab
- Files from connected cloud storage will appear
- Select desired files using checkboxes
- Use "Select All" or "Deselect All" for convenience
- Click "π Process Selected Cloud Files"
- Go to the "π¬ Ask Questions" tab
- Enter your question about the processed documents
- Adjust response settings:
- Response Length: 100-800 tokens
- Creativity: 0.1-1.0 temperature
- Context Sources: 1-8 relevant chunks
- Click "π€ Ask Question"
- Go to the "π General Purpose Chat" tab
- Ask any general question (not document-specific)
- Adjust response settings as needed
- Click "π¬ Ask"
| Mode | Speed | Languages | Embedding Model | Best For |
|---|---|---|---|---|
| English Only | β‘β‘β‘ | English | all-MiniLM-L6-v2 | English documents |
| Multilingual | β‘β‘ | 15+ languages | paraphrase-multilingual-MiniLM-L12-v2 | Mixed language documents |
| Model | Parameters | Speed | Quality | GPU Memory | Best For |
|---|---|---|---|---|---|
| Qwen/Qwen3-1.7B | 1.7B | β‘β‘β‘ | βββ | ~3.5GB | Quick answers, limited resources |
| Qwen/Qwen3-4B | 4B | β‘β‘ | ββββ | ~8GB | Complex analysis, detailed responses |
- 200-400: Best for specific details, technical documents
- 400-600: Balanced approach (recommended for most documents)
- 600-1000: Better for narrative documents, broader context
- 0-25: Minimal overlap, faster processing
- 25-75: Balanced approach (recommended)
- 75-200: Maximum context preservation, slower processing
- English: Native support with optimized embeddings
- Hindi: Full Devanagari script support
- Hinglish: Smart detection of Hindi-English mixed text
- European: Spanish, French, German, Italian, Dutch, Portuguese, Russian
- Asian: Japanese, Korean, Chinese, Arabic, Turkish
- Automatic Detection: Uses langdetect library for accurate language identification
- Hinglish Recognition: Custom patterns to detect Hindi-English mixed content
- Response Matching: Automatically responds in the same language as the question
- Script Support: Handles both Roman and native scripts
The system provides appropriate instructions to the AI model based on detected language:
- Hindi questions β Hindi responses (in Devanagari)
- Hinglish questions β Hinglish responses (Roman script)
- Spanish questions β Spanish responses
- And so on for all supported languages
- Simple Setup: Just need access token
- Folder Navigation: Browse specific folders or root directory
- File Information: Shows file size, modification date
- Batch Processing: Select multiple files for processing
- Flexible Authentication: Both OAuth2 and Service Account support
- Folder Filtering: Process files from specific folders
- Metadata Access: File size, modification date, full file information
- Secure Connection: Uses official Google APIs
- Temporary Downloads: Files downloaded to temporary directory
- Automatic Cleanup: Temporary files cleaned after processing
- Source Attribution: Answers show which cloud service files came from
- Error Handling: Comprehensive error messages for connection issues
| Document Source | Setup Time | Processing Speed | Memory Usage |
|---|---|---|---|
| Local Upload | Instant | 15-30 sec/doc | 2-4GB RAM |
| Dropbox | 2-5 sec | 20-35 sec/doc | 2-4GB RAM |
| Google Drive | 3-10 sec | 25-40 sec/doc | 2-4GB RAM |
| Language | Performance | Response Quality | Processing Speed |
|---|---|---|---|
| English | 99% | βββββ | Fastest |
| Others | 90% | ββββ | Medium |
- CPU: 8+ cores, 3.0+ GHz
- RAM: 16GB+
- Storage: 20GB+ free space
- GPU: NVIDIA with 10GB+ VRAM
- Internet: Stable broadband connection
- Local Processing: All AI processing happens locally on your machine
- Temporary Storage: Cloud files temporarily downloaded, then deleted
- No Data Transmission: Your documents and questions never leave your computer
- Secure APIs: Uses official cloud storage APIs with proper authentication
- Token Storage: Access tokens stored in memory only (not saved to disk)
- Automatic Cleanup: Credentials cleared when application closes
- Best Practices: Follow cloud provider security guidelines
FROM python:3.12-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Install optional dependencies
RUN pip install dropbox google-api-python-client google-auth-httplib2 google-auth-oauthlib langdetect
# Copy application
COPY . .
EXPOSE 7860
CMD ["python", "app.py"]# Install production server
pip install gunicorn
# Run with multiple workers (adjust based on your system)
gunicorn -w 1 -b 0.0.0.0:7860 --timeout 300 --worker-class uvicorn.workers.UvicornWorker app:app
# Or use the built-in Gradio server for production
python app.pyWe welcome contributions! Please see our Contributing Guidelines for details.
git clone https://github.com/jaysheeldodia/QwInSight.git
cd QwInSight
python -m venv dev-env
source dev-env/bin/activate # or dev-env\Scripts\activate on Windows
pip install -r requirements.txtThis project is licensed under the MIT License - see the LICENSE file for details.
- Hugging Face: For the Transformers library and model hosting
- LangChain: For the RAG framework and document processing tools
- Gradio: For the intuitive web interface framework
- FAISS: For efficient similarity search and vector operations
- Google: For Drive API and authentication libraries
- Dropbox: For cloud storage API and SDK
β Star this repository if you find it helpful!