A PDF Question-Answering App built with RAG (Retrieval-Augmented Generation), allowing users to upload PDFs and ask context-based questions.
Powered by Streamlit, LangChain, Ollama, and Chroma/FAISS for efficient and accurate answers.
This project is a Retrieval-Augmented Generation (RAG) based Question-Answering System where users can upload a PDF document and ask questions related to its content.
It extracts the text, splits it into chunks, stores it in a vector database, and uses a Large Language Model (LLM) to provide accurate, context-aware answers.
The RAG pipeline ensures that answers are based on real document context to minimize hallucination.
- π Upload PDF and extract text automatically.
- π Context-aware Q/A using RAG (retrieves relevant chunks before answering).
- β‘ Efficient Vector Search with Chroma/FAISS backend.
- π€ LLM-powered answers using Ollama + Llama 3.1.
- π₯οΈ Interactive GUI built with Streamlit for seamless use.
- π Handles temporary files securely during processing.
β Interactive web interface
β RAG pipeline
β Local LLM (
llama3.1,nomic-embed-text)β Vector similarity search
β Extract text from PDFs
Before running the project, make sure you have:
- π Python 3.9+ installed
- π¦ Ollama installed and running locally β Install Ollama
- π₯ Pull required models in Ollama:
ollama pull llama3.1 ollama pull nomic-embed-text
The repository is organized as follows:
pdf-qa-rag/
βββ app.py
βββ requirements.txt Follow these steps to set up and run the project locally:
git clone https://github.com/muqadasejaz/pdf-qa-rag-system.git2οΈβ£ Create a Virtual Environment (Recommended)
# For Windows
python -m venv venv
venv\Scripts\activate3οΈβ£ Install Dependencies
pip install -r requirements.txt4οΈβ£ Install Ollama & Pull Required Models
-
Download and install Ollama
-
Pull models locally:
ollama pull llama3.1
ollama pull nomic-embed-text5οΈβ£ Run the Application
streamlit run app.py6οΈβ£ Open in Browser
- Streamlit will provide a local URL (e.g. http://localhost:8501).
- Open it in your browser to access the PDF Question-Answering App.
-
Start the app by running:
streamlit run app.py
-
Open the Streamlit link in your browser (default: http://localhost:8501).
-
π Upload a PDF
- Use the file uploader to select any PDF (e.g., notes, research papers, or reports).
- β‘ Processing
- The system will extract text, split it into chunks, and store them in the vector database.
- π Ask Your Question
- Enter your query in the text box (e.g., "What is the main conclusion of this paper?").
- π‘ Get the Answer
- The LLM (Ollama + LangChain) retrieves the most relevant context and generates an accurate, context-based answer.
The system follows a RAG (Retrieval-Augmented Generation) pipeline for answering questions from PDFs.
- π PDF Documents β Uploaded by the user.
- π LangChain Pipeline β Handles:
- PDF Text Extraction
- Text Chunking
- Vector Store (Chroma/FAISS)
- π€ Ollama LLM β Uses
llama3.1for generating answers. - π‘ Generated Response β Delivered back to the user.
The application comes with a simple and interactive Streamlit-based UI.
Upload your PDF, enter your question, and get instant answers.
After uploading, the system extracts and processes the PDF text for querying.
Ask questions, and the system provides precise answers from the document.
- Answer Query 1:
- Answer Query 2:
- Output:
This project is built with the help of:
- LangChain β for chaining components in the RAG pipeline
- Ollama β for running LLaMA 3.1 locally
- Streamlit β for the user-friendly interface
- ChromaDB / FAISS β as vector databases for semantic search
- nomic-embed-text β for text embeddings
Special thanks to the open-source community for providing tools that make projects like this possible π
Muqadas Ejaz
BS Computer Science (AI Specialization)
AI/ML Engineer
Data Science & Gen AI Enthusiast
π« Connect with me on LinkedIn
π GitHub: github.com/muqadasejaz
This project is open-source and available under the MIT License.
