Skip to content
MuhammadAmasPublic

About

Chat with PDFs locally using NestJS, Ollama, and hybrid retrieval, with answers linked to source passages.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Docor

Chat with your PDFs — fully local. Upload a document, ask questions, get answers grounded in the text with source citations. No API keys. No cloud LLM.

Stack: NestJS · local embeddings (all-MiniLM-L6-v2) · Ollama (llama3.1:8b) · hybrid retrieval


Run (one command)

Prerequisites

  1. Node.js 18+
  2. Ollama installed (the start script will launch it and pull the model)
npm start

That single command will:

  1. Install npm dependencies (if needed)
  2. Start Ollama if it isn’t running
  3. Pull llama3.1:8b (first run only)
  4. Start the API + chat UI

Open http://localhost:3000

Upload a PDF in the UI, then ask questions.


Optional config

Copy the example env file and edit as needed:

cp .env.example .env
PORT=3000
OLLAMA_URL=http://localhost:11434
OLLAMA_MODEL=llama3.1:8b

Example with a smaller model (tighter RAM):

OLLAMA_MODEL=llama3.2:3b npm start

What you get

Surface URL
Chat UI http://localhost:3000
Health GET /health
Upload PDF POST /ingestion/upload (form field file)
Ask POST /query/ask { "question": "..." }
Status GET /ingestion/status
Clear store DELETE /ingestion/clear

How it works

  1. Ingest — PDF text → overlapping chunks → local embeddings → persisted store (data/store.json)
  2. Ask — embed the question → hybrid search (vectors + keywords + neighbor chunks) → prompt Ollama with cited context → answer + sources

Project layout

public/           # Docor chat UI
scripts/start.mjs # one-command launcher
src/
  embeddings/     # MiniLM via @xenova/transformers
  vector-store/   # in-memory + hybrid search + disk persistence
  llm/            # Ollama client
  ingestion/      # PDF upload → chunks → embeddings
  query/          # retrieval + prompt + answer

API-only / development

npm run start:api    # Nest watch mode, no Ollama bootstrap
npm run build && npm run start:prod

Tips

  • First embedding run downloads ~80MB (cached afterward).
  • Re-uploading the same filename replaces its old chunks.
  • If answers look wrong, check the sources under each reply — that shows what was retrieved.

About

Chat with PDFs locally using NestJS, Ollama, and hybrid retrieval, with answers linked to source passages.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages