An AI-powered PDF Question Answering application built using Python, Streamlit, LangChain, Google Gemini, FAISS, and Retrieval-Augmented Generation (RAG).
The application allows users to upload any PDF document, ask questions in natural language, retrieve the most relevant information using a vector database, and generate accurate answers using Google's Gemini Large Language Model.
- 📂 Upload PDF documents
- 📖 Automatic PDF text extraction
- ✂️ Intelligent text chunking
- 🧠 Google Gemini Embeddings
- 🗄️ FAISS Vector Database
- 🔍 Similarity Search Retriever
- 🤖 Google Gemini 2.5 Flash LLM
- 💬 Context-aware Question Answering
- ⚡ Cached PDF Processing
- 🎨 Streamlit User Interface
User
│
▼
Upload PDF
│
▼
PyPDFLoader
│
▼
RecursiveCharacterTextSplitter
│
▼
Google Gemini Embeddings
│
▼
FAISS Vector Store
│
▼
Retriever
│
▼
Relevant PDF Chunks
│
▼
Google Gemini 2.5 Flash
│
▼
Final AI Answer
| Component | Technology |
|---|---|
| Programming Language | Python |
| Frontend | Streamlit |
| AI Framework | LangChain |
| Large Language Model | Google Gemini 2.5 Flash |
| Embeddings | Gemini Embedding Model |
| Vector Database | FAISS |
| PDF Loader | PyPDFLoader |
| Environment Variables | python-dotenv |
rag-pdf-chat-gemini/
│── app.py
│── requirements.txt
│── README.md
│── SETUP.md
│── VERSION_FIX.md
│── .env.example
│── .gitignore
Clone the repository
git clone https://github.com/YOUR_USERNAME/rag-pdf-chat-gemini.gitMove into the project folder
cd rag-pdf-chat-geminiCreate Virtual Environment
python -m venv .venvActivate Virtual Environment (Windows)
.venv\Scripts\activateInstall Required Packages
pip install -r requirements.txtCreate a file named
.env
Add your Google Gemini API Key
GOOGLE_API_KEY=YOUR_GOOGLE_API_KEYNote: Never upload your
.envfile to GitHub.
streamlit run app.pyThe application will start on
http://localhost:8501
Upload PDF
│
▼
Read PDF
│
▼
Split into Chunks
│
▼
Generate Embeddings
│
▼
Store in FAISS
│
▼
Retrieve Relevant Chunks
│
▼
Generate AI Answer
│
▼
Display Answer in Streamlit
(Add Screenshot Here)
screenshots/home.png
(Add Screenshot Here)
screenshots/upload.png
(Add Screenshot Here)
screenshots/answer.png
- User uploads a PDF.
- The PDF is loaded using PyPDFLoader.
- The extracted text is split into smaller chunks.
- Each chunk is converted into vector embeddings using Google Gemini Embeddings.
- The embeddings are stored inside a FAISS Vector Database.
- When the user asks a question, the Retriever finds the most relevant chunks.
- Those chunks are passed as context to Google Gemini 2.5 Flash.
- Gemini generates an accurate answer based on the retrieved context.
- The answer is displayed in the Streamlit application.
- ✅ Multiple PDF Support
- ✅ Chat History
- ✅ Conversation Memory
- ✅ Source Page References
- ✅ Save FAISS Index Locally
- ✅ Authentication
- ✅ Dark Mode UI
- ✅ Streamlit Cloud Deployment
This project demonstrates practical implementation of:
- Retrieval-Augmented Generation (RAG)
- LangChain Framework
- Google Gemini API
- Vector Embeddings
- FAISS Vector Database
- Streamlit Web Applications
- Prompt Engineering
- Semantic Search
- PDF Processing
- AI-powered Question Answering
N. Gopalakrishnan
Generative AI Learner
GitHub: https://github.com/YOUR_USERNAME
This project is licensed under the MIT License.