MedRAX: Medical Reasoning Agent for Chest X-ray - ICML 2025
1,225
stars
73
commits
Python
primary language
Oct 31, 2025
updated

Chest X-rays (CXRs) play an integral role in driving critical decisions in disease management and patient care. While recent innovations have led to specialized models for various CXR interpretation tasks, these solutions often operate in isolation, limiting their practical utility in clinical practice. We present MedRAX, the first versatile AI agent that seamlessly integrates state-of-the-art CXR analysis tools and multimodal large language models into a unified framework. MedRAX dynamically leverages these models to address complex medical queries without requiring additional training. To rigorously evaluate its capabilities, we introduce ChestAgentBench, a comprehensive benchmark containing 2,500 complex medical queries across 7 diverse categories. Our experiments demonstrate that MedRAX achieves state-of-the-art performance compared to both open-source and proprietary models, representing a significant step toward the practical deployment of automated CXR interpretation systems.
MedRAX is built on a robust technical foundation:
We introduce ChestAgentBench, a comprehensive evaluation framework with 2,500 complex medical queries across 7 categories, built from 675 expert-curated clinical cases. The benchmark evaluates complex multi-step reasoning in CXR interpretation through:
Download the benchmark: ChestAgentBench on Hugging Face
huggingface-cli download wanglab/chestagentbench --repo-type dataset --local-dir chestagentbench
Unzip the Eurorad figures to your local MedMAX directory.
unzip chestagentbench/figures.zip
To evaluate with GPT-4o, set your OpenAI API key and run the quickstart script.
export OPENAI_API_KEY="<your-openai-api-key>"
python quickstart.py \
--model chatgpt-4o-latest \
--temperature 0.2 \
--max-cases 2 \
--log-prefix chatgpt-4o-latest \
--use-urls
# Clone the repository
git clone https://github.com/bowang-lab/MedRAX.git
cd MedRAX
# Install package
pip install -e .
# Start the Gradio interface
python main.py
or if you run into permission issues
sudo -E env "PATH=$PATH" python main.py
You need to setup the model_dir inside main.py to the directory where you want to download or already have the weights of above tools from Hugging Face.
Comment out the tools that you do not have access to.
Make sure to setup your OpenAI API key in .env file!
MedRAX supports selective tool initialization, allowing you to use only the tools you need. Tools can be specified when initializing the agent (look at main.py):
selected_tools = [
"ImageVisualizerTool",
"ChestXRayClassifierTool",
"ChestXRaySegmentationTool",
# Add or remove tools as needed
]
agent, tools_dict = initialize_agent(
"medrax/docs/system_prompts.txt",
tools_to_use=selected_tools,
model_dir="/model-weights"
)
The following tools will automatically download their model weights when initialized:
ChestXRayClassifierTool(device=device)
ChestXRaySegmentationTool(device=device)
XRayPhraseGroundingTool(
cache_dir=model_dir,
temp_dir=temp_dir,
load_in_8bit=True,
device=device
)
cache_dirLlavaMedTool(
cache_dir=model_dir,
device=device,
load_in_8bit=True
)
cache_dirChestXRayReportGeneratorTool(
cache_dir=model_dir,
device=device
)
XRayVQATool(
cache_dir=model_dir,
device=device
)
Support for MedSAM segmentation will be added in a future update.
No additional model weights required:
ImageVisualizerTool()
DicomProcessorTool(temp_dir=temp_dir)
ChestXRayGeneratorTool(
model_path=f"{model_dir}/roentgen",
temp_dir=temp_dir,
device=device
)
{model_dir}/roentgenmodel_dir or cache_dir: Base directory for model weights that Hugging Face usestemp_dir: Directory for temporary filesdevice: "cuda" for GPU, "cpu" for CPU-onlyIf you are running a local LLM using frameworks like Ollama or LM Studio, you need to configure your environment variables accordingly. For example:
export OPENAI_BASE_URL="http://localhost:11434/v1"
export OPENAI_API_KEY="ollama"
MedRAX supports OpenAI-compatible APIs, allowing regional or local LLM providers to serve as alternative backends.
For example, to use Qwen3-VL via Alibaba Cloud DashScope, set the following environment variables:
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
export OPENAI_API_KEY="<your-dashscope-api-key>"
export OPENAI_MODEL="qwen3-vl-235b-a22b-instruct"
¹ Department of Computer Science, University of Toronto, Toronto, Canada
² Vector Institute, Toronto, Canada
³ University Health Network, Toronto, Canada
⁴ Cohere, Toronto, Canada
⁵ Cohere Labs, Toronto, Canada
⁶ Department of Laboratory Medicine and Pathobiology, University of Toronto, Toronto, Canada
If you find this work useful, please cite our paper:
@misc{fallahpour2025medraxmedicalreasoningagent,
title={MedRAX: Medical Reasoning Agent for Chest X-ray},
author={Adibvafa Fallahpour and Jun Ma and Alif Munim and Hongwei Lyu and Bo Wang},
year={2025},
eprint={2502.02673},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2502.02673},
}
Made with ❤️ at University of Toronto, Vector Institute, and University Health Network
Python
95.7%
Jupyter Notebook
4.3%
MedRAX: Medical Reasoning Agent for Chest X-ray - ICML 2025
1,225
stars
73
commits
Python
primary language
Oct 31, 2025
updated

