An AI-powered system that allows users to upload PDFs and ask questions based on their content using Retrieval-Augmented Generation (RAG). The system combines semantic search + LLM reasoning to generate accurate, context-aware answers.
- Upload multiple PDF documents
- Extract text using PyMuPDF
- Intelligent text chunking with overlap
- Semantic search using Sentence Transformers
- FAISS vector database for fast similarity search
- Keyword-based filtering for improved accuracy
- Answer generation using Groq API (LLaMA model)
- Context-restricted prompting (reduces hallucination)
- ✅ Confidence Score (based on vector similarity)
- 📄 Source Citation (shows which PDF was used)
- 🔍 Highlighted Answer (important keywords in bold)
- 💬 Chat Memory (tracks previous interactions)
- Download generated answers as a
.txtfile - Stores latest response dynamically
- Interactive UI built with Gradio
- Chat-style interface for better user experience
- User uploads PDF(s)
- Text is extracted using PyMuPDF
- Text is split into overlapping chunks
- Chunks are converted into embeddings
- Stored in FAISS vector index
- User query is converted into embedding
- Relevant chunks are retrieved
- Chunks are cleaned and filtered
- Context is sent to LLM (Groq)
- Final answer is generated and displayed
- Python
- Gradio (UI)
- FAISS (Vector Search)
- Sentence Transformers (Embeddings)
- Groq API (LLaMA) (LLM)
- PyMuPDF (PDF Processing)
- NumPy
The system has been tested across:
- Functional scenarios (PDF upload, Q&A)
- Retrieval accuracy (semantic + keyword queries)
- Edge cases (empty input, no PDF, irrelevant queries)
- Feature validation (highlight, export, confidence score)
👉 See testcases.md for detailed test cases.
pip install -r requirements.txtpython app.pySet your Groq API key:
export GROQ_API_KEY=your_api_key(Add screenshots here)
This project can be deployed on:
- Hugging Face Spaces (Gradio)
- Streamlit Cloud
- Local environment
- 📄 Highlight exact sentences from PDF
- 📊 Advanced confidence scoring
- 🔎 Hybrid search (BM25 + FAISS)
- 🧠 Conversational memory with context retention
- 📁 Multi-format support (PDF + DOCX + Images)
Keshav Goyal
This project demonstrates an end-to-end implementation of Retrieval-Augmented Generation (RAG) combining vector search and LLM reasoning for real-world document question answering.