MedAgentSim: Self-Evolving Multi-Agent Simulations for Realistic Clinical Interactions, MICCAI 2025 (oral and early accepted)
See the code
An open-source framework for simulating realistic doctor-patient interactions
MedAgentSim is an open-source simulated hospital environment designed to evaluate and enhance large language model (LLM) performance in dynamic diagnostic settings. Unlike prior approaches, our framework requires doctor agents to actively engage with patients through multi-turn conversations, requesting relevant medical examinations and imaging results to mimic real-world diagnostic processes.
Key features:
# Clone the repository
git clone https://github.com/MAXNORM8650/MedAgentSim.git
cd MedAgentSim
conda env create -f environment.yml
conda activate mgent
pip install e .
# Install dependencies
pip install -r requirements.txt
# Ensure
pip install --upgrade torch torchao torchvision transformers
pip install --upgrade openai
python -m pip install replicate
python -m pip install anthropic
python -m pip install groq
python -m pip install accelerate
python -m pip install openai-cost-tracker
python -m pip install django==2.2
# Start the server
python -m medsim.server
# In a separate terminal, launch the client
python -u -m medsim.simulate --doctor_llm meta-llama/Llama-3.2-3B-Instruct --patient_llm meta-llama/Llama-3.2-3B-Instruct --measurement_llm meta-llama/Llama-3.2-3B-Instruct --moderator_llm meta-llama/Llama-3.2-3B-Instruct
Visit http://localhost:8000/simulator_home in your browser. Make sure to keep that tab open and active during the simulation.
vllm serve unsloth/Llama-3.2-11B-Vision-Instruct-unsloth-bnb-4bit --dtype 'auto' --quantization "bitsandbytes" --load_format "bitsandbytes" --tensor-parallel-size 4 --max-model-len 8192 --limit-mm-per-prompt image=1
vllm serve meta-llama/Llama-3.2-3B-Instruct --tensor-parallel-size 4
vllm serve unsloth/Llama-3.3-70B-Instruct-bnb-4bit --quantization "bitsandbytes" --load_format "bitsandbytes"
MedAgentSim supports three core interaction modes:
MedAgentSim is compatible with various LLMs:
MedAgentSim has been evaluated on several medical benchmarks:
| Benchmark | Description | #Cases |
|---|---|---|
| NEJM | Complex real-world cases | 15 |
| NEJM Extended | Additional complex cases | 120 |
| MedQA | Simulated diagnostic scenarios | 106 |
| MedQA Extended | Extended diagnostic scenarios | 214 |
| MIMIC-IV | Real-world clinical cases | 288 |
CUDA_VISIBLE_DEVICES=0,1,2,3 vllm serve meta-llama/Llama-3.1-70B-Instruct \
--tensor-parallel-size 4 \
--max-model-len 8192
python medsim/main.py \
--doctor_llm meta-llama/Llama-3.1-70B-Instruct \
--patient_llm meta-llama/Llama-3.1-70B-Instruct \
--measurement_llm meta-llama/Llama-3.1-70B-Instruct \
--moderator_llm meta-llama/Llama-3.1-70B-Instruct \
--agent_dataset MedQA
We also support ollama,
python medsim/main.py \
--doctor_llm llama3.3:70b \
--patient_llm llama3.3:70b \
--measurement_llm llama3.3:70b \
--moderator_llm llama3.3:70b \
--agent_dataset MedQA
MedAgentSim/
βββ assets/ # Images, CSS, and other static files
βββ datasets/ # Sample datasets and medical knowledge base. Put your dataset here
βββ docs/ # Documentation. Coming soon
βββ medsim/ # Core simulation code
β βββ configs/ # configs for for models
β βββ core/ # Agent implementations
β βββ server/ # Simulation environment server
β βββ simulate/ # Multi-agnet running interfaces
β βββ utils/ # Utility functions
βββ Simulacra/ # Backend support
βββ MedPromptSimulate/ # Dignosis memory support
βββ examples/ # Example scenarios and configurations
βββ tests/ # Unit and integration tests. Coming soon
βββ requirements.txt # Python dependencies
βββ LICENSE # License information
βββ README.md # This file
from datasets import load_dataset
# Load all files
ds = load_dataset("ItsMaxNorm/MedAgentSim-datasets")
# Load a specific file
ds = load_dataset("ItsMaxNorm/MedAgentSim-datasets", data_files="medqa_v1.parquet")
# Access the data
print(ds["train"][0])
We welcome contributions to MedAgentSim! Please see CONTRIBUTING.md for details on how to get started.
This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0) - see https://creativecommons.org/licenses/by-nc-sa/4.0/ for details.
If you use MedAgentSim in your research, please cite our paper:
@inproceedings{almansooriandkumarMedAgentSim,
title={Self-Evolving Multi-Agent Simulations for Realistic Clinical Interactions},
author={Mohammad Almansoori and Komal Kumar and Hisham Cholakkal},
booktitle={International Conference on Medical Image Computing and Computer-Assisted Intervention},
year={2025}
}
For questions or support, please open an issue or contact the maintainers:
Python
54.0%
Jupyter Notebook
29.6%
HTML
13.0%
Stata
3.3%
MedAgentSim: Self-Evolving Multi-Agent Simulations for Realistic Clinical Interactions, MICCAI 2025 (oral and early accepted)
See the code
An open-source framework for simulating realistic doctor-patient interactions
MedAgentSim is an open-source simulated hospital environment designed to evaluate and enhance large language model (LLM) performance in dynamic diagnostic settings. Unlike prior approaches, our framework requires doctor agents to actively engage with patients through multi-turn conversations, requesting relevant medical examinations and imaging results to mimic real-world diagnostic processes.
Key features:
# Clone the repository
git clone https://github.com/MAXNORM8650/MedAgentSim.git
cd MedAgentSim
conda env create -f environment.yml
conda activate mgent
pip install e .
# Install dependencies
pip install -r requirements.txt
# Ensure
pip install --upgrade torch torchao torchvision transformers
pip install --upgrade openai
python -m pip install replicate
python -m pip install anthropic
python -m pip install groq
python -m pip install accelerate
python -m pip install openai-cost-tracker
python -m pip install django==2.2
# Start the server
python -m medsim.server
# In a separate terminal, launch the client
python -u -m medsim.simulate --doctor_llm meta-llama/Llama-3.2-3B-Instruct --patient_llm meta-llama/Llama-3.2-3B-Instruct --measurement_llm meta-llama/Llama-3.2-3B-Instruct --moderator_llm meta-llama/Llama-3.2-3B-Instruct
Visit http://localhost:8000/simulator_home in your browser. Make sure to keep that tab open and active during the simulation.
vllm serve unsloth/Llama-3.2-11B-Vision-Instruct-unsloth-bnb-4bit --dtype 'auto' --quantization "bitsandbytes" --load_format "bitsandbytes" --tensor-parallel-size 4 --max-model-len 8192 --limit-mm-per-prompt image=1
vllm serve meta-llama/Llama-3.2-3B-Instruct --tensor-parallel-size 4
vllm serve unsloth/Llama-3.3-70B-Instruct-bnb-4bit --quantization "bitsandbytes" --load_format "bitsandbytes"
MedAgentSim supports three core interaction modes:
MedAgentSim is compatible with various LLMs:
MedAgentSim has been evaluated on several medical benchmarks:
| Benchmark | Description | #Cases |
|---|---|---|
| NEJM | Complex real-world cases | 15 |
| NEJM Extended | Additional complex cases | 120 |
| MedQA | Simulated diagnostic scenarios | 106 |
| MedQA Extended | Extended diagnostic scenarios | 214 |
| MIMIC-IV | Real-world clinical cases | 288 |
CUDA_VISIBLE_DEVICES=0,1,2,3 vllm serve meta-llama/Llama-3.1-70B-Instruct \
--tensor-parallel-size 4 \
--max-model-len 8192
python medsim/main.py \
--doctor_llm meta-llama/Llama-3.1-70B-Instruct \
--patient_llm meta-llama/Llama-3.1-70B-Instruct \
--measurement_llm meta-llama/Llama-3.1-70B-Instruct \
--moderator_llm meta-llama/Llama-3.1-70B-Instruct \
--agent_dataset MedQA
We also support ollama,
python medsim/main.py \
--doctor_llm llama3.3:70b \
--patient_llm llama3.3:70b \
--measurement_llm llama3.3:70b \
--moderator_llm llama3.3:70b \
--agent_dataset MedQA
MedAgentSim/
βββ assets/ # Images, CSS, and other static files
βββ datasets/ # Sample datasets and medical knowledge base. Put your dataset here
βββ docs/ # Documentation. Coming soon
βββ medsim/ # Core simulation code
β βββ configs/ # configs for for models
β βββ core/ # Agent implementations
β βββ server/ # Simulation environment server
β βββ simulate/ # Multi-agnet running interfaces
β βββ utils/ # Utility functions
βββ Simulacra/ # Backend support
βββ MedPromptSimulate/ # Dignosis memory support
βββ examples/ # Example scenarios and configurations
βββ tests/ # Unit and integration tests. Coming soon
βββ requirements.txt # Python dependencies
βββ LICENSE # License information
βββ README.md # This file
from datasets import load_dataset
# Load all files
ds = load_dataset("ItsMaxNorm/MedAgentSim-datasets")
# Load a specific file
ds = load_dataset("ItsMaxNorm/MedAgentSim-datasets", data_files="medqa_v1.parquet")
# Access the data
print(ds["train"][0])
We welcome contributions to MedAgentSim! Please see CONTRIBUTING.md for details on how to get started.
This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0) - see https://creativecommons.org/licenses/by-nc-sa/4.0/ for details.
If you use MedAgentSim in your research, please cite our paper:
@inproceedings{almansooriandkumarMedAgentSim,
title={Self-Evolving Multi-Agent Simulations for Realistic Clinical Interactions},
author={Mohammad Almansoori and Komal Kumar and Hisham Cholakkal},
booktitle={International Conference on Medical Image Computing and Computer-Assisted Intervention},
year={2025}
}
For questions or support, please open an issue or contact the maintainers:
Python
54.0%
Jupyter Notebook
29.6%
HTML
13.0%
Stata
3.3%