- [13/05/2025] π Our paper MedAgentSim: Self-Evolving Multi-Agent Simulations for Realistic Clinical Interactions has been accepted early at MICCAI 2025.
- [31/03/2025] π₯ We release MedAgentSim: Self-Evolving Multi-Agent Simulations for Realistic Clinical 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:
- Multi-Agent Architecture: Doctor, patient, and measurement agents interact in a realistic clinical setting
- Self-Improvement Mechanisms: Models iteratively refine their diagnostic strategies through experience
- Experience Replay: Past successful diagnoses inform future cases through knowledge retrieval
- Visual Game Simulation: Built with Phaser for an intuitive, interactive environment
- Multi-Modal Capabilities: Integration with vision language models for medical image interpretation
# 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:
- Generation Mode: Patient agent autonomously creates cases, generating illnesses, symptoms, and test results
- Dataset Mode: Patient responses derived from predefined medical datasets
- Control Mode: Human users can control either the doctor or patient agent for real-time interaction
MedAgentSim is compatible with various LLMs:
- Open-Source Models: LLaMA 3.3, Mistral, Mixtral, Qwen2
- Vision-Language Models: LLaVA 1.5, QwenVL
- Custom Models: Integrate your own models following our documentation
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 |
- Launch the vLLM server (with appropriate GPUs):
CUDA_VISIBLE_DEVICES=0,1,2,3 vllm serve meta-llama/Llama-3.1-70B-Instruct \
--tensor-parallel-size 4 \
--max-model-len 8192
- Run the simulation:
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
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
coming soon!
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}
}
- Thanks to AgentClinic, Microsoft PromptBase, and Generative Agents for open-sourcing their works
- Mohamed bin Zayed University of Artificial Intelligence for supporting this research
- We encourage you to support the following three talented artists whose assets were used in this project, especially if you are planning to use the assets included here for your own project:
- Background art: PixyMoon (@_PixyMoon_)
- Furniture/interior design: LimeZu (@lime_px)
- Character design: γ΄γ½ (@pipohi)
- Open-source multi-agent framework: CAMEL-AI OWL
- Multi-agent framework: OpenMANAUS
- MedPrompt Blog: The Power of Prompting
- MedPrompt Research Paper: https://arxiv.org/abs/2311.16452
- MedPrompt+: Steering at the Frontier: Extending the Power of Prompting
- Microsoft Introduction to Prompt Engineering: https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/prompt-engineering
- Microsoft Advanced Prompt Engineering Guide: https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/advanced-prompt-engineering?pivots=programming-language-chat-completions
For questions or support, please open an issue or contact the maintainers:
- GitHub: @MAXNORM8650
Made with β€οΈ by the MedAgentSim Team