MedBot (Medical RAG Assistant)

Grounded medical Q&A over uploaded clinical PDFs

Healthcare AI Project
  • Streamlit + FastAPI architecture
  • SBERT embeddings + FAISS retrieval
  • Groq LLaMA 3 8B context-based answers
  • Medical PDF ingestion pipeline

MedBot is a retrieval-augmented assistant built for medical document Q&A. The system ingests medical PDFs, chunks and embeds content, indexes vectors in FAISS, and answers user questions using Groq-hosted LLaMA 3 8B constrained to retrieved evidence. The local project includes ingestion, embedding, and query logic modules that were used to validate reliable retrieval quality over medical references.

What the system solves

Medical references are long and difficult to query quickly. MedBot provides a question-answering layer that maps natural-language questions to relevant medical excerpts through semantic retrieval, then generates concise answers grounded in those excerpts.

Top-K retrieval Chunk-level grounding All-MiniLM-L6-v2 FAISS L2 index
Python Streamlit FastAPI Sentence Transformers FAISS PyMuPDF LangChain Groq API

Core capabilities

  • Upload and parse medical PDFs through Streamlit ingestion workflow.
  • Heading-aware + recursive chunking for better semantic context boundaries.
  • Embedding generation with all-MiniLM-L6-v2 and persistence in .npy format.
  • FAISS vector search to retrieve the most relevant evidence chunks per query.
  • Groq LLaMA response generation from retrieved context only.

System architecture

MedBot architecture flow

User -> Streamlit/FastAPI -> extraction/chunking -> embeddings/FAISS -> Groq LLM response

Component summary

LayerRole in MedBot
Streamlit UIUpload PDFs, trigger processing, ask questions interactively
FastAPI/query serviceRetrieval and answer orchestration for user questions
PyMuPDFPDF text extraction from clinical references
Chunking moduleTopic/heading-aware splitting + recursive fallback chunking
SBERT encoderVector embeddings for chunks and user queries
FAISS indexTop-K semantic nearest-neighbor retrieval
Groq LLaMA 3 8BFinal context-grounded natural-language answer generation

Ingestion flow

MedBot ingestion pipeline flow

Upload PDF -> extract -> chunk -> embed -> save vectors/chunks -> index ready

Query flow

MedBot query and retrieval flow

Question embedding -> FAISS top-K retrieval -> prompt assembly -> Groq LLM answer

Key implementation details from local code

  • genrate_store_embed.py runs Streamlit ingestion, extraction, chunking, and embedding persistence.
  • medbottest.py loads persisted embeddings/chunks, builds FAISS index, and handles retrieval + Groq invocation.
  • embed_viewer.py helps inspect generated embedding arrays during verification.
  • unstructure_process_pdf_code/pdf.py contains advanced PDF parsing helpers for OCR/hi-res extraction strategies.

Representative workflow

# Ingestion 1) Upload PDF in Streamlit UI 2) Extract text with PyMuPDF 3) Split by heading + recursive chunks 4) Encode chunks with all-MiniLM-L6-v2 5) Save embeddings (.npy) and chunks (.pkl) # Query 1) Encode user query with same SBERT model 2) Top-K FAISS search on stored vectors 3) Build context prompt from retrieved chunks 4) Invoke Groq LLaMA 3 8B 5) Return context-grounded answer

Project notes and links

Confidentiality note: Public repository contains base MedBot implementation (ingestion, embeddings, retrieval, and answer generation). Advanced agentic orchestration and internal production extensions are intentionally not public.
Back to Portfolio