Skip to content

NazmusSaad/Medical-Assistant-LLM

Repository files navigation

🩺 Medical Assistant LLM (MedLLaMA)

MedLLaMA is a fine-tuned version of LLaMA-2 designed for clinical instruction following. It was trained on the Llama2-MedTuned-Instructions dataset (200,000 samples) using LoRA and 4-bit quantization (QLoRA). The model specializes in tasks like medical question answering, named entity recognition (NER), and relation extraction.


πŸ’‘ Features

  • βœ… Fine-tuned LLaMA-2–7B using LoRA + 4-bit QLoRA
  • βœ… Instruction-style prompting ([INST] ... [/INST]) for clinical NLP tasks
  • βœ… GPT-4-based evaluation showed a +2.1 improvement in accuracy and +1.8 in helpfulness over the base model across 30 prompts
  • βœ… Streamlit app for real-time interaction
  • βœ… πŸ” Dynamic RAG integration for live web-powered answers

πŸ” Dynamic Retrieval-Augmented Generation (RAG)

In addition to fine-tuning, MedLLaMA now supports Dynamic RAG, combining web search with medical domain reasoning:

  • πŸ”Ž Uses DuckDuckGo + BeautifulSoup to fetch real-time content
  • πŸ“„ Chunks and embeds retrieved web pages using MiniLM
  • 🧠 Generates responses using your fine-tuned MedLLaMA model

🧠 Tech Stack

  • πŸ¦™ Hugging Face Transformers + QLoRA (4-bit)
  • πŸ”Ž LangChain (Dynamic RAG pipeline)
  • 🧠 ChromaDB (vector store for chunked web context)
  • 🌐 DuckDuckGo Search + BeautifulSoup (real-time web scraping)
  • πŸŽ›οΈ Streamlit (UI demo)
  • πŸ” dotenv (secure environment variable handling)

πŸš€ Try It Locally

  1. Clone the repo and install dependencies:

    pip install -r requirements.txt
  2. Create a .env file with your Hugging Face token:

    HF_TOKEN=your_token_here
    
  3. Run the app:

    streamlit run streamlit_app.py

Example

Q: Is creatine monohydrate dangerous?

A: Creatine is a substance that occurs naturally in the body and is found in small amounts in foods such as meat and fish. It is also available as a dietary supplement. There is no evidence that creatine is dangerous. However, it can cause some side effects, such as weight gain, water retention, and stomach cramps. It can also interact with some medications, so it is important to talk to a doctor before taking creatine.

πŸ§ͺ This answer was generated by combining retrieved content from sources like Mayo Clinic and WebMD, then passing it to your LLaMA-2 medical model.


πŸ“Š Evaluation Methodology

  • Sampled 30 prompts from the validation split of the MedTuned dataset
  • Compared base LLaMA-2 and MedLLaMA outputs side-by-side
  • GPT-4 scored each pair on accuracy, completeness, and helpfulness

πŸ“ˆ MedLLaMA consistently outperformed the base model.


πŸ“Ž License & Disclaimer

This project is for research and educational purposes only.
The model is not a substitute for professional medical advice.

About

🩺 A fine-tuned LLaMA-2 model for clinical instruction-following tasks. Trained on 200k medical instructions and deployed as an interactive Streamlit app. Evaluated using GPT-4-as-a-judge.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors