Skip to content

sudeisf/DOCUMIND-RAG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DocuMind-RAG

A lightweight Retrieval-Augmented Generation (RAG) API built with FastAPI, ChromaDB, SentenceTransformers embeddings, and Ollama.

The system:

  • Ingests .pdf and .txt files from data/
  • Splits documents into chunks
  • Stores embeddings in persistent ChromaDB (db/)
  • Answers questions grounded in retrieved context using llama3 via Ollama

Features

  • FastAPI backend with /ask endpoint
  • Local vector store using ChromaDB
  • PDF parsing via PyMuPDF (fitz)
  • Source citation list in responses
  • Docker Compose setup for API + Ollama

Project Structure

DocuMind-RAG/
├── main.py
├── requirements.txt
├── docker-compose.yml
├── DockerFile
├── data/
│   ├── raw_text/
│   └── source_pdfs/
├── db/
└── src/
    ├── ingest.py
    ├── query.py
    ├── schemas.py
    └── config.py

Prerequisites

  • Python 3.11+
  • Ollama installed and running (for local non-Docker run)
  • Git (optional)

Local Setup (Windows / macOS / Linux)

  1. Clone and enter the repo:
git clone https://github.com/sudeisf/DOCUMIND-RAG.git
cd DOCUMIND-RAG
  1. Create and activate virtual environment:

PowerShell

python -m venv venv
.\venv\Scripts\Activate.ps1

Git Bash

python -m venv venv
source venv/Scripts/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Start Ollama and pull model:
ollama pull llama3
ollama serve
  1. Add documents to data/ (or subfolders like data/raw_text/, data/source_pdfs/).

  2. Ingest documents:

python src/ingest.py
  1. Start API:
python -m uvicorn main:app --reload --host 127.0.0.1 --port 8000
  1. Open docs:

API Usage

Health Endpoint

GET /

Response:

{
  "message": "Welcome to DocuMind-RAG API"
}

Ask Endpoint

POST /ask

Request body:

{
  "question": "What does the policy say about retention period?"
}

Response body:

{
  "answer": "...",
  "sources": ["raw_text/policy.txt", "source_pdfs/guide.pdf"]
}

cURL Example

curl -X POST "http://127.0.0.1:8000/ask" \
  -H "Content-Type: application/json" \
  -d '{"question":"Summarize the key points"}'

Docker Setup

This repo includes docker-compose.yml for two services:

  • ollama on port 11434
  • api on port 8000

Run:

docker compose up --build

Then ingest data inside the API container (first-time / whenever docs change):

docker compose exec api python src/ingest.py

Open:

Notes

  • db/ is persisted and ignored by git except for a placeholder file.
  • Ingestion uses upsert semantics, so re-ingestion updates existing chunk IDs.
  • You may see a transformer load warning like embeddings.position_ids | UNEXPECTED; this is commonly benign for this embedding setup.

Troubleshooting

FastAPI.__init__() takes 1 positional argument...

Use keyword args when creating app (already fixed in this repo):

app = FastAPI(title="DocuMind-RAG API", version="1.0")

command not found in Git Bash after venv activation

If shell path gets corrupted, temporarily restore path:

export PATH="/usr/bin:/bin:/mingw64/bin:/c/Program Files/Git/cmd:$PATH"

Empty/weak answers

  • Ensure you ingested files: python src/ingest.py
  • Confirm docs exist under data/
  • Ensure Ollama is running and llama3 is available

About

A lightweight Retrieval-Augmented Generation (RAG) API built with FastAPI, ChromaDB, SentenceTransformers embeddings, and Ollama.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages