A production-style Retrieval-Augmented Generation (RAG) pipeline that lets you chat with any PDF document. Built with LangChain, ChromaDB, sentence-transformers, and Gemini 1.5 Flash.
- 📤 Upload any PDF — research papers, reports, notes
- 🔍 Semantic search using
all-MiniLM-L6-v2embeddings - 🧠 Answers grounded in document context (no hallucination)
- 📍 Page-level source citations on every answer
- 🔎 View retrieved chunks with similarity scores
- 💬 Multi-turn chat history in session
PDF Upload
↓
Text Extraction (PyMuPDF)
↓
Chunking with overlap (LangChain RecursiveCharacterTextSplitter)
↓
Embedding (sentence-transformers: all-MiniLM-L6-v2)
↓
Vector Store (NumPy cosine similarity, in-memory)
↓
User Question → Embed → Cosine similarity search → Top 5 chunks
↓
Prompt = chunks + question → Gemini 1.5 Flash
↓
Answer + Page citations
rag-chatbot/
├── app.py ← Streamlit frontend
├── rag/
│ ├── loader.py ← PDF text extraction (PyMuPDF)
│ ├── chunker.py ← Text splitting with overlap
│ ├── embedder.py ← Embedding + ChromaDB storage
│ ├── retriever.py ← Semantic similarity search
│ └── generator.py ← Gemini API call + answer
├── requirements.txt
├── .env.example
├── .gitignore
└── README.md
git clone https://github.com/YOUR_USERNAME/rag-chatbot.git
cd rag-chatbotpython -m venv venv
source venv/bin/activate # Mac/Linux
venv\Scripts\activate # Windowspip install -r requirements.txt- Go to aistudio.google.com
- Click Get API Key → Create API key
- Copy the key (starts with
AIza...)
streamlit run app.pyEnter your API key in the sidebar, upload a PDF, and start chatting!
- Push this repo to GitHub
- Go to share.streamlit.io
- Connect your repo → set main file as
app.py - Under Settings → Secrets, add:
GEMINI_API_KEY = "AIza_your_key_here"| Component | Technology |
|---|---|
| Frontend | Streamlit |
| PDF Parsing | PyMuPDF (fitz) |
| Chunking | LangChain RecursiveCharacterTextSplitter |
| Embeddings | sentence-transformers (all-MiniLM-L6-v2) |
| Vector DB | NumPy cosine similarity (in-memory) |
| LLM | Gemini 1.5 Flash (Google AI) |
Sudeep — GitHub
CSE Graduate · AI/ML Engineer · Building real-world AI systems