Skip to content

Dhruvy0804/Rag-Powered-Internal-Knowledge-Base

Repository files navigation

🚀 Blostem AI Knowledge Base

A 100% Local, Privacy-First Retrieval-Augmented Generation (RAG) System

Python Streamlit Ollama ChromaDB


📖 Overview

This repository contains a full-stack RAG-powered Knowledge Base built to serve internal teams (Ops, Sales, CS).

By training the AI exclusively on Blostem's internal documents (product specs, partner contracts, RBI/SEBI circulars, and live website data), it allows users to ask natural-language questions and receive highly accurate, cited answers with zero hallucination.

Everything runs locally on your machine—ensuring zero data leakage to third-party APIs.


✨ Key Features

  • 🔒 100% Local & Private: Powered by Ollama using llama3.2 for generation and nomic-embed-text for embeddings.
  • 📚 Automated Ingestion Pipeline: Extracts text from .pdf and .docx files, chunks them recursively, and permanently stores the vectors in ChromaDB.
  • 🎯 Anti-Hallucination Guardrails: Strict system prompts prevent the AI from answering off-topic questions (e.g., "What is the capital of France?" gets politely rejected).
  • 📊 Confidence Scoring & Citations: Every AI answer includes a semantic-similarity confidence badge (🟢 High / 🟡 Medium / 🔴 Low) and expandable citations pointing directly to the exact document and page.
  • 🖥️ Streamlit Web Dashboard: A beautiful, dark-themed UI for internal teams to upload documents, view database stats, and chat.

🛠️ Architecture & Tech Stack

Component Technology Used
LLM Engine Ollama (llama3.2, nomic-embed-text)
Vector Database ChromaDB
Frontend Dashboard Streamlit
Document Parsing PyMuPDF (fitz), python-docx

📂 Project Structure

📦 blostem-rag-knowledge-base
 ┣ 📂 sample_docs/                # Directory for storing source PDFs and DOCX files
 ┣ 📂 chroma_db/                  # Local vector database storage (auto-generated)
 ┣ 📜 app.py                      # The Streamlit web dashboard UI
 ┣ 📜 rag.py                      # Core RAG engine (embedding, searching, prompt building)
 ┣ 📜 ingest.py                   # Data ingestion pipeline
 ┣ 📜 create_sample_docs.py       # Script to generate dummy internal documents for testing
 ┗ 📜 create_full_blostem_doc.py  # Script that scraped and ingested the Blostem website data

⚙️ Installation & Setup

1. Prerequisites

  • Python 3.10 or higher.
  • Ollama installed and running on your machine.

2. Install Local Models

Open your terminal and pull the required open-source models:

ollama pull llama3.2
ollama pull nomic-embed-text

3. Install Python Dependencies

pip install streamlit langchain chromadb pymupdf python-docx

🎯 Usage Instructions

Start the Dashboard

Use this interface for internal team access, managing documents, and testing the database.

streamlit run app.py

(Access the dashboard at http://localhost:8501)


🧠 How the RAG Pipeline Works Under the Hood

  1. Ingestion: ingest.py reads the raw text from files, splits it into 500-character chunks (with 50 characters of overlap), and uses nomic-embed-text to map them as vectors in ChromaDB.
  2. Retrieval: When a user asks a question, rag.py converts the question into a vector and performs a Cosine Similarity search to find the Top 5 most relevant chunks.
  3. Generation: The chunks are injected into a strict prompt template. llama3.2 synthesizes a comprehensive, bulleted answer using only the provided context.

Built as a secure, private AI Knowledge Base prototype.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages