Skip to content

Ollama PDF RAG

Chat with your PDFs locally using Ollama and LangChain

Welcome to the documentation for Ollama PDF RAG โ€” a powerful, privacy-first application that lets you have conversations with your PDF documents using local language models.

Next.js Chat Interface

๐ŸŒŸ Why Ollama PDF RAG?

Feature Benefit
๐Ÿ”’ 100% Local Your data never leaves your machine
๐Ÿš€ Two UIs Modern Next.js app OR classic Streamlit
๐Ÿ“„ Multi-PDF Support Query across multiple documents
๐Ÿง  Smart Retrieval Multi-query expansion for better results
โšก Fast API FastAPI backend for production use
๐ŸŽฏ Thinking Models Special support for qwen3, deepseek-r1

๐Ÿ—๏ธ Architecture Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        USER INTERFACE                        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚     Next.js (Modern UI)     โ”‚      Streamlit (Classic)      โ”‚
โ”‚     localhost:3000          โ”‚      localhost:8501           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      FastAPI Backend                         โ”‚
โ”‚                      localhost:8001                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  PDF Upload  โ”‚  RAG Query   โ”‚   Models     โ”‚   Health       โ”‚
โ”‚  /api/v1/    โ”‚  /api/v1/    โ”‚   /api/v1/   โ”‚   /health      โ”‚
โ”‚  pdfs        โ”‚  query       โ”‚   models     โ”‚                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ–ผ                   โ–ผ                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   ChromaDB      โ”‚ โ”‚    Ollama       โ”‚ โ”‚    SQLite       โ”‚
โ”‚   (Vectors)     โ”‚ โ”‚    (LLM)        โ”‚ โ”‚    (Metadata)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Quick Start

# 1. Clone and install
git clone https://github.com/tonykipkemboi/ollama_pdf_rag.git
cd ollama_pdf_rag
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

# 2. Install Ollama models
ollama pull llama3.2
ollama pull nomic-embed-text

# 3. Start the app (Next.js UI + FastAPI)
./start_all.sh
# Or manually:
# python run_api.py &
# cd web-ui && pnpm dev

# 4. Open http://localhost:3000

๐Ÿ“ธ Screenshots

Next.js Modern Interface

Next.js UI with PDF Chat

Streamlit Classic Interface

Streamlit UI

๐Ÿ“– Documentation

Section Description
Installation Full setup guide
Quick Start Get running in 5 minutes
PDF Processing How documents are processed
RAG Pipeline Understanding retrieval
Chat Interface Using the UIs
API Reference Backend API docs
Contributing How to contribute

๐Ÿ”ง Key Features

PDF Selection & Chat

  • โ˜‘๏ธ Checkbox Selection: Select PDFs before chatting
  • ๐Ÿ” Question Classification: Auto-detects if you need documents
  • ๐Ÿ’ฌ General Chat: Works without documents too
  • ๐Ÿ“š Multi-PDF: Query across multiple documents

RAG Pipeline

  • ๐Ÿ”„ Multi-Query Retrieval: Generates alternative queries
  • ๐Ÿงฉ Smart Chunking: 7500 char chunks with 100 overlap
  • ๐ŸŽฏ Source Citations: Every answer includes sources
  • ๐Ÿง  Chain-of-Thought: Thinking models show reasoning

Developer Experience

  • ๐Ÿ“ Type Safe: Full TypeScript frontend
  • ๐Ÿงช Tested: Python tests with pytest
  • ๐Ÿ”„ CI/CD: GitHub Actions for tests
  • ๐Ÿ“š Documented: MkDocs with full API reference

๐Ÿ“Š Project Status

Python Tests Documentation

๐Ÿค Community

๐Ÿ“„ License

This project is open source under the MIT License.