A powerful Streamlit application that allows you to upload documents and ask questions about them using Retrieval-Augmented Generation (RAG) with local LLM processing.
- Document Upload Support: PDF, DOCX, and TXT files
- Real-time Progress Tracking: Visual progress indicators during document processing
- Local Processing: All data processing happens locally using Ollama
- Smart Chunking: Intelligent text splitting with sentence boundary detection
- Vector Search: ChromaDB for efficient similarity search
- Caching: Optimized performance with smart caching mechanisms
- Performance Metrics: Track response times and query statistics
- Interactive Chat Interface: User-friendly chat experience with streaming responses
Before running this application, make sure you have:
- Python 3.8+ installed
- Ollama installed and running locally
- Gemma3 model downloaded in Ollama
- Download and install Ollama from https://ollama.ai
- Pull the Gemma3 model:
ollama pull gemma3
-
Clone the repository:
git clone https://github.com/hari7261/Document-Q-A-LLM.git cd Document-Q-A-LLM
-
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Start the application:
streamlit run app.py
-
Open your browser and navigate to
http://localhost:8501
-
Upload documents:
- Use the sidebar to upload PDF, DOCX, or TXT files
- Click "Process Documents" to index your files
- Watch the real-time progress tracking
-
Ask questions:
- Type your questions in the chat input
- Get AI-powered answers based on your documents
- View source citations for transparency
Document-Q-A-LLM/
├── app.py # Main Streamlit application
├── requirements.txt # Python dependencies
├── README.md # Project documentation
├── .gitignore # Git ignore rules
├── LICENSE # License file
├── setup.py # Package setup file
├── chroma_db/ # ChromaDB storage (created automatically)
│ └── chroma.sqlite3 # Vector database
├── .github/ # GitHub templates and workflows
│ └── ISSUE_TEMPLATE/ # Issue templates
└── docs/ # Additional documentation
├── installation.md
├── usage.md
└── api.md
- Temperature: Control randomness in responses (0.0 - 1.0)
- Model: Currently supports Gemma3 (more models can be added)
- Caching: Responses are cached for 1 minute, search results for 5 minutes
- Chunking: Documents are split into 1000-character chunks with sentence boundary detection
- Batch Processing: Documents are processed in optimized batches
You can customize the application by modifying these parameters in app.py
:
# Chunk size for document splitting
chunk_size = 1000
# Number of relevant chunks to retrieve
k = 5
# Cache TTL settings
cache_ttl_responses = 60 # 1 minute
cache_ttl_search = 300 # 5 minutes
The application tracks:
- Average response time
- Last response time
- Total queries processed
Access these metrics through the expandable "Performance Metrics" section in the sidebar.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Large PDF files may take longer to process
- Ensure Ollama is running before starting the application
- ChromaDB requires write permissions in the project directory
-
"Model not found" error:
ollama pull gemma3
-
ChromaDB permission errors:
- Ensure the application has write permissions in the project directory
-
Slow processing:
- Check if Ollama is running locally
- Verify system resources (RAM, CPU)
If you encounter any issues or have questions:
- Open an issue on GitHub
- Check the documentation
- Review the troubleshooting section
- Streamlit for the amazing web framework
- Ollama for local LLM capabilities
- ChromaDB for vector database functionality
- SentenceTransformers for embeddings
Made with ❤️ by Hariom Kumar for the open-source community
Repository: https://github.com/hari7261/Document-Q-A-LLM