Skip to content

About

Local RAG app to chat with PDFs. Offline-ready with Ollama — no OpenAI, no credit card.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

PDF Chat App (Free & Local Edition)

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.

Features

  • 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

Screenshots

Main UI

Chat with sources

Tech stack

Layer Tool
UI Streamlit
RAG framework LlamaIndex
LLM & embeddings Ollama
PDF parsing pypdf
Vector store LlamaIndex in-memory index (persisted to disk)

Architecture

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]
Loading

Project structure

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)

Setup

1. Install Ollama

Download and install from https://ollama.com/download (Windows/Mac/Linux).

2. Pull a chat model and an embedding model

ollama pull llama3.2
ollama pull nomic-embed-text

Low RAM (8GB or less):

ollama pull llama3.2:1b     # ~1.3GB

16GB+ RAM (better answers):

ollama pull llama3.1        # ~4.7GB

Verify Ollama is running: open http://localhost:11434 — it should say "Ollama is running".

3. Clone and install

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 / Linux

4. Run the app

streamlit run app.py

Open http://localhost:8501.

Usage

  1. Upload one or more PDFs.
  2. Click Process Documents — chunks are embedded and saved to data/.
  3. Ask questions in the chat — answers stream in with page-level sources.
  4. Use Clear Chat to reset messages (keeps the index).
  5. Use Re-process to rebuild the index from current uploads with latest settings.
  6. Use Clear Index to delete saved data and start fresh.

After processing once, restarting the app restores the index automatically from disk.

Configuration

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.

Hardware requirements

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.

Troubleshooting

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

Development

python -m pip install -r requirements-dev.txt
pytest

How it's free

  • 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.

License

MIT — see LICENSE.

About

Local RAG app to chat with PDFs. Offline-ready with Ollama — no OpenAI, no credit card.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages