How basheerahmedshk/medical-chatbot works
Project Type and Purpose
• MediBot is a full-stack Retrieval-Augmented Generation (RAG) system for answering medical queries.
• It consists of three logical phases: Memory Setup (vector DB build), Retrieval + LLM integration, and Chatbot UI.
• Key technologies: Python, FAISS, LangChain, Streamlit, LLMs (Mistral-7B / LLaMA-4), SentenceTransformers, PyPDF2.
File Structure
• Top-level scripts:
• create_memory_for_llm.py – PDF → text chunks → embeddings → FAISS index
• connect_memory_with_llm.py – RetrievalQA pipeline connecting FAISS to an LLM
• medibot.py – Streamlit UI exposing the chat interface
• data/ – source PDFs
• vectorstore/ – persisted FAISS index files
• requirements.txt – dependency list
• README.md, Overview.md, presentation.pptx – documentation and slide deck
README Insights
• Phases described in README map directly to the three main components.
• Emphasis on cached FAISS index for speed, real-time streaming, and source citation.
• Mentions LangChain RetrievalQA, safe prompting, and the chosen embedding model.
Main Components and Relationships
a. Memory Setup Component
• Inputs: PDFs from data/
• Subcomponents:
• PDF Parser (PyPDF2)
• Text Chunker
• Embedding Generator (SentenceTransformers all-MiniLM-L6-v2)
• FAISS Vector Store (IndexFlatIP)
• Outputs: vectorstore/db_faiss/index.faiss + index.pkl
b. Retrieval + LLM Component
• Inputs: user query, FAISS index
• Subcomponents:
• FAISS Retriever (k=3)
• RetrievalQA Pipeline (LangChain)
• LLM Client (Mistral-7B or LLaMA-4 via Groq)
• Outputs: answer text + source chunk citations
c. Chatbot UI Component
• Built with Streamlit (medibot.py)
• Features: session history, real-time streaming, source display
• Connects to Retrieval + LLM component via local function calls or API
Architectural Patterns and Principles
• Layered/pipeline architecture: ingestion → indexing → retrieval → generation → presentation
• Separation of concerns: batch indexing separated from real-time query pipeline
• Stateless UI: Streamlit app calls pure functions for retrieval and generation
• Modular: each phase can be replaced or scaled independently (e.g., swap FAISS for another vector DB)