Skip to content

Ratnesh-181998/Medical-RAG-Chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

38 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ Medical RAG Chatbot: Advanced AI Health Assistant

image

Streamlit App License: MIT Python 3.10+ LangChain FAISS GitHub Issues

An intelligent, Retrieval-Augmented Generation (RAG) powered conversational AI designed to provide accurate medical information from verified documentation.


πŸ“– Table of Contents


🌐🎬 Live Demo

πŸš€ Try it now:

πŸŽ₯ Live Preview

App Demo


🎬 Live Project Demo

Experience the full flow:

Project Demo Walkthrough


✨ Introduction

The Medical RAG Chatbot is a state-of-the-art AI application built to bridge the gap between complex medical documentation and accessible, user-friendly health queries. By leveraging Llama-3 (via Hugging Face) for reasoning and FAISS for fast similarity search, this system ingests medical PDFs (e.g., "The Gale Encyclopedia of Medicine"), understands user questions, and retrieves precise, context-aware answers.

Unlike standard chatbots, this system is grounded in RAG (Retrieval-Augmented Generation), meaning every answer is backed by retrieved evidence from trusted sources, significantly reducing hallucinations.


πŸš€ Key Features

  • πŸ” RAG-Powered Accuracy:Retrieves relevant context from indexed medical PDFs before answering.
  • πŸ€– Advanced LLM Integration: Uses Llama-3 (via Hugging Face API) for high-quality natural language understanding.
  • ⚑ Fast Vector Search: Implements FAISS (Facebook AI Similarity Search) for millisecond-latency document retrieval.
  • 🧠 Conversation Memory: Remembers past interactions to provide context-aware follow-up answers.
  • πŸ“„ Source Attribution: Shows exactly which part of the document was used to generate the answer.
  • πŸ–₯️ System Health Dashboard: Real-time monitoring of vector store status, LLM connectivity, and system latency.
  • 🎨 Premium UI/UX: A polished Streamlit interface with a custom medical green theme, smooth transitions, and interactive components.

Medical RAG System Architecture

image

Interactive Logic Diagram

image

Architecture Evolution

  • πŸ“· Architecture View 1 β€” Very Simple
image - πŸ“· Architecture View 2 β€” Basic Rag Flow image - Architecture View 3 – Rag With Embeddings image - Architecture View 4 β€” Full Application Architecture image - Architecture View 5 β€” With Memory (Chat History) image - Architecture View 6 – Production + Devops image - Architecture View 7 β€” End-To-End (Best Final Diagram) image

πŸ—οΈ System Architecture

The system follows a robust data pipeline:

  1. Ingestion: Loading medical PDFs using PyPDFLoader.
  2. Chunking: Splitting text into manageable chunks (RecursiveCharacterTextSplitter).
  3. Embedding: Converting text to vectors using SentenceTransformer (all-MiniLM-L6-v2).
  4. Storage: Indexing vectors in a local FAISS database.
  5. Retrieval: Fetching top-k relevant chunks for a user query.
  6. Generation: Synthesizing the final answer using the LLM.

System Architecture

image

(See the Architecture tab in the app for an interactive deep dive into each component.)


πŸ› οΈ Tech Stack

Category Technology Purpose
Frontend Streamlit Interactive Web UI & Dashboard
LLM Engine Llama 3 (via Groq/HF) Natural Language Generation
Embeddings SentenceTransformers Semantic text representation
Vector DB FAISS High-performance similarity search
Orchestration LangChain Chaining retrieval and generation flows
DevOps Docker & Jenkins Containerization & CI/CD Pipelines
Security Aqua Trivy Container vulnerability scanning
Cloud AWS App Runner Scalable cloud deployment
Language Python 3.10 Core programming language

πŸ“² App Walkthrough (UI Sections)

1. πŸ’¬ Demo Project