Chest X-rays (CXRs) play an integral role in driving critical decisions in disease management and patient care. While recent innovations have led to specialized models for various CXR interpretation tasks, these solutions often operate in isolation, limiting their practical utility in clinical practice. We present MedRAX, the first versatile AI agent that seamlessly integrates state-of-the-art CXR analysis tools and multimodal large language models into a unified framework. MedRAX dynamically leverages these models to address complex medical queries without requiring additional training. To rigorously evaluate its capabilities, we introduce ChestAgentBench, a comprehensive benchmark containing 2,500 complex medical queries across 7 diverse categories. Our experiments demonstrate that MedRAX achieves state-of-the-art performance compared to both open-source and proprietary models, representing a significant step toward the practical deployment of automated CXR interpretation systems.
MedRAX is built on a robust technical foundation:
We introduce ChestAgentBench, a comprehensive evaluation framework with 2,500 complex medical queries across 7 categories, built from 675 expert-curated clinical cases. The benchmark evaluates complex multi-step reasoning in CXR interpretation through:
Download the benchmark: ChestAgentBench on Hugging Face
huggingface-cli download wanglab/chestagentbench --repo-type dataset --local-dir chestagentbench
Unzip the Eurorad figures to your local MedMAX directory.
unzip chestagentbench/figures.zip
To evaluate with GPT-4o, set your OpenAI API key and run the quickstart script.
export OPENAI_API_KEY="<your-openai-api-key>"
python quickstart.py \
--model chatgpt-4o-latest \
--temperature 0.2 \
--max-cases 2 \
--log-prefix chatgpt-4o-latest \
--use-urls
# Clone the repository
git clone https://github.com/bowang-lab/MedRAX.git
cd MedRAX
# Install package
pip install -e .
# Start the Gradio interface
python main.py
or if you run into permission issues
sudo -E env "PATH=$PATH" python main.py
You need to setup the model_dir inside main.py to the directory where you want to download or already have the weights of above tools from Hugging Face.
Comment out the tools that you do not have access to.
Make sure to setup your OpenAI API key in .env file!
MedRAX supports selective tool initialization, allowing you to use only the tools you need. Tools can be specified when initializing the agent (look at main.py):
selected_tools = [
"ImageVisualizerTool",
"ChestXRayClassifierTool",
"ChestXRaySegmentationTool",
# Add or remove tools as needed
]
agent, tools_dict = initialize_agent(
"medrax/docs/system_prompts.txt",
tools_to_use=selected_tools,
model_dir="/model-weights"
)
The following tools will automatically download their model weights when initialized:
ChestXRayClassifierTool(device=device)
ChestXRaySegmentationTool(device=device)
XRayPhraseGroundingTool(
cache_dir=model_dir,
temp_dir=temp_dir,
load_in_8bit=True,
device=device
)
cache_dirLlavaMedTool(
cache_dir=model_dir,
device=device,
load_in_8bit=True
)
cache_dirChestXRayReportGeneratorTool(
cache_dir=model_dir,
device=device
)
XRayVQATool(
cache_dir=model_dir,
device=device
)
Support for MedSAM segmentation will be added in a future update.
No additional model weights required:
ImageVisualizerTool()
DicomProcessorTool(temp_dir=temp_dir)
ChestXRayGeneratorTool(
model_path=f"{model_dir}/roentgen",
temp_dir=temp_dir,
device=device
)
{model_dir}/roentgenmodel_dir or cache_dir: Base directory for model weights that Hugging Face usestemp_dir: Directory for temporary filesdevice: "cuda" for GPU, "cpu" for CPU-onlyIf you are running a local LLM using frameworks like Ollama or LM Studio, you need to configure your environment variables accordingly. For example:
export OPENAI_BASE_URL="http://localhost:11434/v1"
export OPENAI_API_KEY="ollama"
MedRAX supports OpenAI-compatible APIs, allowing regional or local LLM providers to serve as alternative backends.
For example, to use Qwen3-VL via Alibaba Cloud DashScope, set the following environment variables:
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
export OPENAI_API_KEY="<your-dashscope-api-key>"
export OPENAI_MODEL="qwen3-vl-235b-a22b-instruct"
¹ Department of Computer Science, University of Toronto, Toronto, Canada
² Vector Institute, Toronto, Canada
³ University Health Network, Toronto, Canada
⁴ Cohere, Toronto, Canada
⁵ Cohere Labs, Toronto, Canada
⁶ Department of Laboratory Medicine and Pathobiology, University of Toronto, Toronto, Canada
If you find this work useful, please cite our paper:
@misc{fallahpour2025medraxmedicalreasoningagent,
title={MedRAX: Medical Reasoning Agent for Chest X-ray},
author={Adibvafa Fallahpour and Jun Ma and Alif Munim and Hongwei Lyu and Bo Wang},
year={2025},
eprint={2502.02673},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2502.02673},
}
Made with ❤️ at University of Toronto, Vector Institute, and University Health Network
Python
95.7%
Jupyter Notebook
4.3%