AI-Powered Academic Knowledge Assistant
Retrieval-Augmented Generation (RAG) System
MCA Prompt Engineering Assignment — Chanakya University
DocuMind AI is a production-quality RAG (Retrieval-Augmented Generation) system that lets you upload any PDF or TXT document and ask questions about it. The AI answers strictly from your uploaded documents — no hallucinations, no guessing.
Built as a Prompt Engineering assignment demonstrating the full RAG pipeline:
User Query → Embed Query → Vector Search → Retrieve Chunks → LLaMA 3 → Grounded Answer
- 📄 Upload PDF and TXT documents
- 🔍 Semantic similarity search using
all-MiniLM-L6-v2 - 🧠 Grounded answers using LLaMA 3 8B Instruct via OpenRouter
- 💾 Persistent ChromaDB vector store
- 📚 Source attribution — see exactly which chunks were used
- 💬 Multi-turn chat with history
- 🎨 Premium Streamlit UI with dark mode toggle
- ⚡ Cached models for fast loading
rag_project/
│
├── app.py ← Main Streamlit application
├── requirements.txt ← Python dependencies
├── .env.example ← Environment variable template
├── .gitignore
├── README.md
│
├── rag/
│ ├── pdf_loader.py ← Document loading & text extraction
│ ├── chunker.py ← Overlapping text chunking
│ ├── embeddings.py ← Sentence-transformer embeddings
│ ├── vector_store.py ← ChromaDB vector database
│ ├── retriever.py ← Semantic similarity retrieval
│ ├── llm.py ← OpenRouter API caller
│ └── rag_pipeline.py ← Orchestrates full RAG pipeline
│
└── assets/
└── styles.css ← Premium UI stylesheet
| Stage | Module | Description |
|---|---|---|
| 1. Ingestion | pdf_loader.py |
Extract clean text from PDF/TXT |
| 2. Chunking | chunker.py |
Split into 500-char overlapping chunks |
| 3. Embedding | embeddings.py |
Convert text to 384-dim vectors |
| 4. Storage | vector_store.py |
Persist in ChromaDB with cosine similarity |
| 5. Generation | rag_pipeline.py |
Retrieve + augment + generate answer |
git clone https://github.com/YOUR_USERNAME/documind-ai.git
cd documind-aipython -m venv venv
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activatepip install -r requirements.txt⏳ First install downloads the embedding model (~90 MB). This only happens once.
# Copy the example file
cp .env.example .envEdit .env and add your key:
OPENROUTER_API_KEY=your_key_here
Get a free API key at openrouter.ai/keys — no credit card required for free tier.
streamlit run app.pyOpen http://localhost:8501 in your browser.
- Upload documents using the sidebar file uploader (PDF or TXT)
- Wait for indexing to complete (shown in sidebar)
- Type a question in the chat bar at the bottom
- View the grounded answer and expand Retrieved Sources to see evidence
| Parameter | Default | Location |
|---|---|---|
| Chunk size | 500 chars | rag/chunker.py |
| Chunk overlap | 50 chars | rag/chunker.py |
| Top-K retrieval | 5 chunks | rag/rag_pipeline.py |
| LLM model | meta-llama/llama-3-8b-instruct |
rag/llm.py |
| Embedding model | all-MiniLM-L6-v2 |
rag/embeddings.py |
| Temperature | 0.2 | rag/llm.py |
| Component | Technology |
|---|---|
| Frontend + Backend | Streamlit |
| Vector Database | ChromaDB |
| Embedding Model | all-MiniLM-L6-v2 |
| LLM API | OpenRouter (LLaMA 3 8B Instruct) |
| PDF Parsing | PyPDF |
| Environment | python-dotenv |
- Lewis et al. (2020) — Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks
- Course: Prompt Engineering — Chanakya University, School of Engineering
- Instructor: Mr. Deepak B
- Student: Baire Gowda
MIT License — free to use for academic and personal projects.