ChatPDF is a locally hosted application that enables users to interactively query the contents of PDF documents. It leverages Retrieval-Augmented Generation (RAG) technology to generate context-aware answers using only the information found in the uploaded PDFs. ChatPDF provides a simple, user-friendly web interface for document ingestion and question answering, powered entirely by local resources—no internet-based APIs are required after setup.
- Streamlit – For building the graphical web interface
- LangChain – Manages interaction between LLMs, embeddings, and retrieval
- ChromaDB – Local vector database for storing and retrieving document chunks
- Ollama – Hosts Large Language Models (LLMs) like Mistral locally
- Operating System: Windows 10/11, macOS, or Linux
- Python: Version 3.10 or higher
- Memory (RAM): Minimum 4 GB
- Storage: At least 5 GB available disk space
- Internet: Only required for setup (to install packages and download the model)
💡 How to open Command Prompt / Terminal:
- Windows: Press
Windows + R, typecmd, and press Enter- macOS: Use Spotlight (
Cmd + Space) and search for "Terminal"- Linux: Open the Terminal from your application menu or press
Ctrl + Alt + T
ChatPDF_Project/
├── main.py # Application backend
├── app.py # Streamlit frontend
├── requirements.txt # Python dependencies
└── vectorstores/ # Auto-generated when app runs
- Download from: python.org/downloads
- During installation, check the box for "Add Python to PATH"
- Verify installation:
It should return
python --version
Python 3.10or higher.
In your project folder:
# Create a virtual environment
python -m venv venv
# Activate the environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate💡 You should see
(venv)appear before your prompt, meaning the virtual environment is active.
Create a file named requirements.txt with the following content:
streamlit
streamlit-chat
langchain
langchain-community
langchain-ollama
langchain-chroma
chromadb
pypdf
jq
Then install:
pip install -r requirements.txt- Download and install from ollama.com/download
- Then run:
This will download (~1.4 GB) and start the Mistral model locally.
ollama run deepseek-r1:1.5b ollama run nomic-embed-text
Ensure your folder has these two files with the following content:
main.py– [Full backend logic]app.py– [Streamlit frontend interface]
📁 Make sure these are in the same directory as your
requirements.txt.
From the project directory (and with the virtual environment activated):
streamlit run app.pyYour browser will open automatically or show a local link (e.g., http://localhost:8501).
- Click Upload PDFs to ingest your documents
- Type a question and click Send
- View document-aware answers in the chat
- Use 🗑️ Delete All Data to reset and clear vector memory
- ✅ General JSON Support: Ingest both
defectList[](e.g., MRT damage logs) andcategory[].elements[](e.g., masonry catalog). - ✅ Prompt Improvements: Short, clear, paragraph-only answers. Avoids repetition, bullets, and numbering.
- ✅ Flexible Retrieval: Loosened similarity threshold for better JSON matching.
- ✅ Cleaner UI Flow: Auto-detection of PDF vs. JSON during upload; graceful error handling.
- ✅ Automatic Truncation: Ensures concise 3-sentence answers even if the model overruns.
This project is licensed under the MIT License.