Skip to content

Latest commit

 

History

History
59 lines (47 loc) · 1.62 KB

File metadata and controls

59 lines (47 loc) · 1.62 KB

README.md

CareMind Clinical QA System

A Retrieval-Augmented Generation (RAG) system designed to answer clinical questions based on MIMIC-IV data, using LangChain, LLaMA 2, BioBERT embeddings, and Pinecone for retrieval. Guardrails are enforced using Natural Language Inference (NLI) to reduce hallucinations.

This project builds an intelligent clinical QA system powered by LLaMA and LangChain. It uses:

  • MIMIC-IV data via Pinecone + BioBERT retriever
  • Advanced prompt-based LLaMA2 for generation
  • NLI-based guardrails to reduce hallucinations
  • External search fallback (via SerpAPI)

Features:

  • Context-Aware Retrieval: Uses BioBERT + Pinecone to pull semantically relevant patient notes from MIMIC-IV.
  • LLaMA 2 QA Model: Generates grounded, clinical answers using a structured prompt.
  • Model-Based Guardrails (NLI):
    • Applies a pre-trained RoBERTa NLI model to detect hallucinated or unfaithful outputs.
  • LangChain Framework: Modular, production-ready RAG pipeline.
  • Gradio Interface: Simple UI for clinicians, students, or researchers to interact with.

System Architecture

[Clinical Query]
   ↓
[Pinecone + BioBERT Retriever]
   ↓
[Prompt Template]
   ↓
[LLaMA 2 Generation]
   ↓
[NLI Guardrails (RoBERTa-MedNLI)]
   ↓
[Fallback: SerpAPI for Web Answers]
   ↓
[Gradio UI]

How to Run (Locally or Hugging Face Spaces)

  1. Clone the repo and install dependencies:
pip install -r requirements.txt
  1. Set your .env variables:
PINECONE_API_KEY=your_key
SERPAPI_API_KEY=your_key
  1. Launch the app:
python caremind_agent.py