| # β‘ Nexus AI β Smart Document Analyzer |
|
|
| A production-grade RAG (Retrieval-Augmented Generation) system for intelligent PDF Q&A with real semantic search, page-level citations, and multi-document support. |
|
|
| --- |
|
|
| ## π Features |
|
|
| | Feature | Description | |
| |---|---| |
| | **Real Semantic Search** | Uses `sentence-transformers` + cosine similarity β not keyword matching | |
| | **Multi-PDF Support** | Upload and query across multiple documents simultaneously | |
| | **Page Citations** | Every answer shows exact source page + relevance score | |
| | **Auto Summary** | Document is summarized automatically on upload | |
| | **Dual API** | Switch between Groq (Llama 3.1) and Google Gemini with one click | |
| | **Conversation Memory** | Follow-up questions retain context from previous turns | |
| | **Export Chat** | Download your full Q&A session as a text file | |
|
|
| --- |
|
|
| ## π Setup (Local) |
|
|
| ### 1. Clone & install |
| ```bash |
| git clone <your-repo> |
| cd nexus-ai |
| pip install -r requirements.txt |
| ``` |
|
|
| ### 2. Get API keys (both free) |
| - **Groq**: https://console.groq.com β Create API key |
| - **Gemini**: https://aistudio.google.com β Get API key |
|
|
| ### 3. Run |
| ```bash |
| streamlit run app.py |
| ``` |
|
|
| Enter your API key(s) in the sidebar when the app opens. |
|
|
| --- |
|
|
| ## βοΈ Deploy to Streamlit Community Cloud (Recommended) |
|
|
| 1. Push your code to a **public GitHub repo** |
| 2. Go to [share.streamlit.io](https://share.streamlit.io) |
| 3. Connect your GitHub β Select `app.py` |
| 4. Add secrets in **Settings β Secrets**: |
| ```toml |
| GROQ_API_KEY = "gsk_..." |
| GEMINI_API_KEY = "AIza..." |
| ``` |
| 5. Click **Deploy** β done in ~2 minutes β
|
|
|
| --- |
|
|
| ## π Architecture |
|
|
| ``` |
| PDF Upload |
| β |
| βΌ |
| Page-by-Page Text Extraction (pypdf) |
| β |
| βΌ |
| Semantic Chunking (280 words, 55 overlap) |
| β |
| βΌ |
| Embedding Generation (all-MiniLM-L6-v2) |
| β |
| βΌ |
| In-memory Vector Store (numpy arrays) |
| β |
| Query |
| β |
| βΌ |
| Semantic Search (cosine similarity, top-5) |
| β |
| βΌ |
| Context + Citations β LLM (Groq / Gemini) |
| β |
| βΌ |
| Answer with Page Citations + Relevance Scores |
| ``` |
|
|
| --- |
|
|
| ## π Project Structure |
|
|
| ``` |
| nexus-ai/ |
| βββ app.py # Main application |
| βββ requirements.txt # Dependencies |
| βββ README.md # This file |
| ``` |
|
|
| --- |
|
|
| ## π Key Technical Concepts Demonstrated |
|
|
| - **RAG Pipeline** β Full retrieval-augmented generation from scratch |
| - **Semantic Embeddings** β Sentence transformers for meaning-based search |
| - **Vector Similarity** β Cosine similarity for chunk retrieval |
| - **LLM Integration** β Multi-provider API abstraction |
| - **Context Window Management** β Conversation history with truncation |
| - **PDF Processing** β Page-level text extraction and chunking |
|
|
| --- |
|
|
| ## π· Tech Stack |
|
|
| `Python` `Streamlit` `sentence-transformers` `scikit-learn` `pypdf` `Groq API` `Google Gemini API` `NumPy` |
|
|