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.
- A PDF is loaded and split into overlapping text chunks of 500 characters each.
- Each chunk is embedded using
nomic-embed-textvia Ollama and stored in a ChromaDB vector database. - At query time, the top 10 candidate chunks are retrieved by cosine similarity.
- A cross-encoder (
ms-marco-MiniLM-L-6-v2) re-ranks those 10 candidates and selects the top 3. - The top 3 chunks are assembled into a prompt and sent to
llama3.2:3brunning locally via Ollama. - The model answers strictly from the provided context. If the answer is not there, it says so.
- The Gradio UI displays the answer, the source page numbers, and the raw evidence snippets.
| 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 |
- Python 3.11+
- Ollama installed and running locally
- The following models pulled in Ollama:
ollama pull nomic-embed-text
ollama pull llama3.2:3b
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.txtPlace 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_dbfolder
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 servepython app.pyThe 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.
.
├── 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
- 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_dbis excluded from version control since it is large and machine-generated. Re-ingest after cloning.
Shayan Muhammad