library_name: peft base_model: BioMistral/BioMistral-7B language: - en pipeline_tag: text-generation tags: - medical - healthcare - triage - risk-prediction - biomistral - rag - fine-tuned license: apache-2.0
π₯ GenMedX: Emergency Triage & Risk Prediction Adapter
GenMedX is a specialized medical AI system designed to assist in Emergency Department (ED) triage. It utilizes a fine-tuned BioMistral-7B model combined with Retrieval-Augmented Generation (RAG) to analyze patient complaints and vital signs, predicting risk levels and recommending diagnostic tests.
π Model Details
- Model Name: GenMedX-Adapter
- Base Model: BioMistral/BioMistral-7B (A Mistral-based model further pre-trained on PubMed).
- Architecture: - LLM: 4-bit Quantized LLaMA architecture (via
bitsandbytesandpeft).- RAG System: Uses
sentence-transformers/all-MiniLM-L6-v2to retrieve similar historical cases from a vector database.
- RAG System: Uses
- Task: Medical Risk Stratification, Clinical Reasoning, and Diagnostic Test Recommendation.
- Fine-Tuning Method: QLoRA (Quantized Low-Rank Adaptation).
π― Intended Use
This model is intended for research and academic demonstration purposes only. It is designed to simulate an "AI Medical Assistant" that can:
- Analyze Vitals: Detect abnormalities (Tachycardia, Hypoxia, Hypertension, etc.).
- Predict Risk: Classify patients as High, Medium, or Low risk based on ESI (Emergency Severity Index) standards.
- Recommend Tests: Suggest immediate diagnostic actions (e.g., ECG, Troponin, CT Scan).
- Retrieve Context: Compare the current patient with similar historical cases using RAG.
β οΈ Limitations & Ethical Warnings
This model is NOT a doctor.
- Clinical Use: Do not use this model for real-world medical decision-making without human supervision. It is a decision-support tool, not a replacement for a clinician.
- Hallucinations: Like all Large Language Models (LLMs), GenMedX can generate plausible-sounding but incorrect information.
- Bias: The model's outputs are dependent on the quality of the training data. If the data contains biases regarding demographics or disease prevalence, the model may reproduce them.
- Privacy: Ensure no PII (Personally Identifiable Information) is fed into the model during inference.
βοΈ Training Data & Procedure
Data
The model was fine-tuned on a preprocessed emergency dataset (train_preprocessed.csv) containing:
- Inputs: Patient Chief Complaints (e.g., "Chest pain radiating to jaw") and Vital Signs (HR, RR, BP, Temp, O2).
- Targets: Risk Labels (High/Low), Acuity Scores, and Clinician Notes.
Training Hyperparameters
- LoRA Rank (r): 64
- LoRA Alpha: 16
- Dropout: 0.1
- Quantization: 4-bit (NF4)
- Optimizer: PagedAdamW
- Learning Rate: 2e-4
- Scheduler: Cosine
π How to Use (Python)
To use this model, you need the peft and transformers libraries.
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
# 1. Configuration
base_model_id = "BioMistral/BioMistral-7B"
adapter_id = "hamsaram/GenMedX-Adapter"
# 2. Load Base Model (4-bit for efficiency)
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
)
model = AutoModelForCausalLM.from_pretrained(
base_model_id,
quantization_config=bnb_config,
device_map="auto",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
# 3. Load GenMedX Adapter
model = PeftModel.from_pretrained(model, adapter_id)
# 4. Inference
prompt = "[INST] Patient has chest pain and HR 120. Assess risk. [/INST]"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=200)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support