A Retrieval-Augmented Generation (RAG) app that lets you chat with your PDF documents — 100% free, no OpenAI account, no API key, no credit card. Everything runs on your own machine using Ollama, including embeddings — no Python-native ML libraries (torch, scikit-learn, sentence-transformers) required. This matters on machines where Windows Application Control / Device Guard policies block unsigned compiled Python extensions.
- Local LLM + embeddings via Ollama (fully offline after models are pulled)
- Page-level source citations (
filename.pdf, page 3) - Streaming answers in the chat UI
- RAG system prompt — answers only from uploaded documents
- Persisted vector index — survives app restarts (
data/folder) - Configurable Ollama host (local, Docker, or remote)
- Clear chat, re-process, and clear index controls
| Layer | Tool |
|---|---|
| UI | Streamlit |
| RAG framework | LlamaIndex |
| LLM & embeddings | Ollama |
| PDF parsing | pypdf |
| Vector store | LlamaIndex in-memory index (persisted to disk) |
flowchart LR
A[Upload PDFs] --> B[pypdf page extraction]
B --> C[SentenceSplitter chunks]
C --> D[Ollama embeddings]
D --> E[Vector index on disk]
F[User question] --> G[Similarity search]
E --> G
G --> H[Top-k chunks + system prompt]
H --> I[Ollama LLM streaming]
I --> J[Answer + page sources]
pdf-chat-app/
├── app.py # Streamlit entry point
├── ui.py # Streamlit UI (sidebar, upload, chat)
├── config.py # Defaults, RAG prompt, paths
├── pdf_loader.py # PDF → page-level documents
├── ollama_client.py # Ollama health check & model listing
├── rag_engine.py # Index build/load, query engine, streaming
├── storage.py # Persist index + manifest on disk
├── requirements.txt
├── requirements-dev.txt
├── .env.example
├── LICENSE
└── data/ # Created at runtime (gitignored)
Download and install from https://ollama.com/download (Windows/Mac/Linux).
ollama pull llama3.2
ollama pull nomic-embed-textLow RAM (8GB or less):
ollama pull llama3.2:1b # ~1.3GB16GB+ RAM (better answers):
ollama pull llama3.1 # ~4.7GBVerify Ollama is running: open http://localhost:11434 — it should say "Ollama is running".
Python version: Use Python 3.12 or 3.13 (recommended). Python 3.14+ works with the pinned
dependencies in requirements.txt (numpy 2.x wheels). Older llama-index versions are not
compatible with Python 3.14.
git clone https://github.com/YOUR_USERNAME/pdf-chat-app.git
cd pdf-chat-app
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS / Linux
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements.txt(Optional) Copy environment config:
copy .env.example .env # Windows
# cp .env.example .env # macOS / Linuxstreamlit run app.pyOpen http://localhost:8501.
- Upload one or more PDFs.
- Click Process Documents — chunks are embedded and saved to
data/. - Ask questions in the chat — answers stream in with page-level sources.
- Use Clear Chat to reset messages (keeps the index).
- Use Re-process to rebuild the index from current uploads with latest settings.
- Use Clear Index to delete saved data and start fresh.
After processing once, restarting the app restores the index automatically from disk.
| Variable | Default | Description |
|---|---|---|
OLLAMA_HOST |
http://localhost:11434 |
Ollama API URL (set in .env or sidebar) |
Sidebar sliders control temperature, chunk size/overlap, and how many chunks are retrieved.
| Model | Approx. RAM | Notes |
|---|---|---|
llama3.2:1b |
~4 GB | Fastest, lightest |
llama3.2 |
~6–8 GB | Good default |
llama3.1 |
~10–12 GB | Best quality |
nomic-embed-text |
~300 MB | Required for embeddings |
Response speed depends on CPU/GPU — local models are slower than cloud APIs, but free and private.
| Problem | Fix |
|---|---|
| "Ollama is not reachable" | Start Ollama (ollama serve) or check OLLAMA_HOST |
| No models in dropdown | Run ollama pull llama3.2 and refresh the page |
| No embedding model warning | Run ollama pull nomic-embed-text |
| Empty PDF text | PDF may be scanned/image-only — needs OCR (not included) |
| Slow first response | Model loading into RAM — normal on first query |
| Windows "Application Control blocked" | This stack avoids torch/sklearn/chromadb by design |
Failed building wheel for numpy / Unknown compiler(s) on Windows |
Pip is compiling numpy from source (no wheel for your Python). Fix: upgrade pip (python -m pip install --upgrade pip setuptools wheel), pull latest requirements.txt (llama-index ≥0.12 + numpy ≥2), then reinstall. Or use Python 3.12/3.13 instead of 3.14. Do not install Visual Studio Build Tools just for numpy — use a wheel instead. |
| Restored index warning | Index was built against a different Ollama host — re-process if needed |
python -m pip install -r requirements-dev.txt
pytest- LLM: Ollama running an open-source model locally.
- Embeddings: Ollama embedding model (e.g.
nomic-embed-text). - Vector store: LlamaIndex index persisted under
data/— no paid API.
No data leaves your machine unless you point OLLAMA_HOST at a remote server.
MIT — see LICENSE.

