Copyright Notice: This repository is a portfolio showcase. The code is made available for viewing purposes only. No reproduction, modification, or distribution is allowed without explicit written permission from the authors. See the
LICENSEfile for more details.
An AI-powered medical simulation ecosystem secured by RAG and evaluated via an MLOps benchmarking pipeline.
The following video demonstrates the complete system architecture in action, highlighting the dynamic VRAM swapping mechanism and the customizable Multi-Agent Engine. The interface allows seamless transition between various Instruction-Tuned models (Llama-3, Gemma-2, Mistral, BioMistral, Phi-3) for both the Patient Agent and the Supervisor Agent.
Clinical interviewing is a cornerstone of medical practice, yet scalable environments for students to practice diagnostic formulation and receive immediate expert feedback remain limited. MedSim addresses this gap by providing a dual-agent simulation environment:
A core constraint of the project was running multiple heavily quantized 7B-9B parameter models concurrently on a single NVIDIA Tesla V100 (16GB GPU) to optimize infrastructure costs. To prevent Out-Of-Memory (OOM) crashes, we engineered a state-managed Dynamic VRAM Swapping protocol. The memory is explicitly purged (torch.cuda.empty_cache()) and models are swapped on the fly between the interview phase and the grading phase.
To validate the pedagogical accuracy of the system at scale, we developed an automated benchmarking pipeline. By replacing the human user with a "Doctor Agent", we ran a combinatorial evaluation matrix across 5 open-weight models.
This automated metrology phase allowed us to:
To ensure compatibility with CUDA 12.1 and specific hardware optimizations, deploying within an isolated Conda environment is highly recommended.
conda create -n medsim_env python=3.11
conda activate medsim_env
pip install -r requirements.txt
The repository is structured around three main execution phases.
To respect repository size limits and data licensing, the full database of 4,500+ pathologies is not distributed. You must run the scraper to build the complete RAG database locally, using the provided pubmed-statpearls-set.txt seed.
python etl/web_scrapping.py
(Note: This pipeline enforces rate limits to respect NCBI server policies and will take several hours. A lightweight knowledge_base_extract.json is provided for immediate UI testing).
To launch the client-facing clinical simulator:
streamlit run app.py
To run the automated model evaluation factory and generate the statistical metrics:
python scripts/run_benchmark.py
python scripts/extract_results.py
/results/graphs/).python scripts/generate_graphs.py
Developed as part of the INF 3600 - Generative Artificial Intelligence course at UiT The Arctic University of Norway (Tromsø). Data sourced ethically from the NCBI StatPearls Database.
Copyright Notice: This repository is a portfolio showcase. The code is made available for viewing purposes only. No reproduction, modification, or distribution is allowed without explicit written permission from the authors. See the
LICENSEfile for more details.
An AI-powered medical simulation ecosystem secured by RAG and evaluated via an MLOps benchmarking pipeline.
The following video demonstrates the complete system architecture in action, highlighting the dynamic VRAM swapping mechanism and the customizable Multi-Agent Engine. The interface allows seamless transition between various Instruction-Tuned models (Llama-3, Gemma-2, Mistral, BioMistral, Phi-3) for both the Patient Agent and the Supervisor Agent.
Clinical interviewing is a cornerstone of medical practice, yet scalable environments for students to practice diagnostic formulation and receive immediate expert feedback remain limited. MedSim addresses this gap by providing a dual-agent simulation environment:
A core constraint of the project was running multiple heavily quantized 7B-9B parameter models concurrently on a single NVIDIA Tesla V100 (16GB GPU) to optimize infrastructure costs. To prevent Out-Of-Memory (OOM) crashes, we engineered a state-managed Dynamic VRAM Swapping protocol. The memory is explicitly purged (torch.cuda.empty_cache()) and models are swapped on the fly between the interview phase and the grading phase.
To validate the pedagogical accuracy of the system at scale, we developed an automated benchmarking pipeline. By replacing the human user with a "Doctor Agent", we ran a combinatorial evaluation matrix across 5 open-weight models.
This automated metrology phase allowed us to:
To ensure compatibility with CUDA 12.1 and specific hardware optimizations, deploying within an isolated Conda environment is highly recommended.
conda create -n medsim_env python=3.11
conda activate medsim_env
pip install -r requirements.txt
The repository is structured around three main execution phases.
To respect repository size limits and data licensing, the full database of 4,500+ pathologies is not distributed. You must run the scraper to build the complete RAG database locally, using the provided pubmed-statpearls-set.txt seed.
python etl/web_scrapping.py
(Note: This pipeline enforces rate limits to respect NCBI server policies and will take several hours. A lightweight knowledge_base_extract.json is provided for immediate UI testing).
To launch the client-facing clinical simulator:
streamlit run app.py
To run the automated model evaluation factory and generate the statistical metrics:
python scripts/run_benchmark.py
python scripts/extract_results.py
/results/graphs/).python scripts/generate_graphs.py
Developed as part of the INF 3600 - Generative Artificial Intelligence course at UiT The Arctic University of Norway (Tromsø). Data sourced ethically from the NCBI StatPearls Database.