Skip to content

Data2Deploy/A-Mini-RAG-POWERED-ASSISTANT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📚 Mini RAG-Powered Assistant

IIT Jodhpur Information RAG Assistant

A Retrieval-Augmented Generation (RAG) based chat assistant that answers user questions strictly from internal documents such as academic calendars, institutional policies, SOPs, FAQs, and manuals.

This project is designed to simulate a real-world SMB / institutional knowledge assistant where accuracy, document grounding, and policy version control are critical.


🚀 Problem Statement

Small and Medium Businesses (SMBs) and institutions face the following challenges:

  • 🔍 Difficulty searching across multiple internal documents
  • 🔁 Repetitive questions asked to HR / support teams
  • ⚠️ Errors caused by outdated or conflicting policy information
  • 🌐 Risk of LLMs hallucinating answers from the internet

🎯 Business Need

"We want a chat assistant that answers questions only from our internal documents, not from the internet."


🧠 Solution Overview (RAG Architecture)

We built a Mini RAG Assistant that:

  • Ingests internal documents (PDFs, TXT, DOCs, CSVs)
  • Converts them into vector embeddings
  • Stores embeddings in a FAISS vector database
  • Retrieves relevant chunks for a user query
  • Feeds retrieved context to an LLM to generate grounded answers

🗂️ Corpus

  • 📄 Academic Calendar (PDF)
  • 📄 Institutional Policies (PDF)
  • 📄 Internal Documents
  • 📄 SOPs, FAQs

🏗️ System Design

Documents (PDF / TXT / DOC / CSV)
        ↓
Text Extraction + Chunking
        ↓
Embedding Generation (all-MiniLM-L6-v2)
        ↓
FAISS Vector Database
        ↓

User Query
        ↓
Query Embedding (all-MiniLM-L6-v2)
        ↓
Top-K Similarity Search (FAISS)
        ↓
Prompt Construction
        ↓
LLM (GPT / Google API / HuggingFace)
        ↓
Final Answer (Grounded in Documents)

🔧 Technology Stack

  • Language: Python
  • Embedding Model: sentence-transformers/all-MiniLM-L6-v2
  • Vector Database: FAISS
  • LLM:
    • OpenAI GPT API (optional)
    • Google Generative API (optional)
    • HuggingFace open-source models *(Mistral, LLaMA, etc.)
  • UI: Streamlit

✂️ Chunking Strategy

  • Documents are split into smaller text chunks
  • Each chunk is embedded separately
  • Helps in:
    • Better semantic retrieval
    • Reduced hallucinations
    • Efficient similarity search

🧩 Prompt Template

Instruction:
You are an institutional assistant. Answer only from the provided context.

Context:
[Top-K Retrieved Document Chunks]

User Question:
{query}

📌 Special Cases Handling

1️⃣ Multiple Document Types

Supported formats:

  • ✅ PDF
  • ✅ TXT
  • ✅ DOC / DOCX
  • ✅ CSV

Handled using appropriate loaders and text extractors before chunking.


2️⃣ Policy Updates Handling (Very Important)

We handle new or updated policies in two robust ways:

✅ Method 1: Versioning + Re-Ranking

  • Maintain multiple versions of a policy
  • Assign metadata like version, date, status
  • Apply re-ranking to prioritize the latest policy

✅ Method 2: Deactivation Strategy (Recommended)

  • When a new policy is added:
    • Old policy embeddings are removed or deactivated
    • Only the latest policy remains active in the vector DB

➡️ This avoids conflicts and ensures answers are always up-to-date.



⚙️ Installation & Setup

Step 1: Open Command Prompt / Terminal

Navigate to the project directory:

cd RAG_Assistant

Step 2: Install Dependencies

pip install -r requirements.txt

Step 3: Generate Embeddings

cd embeds
python embed.py
cd ..

This will:

  • Load documents
  • Chunk text
  • Generate embeddings
  • Store vectors in FAISS

Step 4: Run the Application

streamlit run app.py

Step 5: Open the App

Open the browser and go to:

http://localhost:8501

(or use the Streamlit-generated URL)


💬 Usage

  • Ask any question related to the document corpus
  • Example queries:
    • "What is the semester start date?"
    • "What is the attendance policy?"
    • "What are the academic regulations for grading?"

📌 The model will not answer questions outside the document corpus.


🔐 Key Features

  • ✅ Answers grounded only in internal documents
  • ✅ No internet-based hallucinations
  • ✅ Handles multiple file formats
  • ✅ Policy version control
  • ✅ Easy to deploy and extend

🧪 Future Enhancements

  • 🔄 Incremental embedding updates
  • 🧠 Cross-encoder re-ranking
  • 🔍 Hybrid search (BM25 + FAISS)
  • 👥 Role-based access control
  • 📊 Admin dashboard for document management

🏁 Conclusion

This Mini RAG Assistant demonstrates a production-ready approach to building a secure, document-grounded AI assistant for institutions and SMBs.

It reduces manual effort, improves accuracy, and ensures users always receive up-to-date and trusted information.


Built for real-world RAG system understanding and deployment readiness.

About

Small and medium businesses (SMBs)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors