An AI-powered PDF Question Answering application built using Python and Streamlit. This project uses Retrieval-Augmented Generation (RAG) to retrieve relevant information from uploaded PDF documents and generate context-aware answers using a Large Language Model (LLM).
- PDF Upload: Upload PDF documents through a user-friendly interface.
- Text Extraction: Extract text from PDF pages for processing.
- Text Chunking: Split document content into smaller chunks for efficient retrieval.
- Embeddings Generation: Convert text chunks into vector representations.
- Vector Database: Store and retrieve document embeddings using ChromaDB.
- Semantic Search: Retrieve relevant document chunks based on user questions.
- AI-Powered Answers: Generate answers using retrieved context and an LLM.
- Interactive UI: Use a Streamlit interface to upload documents and ask questions.
- Python
- Streamlit
- ChromaDB
- Embedding Models
- Large Language Models (LLMs)
- Retrieval-Augmented Generation (RAG)
PDF_RAG_Chatbot/
│
├── app.py # Streamlit application interface
├── rag_pipeline.py # PDF processing and RAG pipeline
├── requirements.txt # Python dependencies
├── .gitignore # Files excluded from Git
└── README.md # Project documentation
The chroma_db/ directory may be created locally to persist vector embeddings, depending on the application configuration. It is excluded from version control when configured in .gitignore.
- Upload a PDF document.
- Extract text from the PDF.
- Split the extracted text into manageable chunks.
- Generate embeddings for the chunks.
- Store the embeddings in ChromaDB.
- Enter a question about the uploaded document.
- Retrieve the most relevant chunks using semantic search.
- Pass the retrieved context and question to an LLM.
- Display the generated answer in the Streamlit application.
git clone https://github.com/thecoder-prog/PDF_RAG_Chatbot.git
cd PDF_RAG_Chatbotpython -m venv .venvActivate it on Windows:
.venv\Scripts\activateOn Linux or macOS:
source .venv/bin/activatepip install -r requirements.txtIf your selected LLM provider requires an API key, configure it using environment variables or Streamlit secrets.
Do not hardcode API keys in source code or commit them to GitHub.
streamlit run app.pyOpen the local URL displayed in the terminal.
The application can be deployed using Streamlit Community Cloud, subject to the application's dependencies, API requirements, and available resources.
Deployment: https://share.streamlit.io/
- Do not upload confidential PDFs or sensitive documents to a public repository.
- Do not commit API keys, passwords, or
.envfiles. - Exclude generated vector databases and temporary files when they are not required.
- Review the privacy policies of any external LLM or embedding provider before sending document content.
- Support for multiple PDF documents.
- Display page numbers and document citations in answers.
- Add chat history and conversational memory.
- Support additional document formats such as DOCX and TXT.
- Improve retrieval using hybrid search and reranking.
- Add answer evaluation and retrieval quality metrics.
Yogesh Bhore
GitHub: https://github.com/thecoder-prog
No license has been specified yet. All rights are reserved unless a license is added to this repository. Contact the author for permission to reuse or distribute the code.