Production-ready RAG application for intelligent document understanding using multimodal AI, vector search and LLMs.
Chat with your documents (PDF, DOCX, Images), leverage powerful RAG, and toggle between local (Ollama) and cloud (Gemini) AI models.
- Text Documents: PDF, DOCX, TXT, Markdown, CSV
- Images: PNG, JPG, JPEG, BMP, TIFF, WEBP (with OCR + Vision AI)
- Web Content: Scrape and index URLs
- Multiple Sources: Combine different document types in one knowledge base
- Local (Ollama): 100% private, free, runs on your machine
- Cloud (Gemini): 5-10x faster, free tier available (60 req/min)
- Easy Toggle: Switch between providers with one setting
- Hybrid Mode: Use different providers for different tasks
- Multi-Project Management: Create isolated knowledge bases
- Persistent Conversations: Full chat history with search
- Source Attribution: See which documents answered each question
- Image Understanding: OCR text extraction + AI vision analysis
- Export Capabilities: JSON, CSV, PDF export formats
- Improved Retrieval: Hybrid search (semantic + keyword matching)
- Streamlit Web UI: Beautiful, intuitive interface
- Project Dashboard: Manage multiple knowledge bases
- Real-time Progress: See document processing status
- History & Search: Find past conversations instantly
- Python: 3.10 or higher
- Ollama: For local AI models (optional if using Gemini)
- RAM: 8GB minimum, 16GB recommended
- Storage: 10GB free space
# Linux/WSL
curl -fsSL https://ollama.com/install.sh | sh
# macOS
brew install ollama
# Start Ollama
ollama serve
# Pull models (in another terminal)
ollama pull qwen2.5:14b # Q&A model
ollama pull nomic-embed-text # Embeddings
ollama pull llava:7b # Vision (optional)# Clone repository
git clone https://github.com/YOUR_USERNAME/document_q_n_a.git
cd document_q_n_a
# Create virtual environment
python3 -m venv env
source env/bin/activate # Windows: env\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
nano .env # Add your API keys (optional)# Activate environment
source env/bin/activate
# Start the app
streamlit run app.py
# Open browser to: http://localhost:8501That's it! π
For local-only setup, no API keys needed. Just ensure Ollama is running:
LLM_PROVIDER=local
VISION_PROVIDER=localGet 5-10x faster responses with Google Gemini (free tier):
- Get API key: https://makersuite.google.com/app/apikey
- Update
.env:
LLM_PROVIDER=gemini
VISION_PROVIDER=gemini
GOOGLE_API_KEY=your_api_key_hereLLM_PROVIDER=gemini # Fast Q&A
VISION_PROVIDER=local # Private image processingSee .env.example for all available settings including:
- Model selection
- Chunk sizes
- Rate limits
- Storage paths
- LangSmith tracking (optional)
-
Create Project
- Go to "Knowledge Base" tab
- Click "Create New Project"
- Name it and add description
-
Add Documents
- Upload files (PDF, DOCX, images, etc.)
- Or add URLs to scrape
- Wait for processing (see progress bar)
-
Start Chatting
- Go to "Chat" tab
- Ask questions about your documents
- See source attribution for each answer
-
Review History
- Go to "History" tab
- Search past conversations
- Export to JSON/CSV/PDF
The system can extract text from images AND understand visual content:
Upload image.png β
ββ OCR (Tesseract) β Extract text
ββ Vision AI β Describe image content
ββ Combined β Full understanding
Supported formats: PNG, JPG, JPEG, BMP, TIFF, WEBP, GIF
| Feature | Local (Ollama) | Cloud (Gemini) |
|---|---|---|
| Speed | 20-45 sec/query | 2-5 sec/query |
| Cost | Free forever | Free tier (60/min) |
| Privacy | 100% private | Data sent to Google |
| Internet | Not required | Required |
| Quality | Excellent | Excellent |
| Images | LLaVA (slow) | Gemini Vision (fast) |
- LLM Framework: LangChain
- Local Models: Ollama (Qwen 2.5, LLaVA)
- Cloud Models: Google Gemini 2.5 Flash
- Vector DB: ChromaDB
- Database: SQLite (SQLAlchemy ORM)
- UI: Streamlit
- OCR: Tesseract, EasyOCR
- Document Processing: PyPDF, python-docx, BeautifulSoup
ββββββββββββββββ
β User Questionβ
ββββββββ¬ββββββββ
β
v
ββββββββββββββββββββββββ
β Hybrid Search β 1. Semantic search (vector similarity)
β (Semantic + Keyword) β 2. Keyword matching (BM25)
β β 3. Merge & re-rank results
ββββββββ¬ββββββββββββββββ
β
v
ββββββββββββββββββββ
β Retrieved Chunks β Top 10 most relevant passages
ββββββββ¬ββββββββββββ
β
v
ββββββββββββββββββββ
β LLM Generation β Qwen 2.5 or Gemini
β (with context) β β Grounded answer
ββββββββ¬ββββββββββββ
β
v
ββββββββββββββββββββ
β Answer + Sources β With document attribution
ββββββββββββββββββββ
document_q_n_a/
βββ app.py # Streamlit UI
βββ src/
β βββ config.py # Configuration management
β βββ database.py # SQLAlchemy models
β βββ cloud_providers.py # Gemini API wrapper
β βββ document_processor.py # Document parsing
β βββ image_processor.py # OCR + Vision AI
β βββ vector_store.py # ChromaDB operations
β βββ qa_chain.py # RAG implementation
β βββ improved_retrieval.py # Hybrid search
β βββ web_scraper.py # URL fetching
β βββ export_manager.py # Export functionality
β βββ session_manager.py # Project management
βββ data/ # Application data
β βββ app.db # SQLite database
β βββ projects/ # Project vector stores
βββ docs_backup/ # Documentation backups
βββ requirements.txt # Python dependencies
βββ .env.example # Configuration template
βββ README.md # This file
| Task | Local (Ollama) | Cloud (Gemini) |
|---|---|---|
| Q&A | 20-45 seconds | 2-5 seconds |
| Image Vision | 3-12 seconds | 1-3 seconds |
| OCR | 0.5-2 seconds | 0.5-2 seconds |
| Document Upload | 1-5 seconds | 1-5 seconds |
- CPU: Qwen 2.5:14b uses all available cores
- RAM: ~6-8GB for model + application
- Disk: ~5GB for models + your documents
- GPU: Optional (3-5x speedup if available)
# Check if Ollama is running
curl http://localhost:11434/api/tags
# Start Ollama
ollama serve
# Verify models are pulled
ollama list- Use Gemini for 5-10x faster responses (set
LLM_PROVIDER=gemini) - Use GPU if available (Ollama auto-detects)
- Reduce model size: Try
qwen2.5:7binstead of14b
# Install Tesseract OCR
# Ubuntu/Debian:
sudo apt-get install tesseract-ocr
# macOS:
brew install tesseract
# Windows: Download from https://github.com/UB-Mannheim/tesseract/wiki# Make sure you're in the project directory
cd document_q_n_a
# Activate virtual environment
source env/bin/activate- Multi-format document support
- Image processing (OCR + Vision)
- Cloud provider integration (Gemini)
- Hybrid search (semantic + keyword)
- Project management
- Conversation history
- Export functionality
-
Phase 1 (Next 2-4 weeks):
- Text-to-Image generation (Stable Diffusion)
- Speech-to-Text (Whisper)
- Text-to-Speech (Coqui TTS)
-
Phase 2 (1-2 months):
- Video analysis
- Audio processing
- Code assistant
- Advanced analytics dashboard
-
Phase 3 (Future):
- Multi-user support
- User authentication
- API endpoints
- Mobile app
See AI_SERVICE_EXPANSION_PLAN.md for details.
MIT License - see LICENSE file for details.
Feel free to use for personal or commercial projects!
Built with these amazing open-source projects:
- Ollama - Local LLM runtime
- LangChain - LLM orchestration framework
- ChromaDB - Vector database
- Streamlit - Web UI framework
- Google Gemini - Cloud AI API
- Qwen 2.5 by Alibaba Cloud
- LLaVA - Vision-Language model
- Documentation: See docs_backup/ for detailed guides
- Issues: Open an issue on GitHub
- Questions: Check documentation or open a discussion
If you find this project useful, please consider giving it a star!
Ready to start? Follow the Quick Start guide above! π