contextIQ / README.md
satheeshbhukya
first commit
bd91918
---
title: ContextIQ
emoji: 🧠
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 7860
pinned: false
---
# ContextIQ - A Local RAG Based Secure Document Q&A System
ContextIQ is a fully local Retrieval-Augmented Generation (RAG) system that allows users to upload documents and ask AI-powered questions about their content β€” without using external APIs.
## Features
- **Multi-format Document Support**: PDF, Word (.docx), Excel (.xlsx), PowerPoint (.pptx), and Text (.txt)
- **Semantic Search**: Uses sentence transformers and FAISS for efficient vector similarity search
- **AI-Powered Answers**: Leverages OpenVINO LLM (Phi-3) for accurate question answering
- **Interactive UI**: Clean Streamlit interface with conversation history
- **Source Attribution**: Shows which document sections were used to generate answers
## Architecture
```
User Upload β†’ Document Parser β†’ Text Chunker β†’ Embedding Generator
↓
User Question β†’ Query Embedder β†’ FAISS Search β†’ Context Retrieval β†’ LLM β†’ Answer
```
## Prerequisites
- Python 3.8+
## Installation
### 1. Clone the repository
```bash
git clone https://github.com/satheeshbhukya/ContextIQ.git
cd ContextIQ
```
### 2. Create virtual environment
```bash
python -m venv venv
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate
```
### 3. Install dependencies
```bash
pip install -r requirements.txt
```
### 4. Model download
```bash
You must download OpenVINO Phi-3 model locally using python download_model.py
```
## Usage
### Run the application
```bash
streamlit run app.py
```
The app will open in your browser at `http://localhost:8501`
### Using the system
1. **Upload a document** using the sidebar file uploader
2. **Wait for processing** (you'll see a success message with chunk count)
3. **Ask questions** in the text input field
4. **View answers** with source attribution
5. **Check conversation history** to see previous Q&A pairs
## Project Structure
```
ContextIQ/
β”‚
β”œβ”€β”€ app.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
β”œβ”€β”€ .gitignore
β”‚
β”œβ”€β”€ scripts/
β”‚ β”œβ”€β”€ document_parser.py
β”‚ β”œβ”€β”€ text_processor.py
β”‚ β”œβ”€β”€ vector_store.py
β”‚ └── rag_engine.py
β”‚
β”œβ”€β”€ model/ ❌ NOT included in GitHub
β”‚ └── phi-3-openvino/
β”‚
└── data/ (optional FAISS index storage)
```
## Configuration
### Adjustable Parameters
In the sidebar, you can adjust:
- **Number of chunks to retrieve** (1-10): More chunks = more context but slower
## Example Use Cases
1. **Research Papers**: Upload PDFs and ask about methodologies, findings, conclusions
2. **Legal Documents**: Query contracts, agreements for specific clauses
3. **Business Reports**: Extract insights from quarterly reports, presentations
4. **Technical Documentation**: Search for specific procedures, configurations
5. **Academic Notes**: Ask questions about study materials, lecture slides
## Technical Stack
- **Frontend**: Streamlit
- **Document Processing**: PyMuPDF, python-docx, python-pptx, pandas
- **Text Processing**: LangChain
- **Embeddings**: Hugging Face sentence-transformers (all-MiniLM-L6-v2)
- **Vector Store**: FAISS
- **LLM**: OpenVINO Phi-3
-
## Flow Diagram
```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ QUICK REFERENCE β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Start App: streamlit run app.py β”‚
β”‚ Upload Doc: Browse files β†’ Select file β”‚
β”‚ Ask Question: Type β†’ Click Ask β”‚
β”‚ Adjust Chunks: Drag slider (1-10) β”‚
β”‚ Clear History: Click "Clear Chat History" β”‚
β”‚ New Document: Click "Reset Document" β”‚
β”‚ Stop App: Ctrl+C in terminal β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```
## Demo
![Demo Image 1](demo/image1.png)
![Demo Image 2](demo/image2.png)
## License
MIT License - feel free to use this project for personal or commercial purposes.
## πŸ“§ Contact
For questions or support, please open an issue on GitHub or contact [satheeshbhukyaa@gmail.com]
---
**⭐ If you find this project useful, please consider giving it a star!**