The main interface where users interact with the AI.

  • Input Area: Type medical questions (e.g., "What are symptoms of Pneumonia?").
  • Answer Display: Receive detailed, AI-generated responses.
  • Reference Context: Expandable section showing the raw source text used for the answer.
  • Metrics: Real-time display of execution time and confidence.
image image image image image image image

2. πŸ“– About Project

A detailed overview of the project's mission.

  • Explains the "Why" and "How" of Medical RAG.
  • Highlights the datasets used (Gale Encyclopedia of Medicine).
  • outlines the solution approach.
image image image image image image image image image image image image image

3. πŸ›  Tech Stack

Visual representation of the technologies used.

  • Cards for LLM, Vector Store, DevOps, and Frontend.
  • Explains the role of Docker, Jenkins, and AWS in the deployment pipeline.
image image image image image image

4. πŸ› Architecture

An educational hub for developers.

  • Interactive Flowcharts: Visualizing the data journey from PDF to Answer.
  • Component Deep Dive: Tabs explaining Ingestion, Embedding, and Generation with code snippets.
  • Evolution: A gallery showing how the architecture evolved from MVP to Production.
image image image image image

5. πŸ–₯️ System Health & Logs

A dashboard for administrators.

  • Status Indicators: Green/Red lights for App, Vector Store, and LLM connectivity.
  • Live Logs: Scrollable, filterable logs showing system activities and errors.
  • Download: Export logs for external analysis.
image image image

βš™οΈ Installation & Setup

Prerequisites

  • Python 3.8 or higher.
  • A Hugging Face API Token (for the LLM).

1. Clone the Repository

git clone https://github.com/Ratnesh-181998/Medical-RAG-Chatbot.git
cd Medical-RAG-Chatbot

2. Install Dependencies

pip install -r requirements.txt

3. Configure Environment

Create a .env file in the root directory and add your API token:

HF_TOKEN=your_hugging_face_token_here

4. Run the Application

streamlit run Medical_Chatbot_streamlit_app.py

The app will open in your browser at http://localhost:8501.


πŸ“¦ Project Structure

Medical-RAG-Chatbot/
β”œβ”€β”€ architecture_images/       # Diagrams for documentation
β”œβ”€β”€ vectorstore/               # FAISS index files (if local)
β”œβ”€β”€ Medical_Chatbot_streamlit_app.py  # Main Entry Point
β”œβ”€β”€ requirements.txt           # Python dependencies
β”œβ”€β”€ .env                       # Environment variables (GitIgnored)
└── README.md                  # Project Documentation

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/AmazingFeature).
  3. Commit your changes (git commit -m 'Add some AmazingFeature').
  4. Push to the branch (git push origin feature/AmazingFeature).
  5. Open a Pull Request.

πŸ“œ License

Distributed under the MIT License. See LICENSE for more information.


πŸ“ž Contact

Ratnesh Kumar Singh

Project Links

Built with passion for the AI Community. πŸš€



πŸ“œ License

License

Licensed under the MIT License - Feel free to fork and build upon this innovation! πŸš€


πŸ“ž CONTACT & NETWORKING πŸ“ž

πŸ’Ό Professional Networks

LinkedIn GitHub X Portfolio Email Medium Stack Overflow

πŸš€ AI/ML & Data Science

Streamlit HuggingFace Kaggle

πŸ’» Competitive Programming (Including all coding plateform's 5000+ Problems/Questions solved )

LeetCode HackerRank CodeChef Codeforces GeeksforGeeks HackerEarth InterviewBit


πŸ“Š GitHub Stats & Metrics πŸ“Š

Profile Views

GitHub Streak Stats


Typing SVG

Footer Typing SVG

About

Medical RAG Question-Answering System built using LangChain, FAISS vector store, PyPDF, and Streamlit. Powered by Mistral open-source LLMs (HuggingFace) with custom context-aware chains. Includes a production-grade LLMOps/AIOps pipeline using Docker, Jenkins CI/CD, Aqua Trivy security scanning, and automated deployment on AWS App Runner.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors