Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DOCUMIND — RAG System for Personal Documents

DOCUMIND is a local, privacy-first question-answering system that lets you chat with your own documents. You load a PDF, it gets embedded into a vector database, and you can ask natural language questions about its contents. Everything runs on your machine — no cloud APIs, no data leaving your system.

It is built around Retrieval-Augmented Generation (RAG): when you ask a question, the system retrieves the most relevant chunks from your document, re-ranks them using a cross-encoder for precision, and feeds them as context to a local language model which then generates an answer grounded entirely in the document.


How it works

  1. A PDF is loaded and split into overlapping text chunks of 500 characters each.
  2. Each chunk is embedded using nomic-embed-text via Ollama and stored in a ChromaDB vector database.
  3. At query time, the top 10 candidate chunks are retrieved by cosine similarity.
  4. A cross-encoder (ms-marco-MiniLM-L-6-v2) re-ranks those 10 candidates and selects the top 3.
  5. The top 3 chunks are assembled into a prompt and sent to llama3.2:3b running locally via Ollama.
  6. The model answers strictly from the provided context. If the answer is not there, it says so.
  7. The Gradio UI displays the answer, the source page numbers, and the raw evidence snippets.

Stack

Component Tool
PDF loading LangChain PyPDFLoader
Text splitting RecursiveCharacterTextSplitter
Embeddings nomic-embed-text (Ollama)
Vector store ChromaDB
Re-ranking cross-encoder/ms-marco-MiniLM-L-6-v2 (sentence-transformers)
Language model llama3.2:3b (Ollama)
UI Gradio

Requirements

  • Python 3.11+
  • Ollama installed and running locally
  • The following models pulled in Ollama:
ollama pull nomic-embed-text
ollama pull llama3.2:3b

Setup

Clone the repository and create a virtual environment:

git clone https://github.com/ShayanMuhammad-CS/DOCUMIND-RAG-Retrieval-Augmented-Generation-System-for-Personal-Documents.git
cd DOCUMIND-RAG-Retrieval-Augmented-Generation-System-for-Personal-Documents
python -m venv venv
venv\Scripts\activate        # Windows
# source venv/bin/activate   # Mac / Linux
pip install -r requirements.txt

Ingesting your document

Place your PDF in the project root (the default filename expected is ML.pdf, but you can change this in ingest.ipynb).

Open ingest.ipynb and run all cells. This will:

  • Load and chunk the PDF
  • Embed every chunk using nomic-embed-text
  • Store everything in a local chroma_db folder

This only needs to be done once per document. If you switch documents, delete the chroma_db folder and re-run the notebook.

Make sure Ollama is running before you ingest:

ollama serve

Running the app

python app.py

The Gradio interface will open in your browser at http://127.0.0.1:7860. Type a question, hit Send or press Enter, and the system will retrieve, re-rank, and answer from your document.


Project structure

.
├── app.py            # Main Gradio app — retrieval, re-ranking, generation, UI
├── ingest.ipynb      # One-time ingestion notebook — load PDF, embed, store
├── chat.ipynb        # Scratch notebook for testing queries
├── ML.pdf            # The document being queried (replace with your own)
├── chroma_db/        # Persisted vector store (generated after ingestion)
└── README.md

Notes

  • The model is instructed to answer only from the retrieved context. It will not hallucinate answers that are not supported by the document.
  • Re-ranking significantly improves precision over raw similarity search. The cross-encoder scores query-document pairs directly rather than comparing embeddings independently.
  • The system currently supports one document at a time. Multi-document support would require metadata filtering at retrieval time.
  • chroma_db is excluded from version control since it is large and machine-generated. Re-ingest after cloning.

Author

Shayan Muhammad

About

Local RAG system for querying PDFs and notes using ChromaDB, Ollama, CrossEncoder reranking, and Gradio.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages