
Whole Slide Images (WSIs) exhibit hierarchical structure, where diagnostic information emerges from cellular morphology, regional tissue organization, and global context. Existing Computational Pathology (CPath) Multimodal Large Language Models (MLLMs) typically compress an entire WSI into a single embedding, which hinders fine-grained grounding and ignores how pathologists synthesize evidence across different scales. We introduce MLLM-HWSI, a Hierarchical WSI-level MLLM that aligns visual features with pathology language at four distinct scales, cell as word, patch as phrase, region as sentence, and WSI as paragraph to support interpretable evidencegrounded reasoning. MLLM-HWSI decomposes each WSI into multi-scale embeddings with scale-specific projectors and jointly enforces (i) a hierarchical contrastive objective and (ii) a cross-scale consistency loss, preserving semantic coherence from cells to the WSI. We compute diagnostically relevant patches and aggregate segmented cell embeddings into a compact cellular token per-patch using a lightweight Cell–Cell Attention Fusion (CCAF) transformer. The projected multi-scale tokens are fused with text tokens and fed to an instruction-tuned LLM for open-ended reasoning, VQA, report, and caption generation tasks. Trained in three stages, MLLM-HWSI achieves new SOTA results on 13 WSIlevel benchmarks across six CPath tasks. By aligning language with multi-scale visual evidence, MLLM-HWSI provides accurate, interpretable outputs that mirror diagnostic workflows and advance holistic WSI understanding.
git clone https://github.com/BasitAlawode/MLLM-HWSI
cd MLLM-HWSI
conda create -y --name mllm_hwsi python==3.10.0
conda activate mllm_hwsi
pip install torch==2.11.0 torchvision==0.26.0 torchaudio==2.11.0 --index-url https://download.pytorch.org/whl/cu130
pip install -r requirements.txt
Download the train and test set json files from WSI-LLaVA repository.
Download train and test WSI .svs from here and put them in your preferred directory.
Note: Ensure the downloaded WSI slide_ids matches the ones in the json files.
├── ./data # Base data directory
│ ├── trainWSI # training data folder
| │ ├── <slide_id_1>.svs
| │ ├── <slide_id_2>.svs
| │ └── <slide_id_3>.svs
| | ...
│ ├── testWSI # test data folder
| │ ├── <slide_id_1>.svs
| │ ├── <slide_id_2>.svs
| │ └── <slide_id_3>.svs
| | ...
As our method (MLLM-HWSI) involves region, patches, and cell feature extraction from the WSIs, it is recommended to perform these steps before training or testing.
NOTE: Steps 1 to 4 below should be performed sequentially.
python ext_regions.py \
--source <WSI directory> \
--save_dir <regions save directory> \
--seg \
--patch \
--stitch
python ext_feats_conch_hierar_par.py \
--wsi_dir <WSI directory> \
--reports_path <Report json file path or None for inference data> \
--h5_dir_4096 <regions save directory>/patches \
--hipt_repo ./HIPT_4K \
--checkpoint256 <hipt 256 model.pth path> \
--checkpoint4k <hipt 4096 model.pth path> \
--trident_repo ./trident \
--conch_ckpt_path <conch.bin model path> \
--data_mode <train or inference> \
--out_dir <features save directory> \
--extract_patch_features \
--all_gpus \
--workers_per_gpu 1
Note: You may
python ext_cell_feat_par.py \
--wsi_dir <Train or Test WSI directory> \
--region_coords_dir <features save directory>/coords_region4096_valid \
--selected_indices_dir <features save directory>/patches_filtered \
--checkpoint <cellvit 256 model.pth path> \
--output_dir <features save directory>/cells \
--all_gpus \
--workers_per_gpu 1 \
--enforce_amp \
Note: You may
python save_patch_images.py \
--wsi_dir <Train or Test WSI directory> \
--coords_dir <features save directory>/coords_region4096_valid \
--indices_dir <features save directory>/patches_filtered \
--output_dir <features save directory>/sample_images \
--region_size 4096 \
--patch_size 256 \
--max_wsi 2 \
--max_regions_per_wsi 20 \
--selection_mode random
Note:
Edit edit MODEL_DIR, BASE_DIR, and TRAIN_SUB_FOLDER in run_train.sh.
Run
./run_train.sh 2
./run_train.sh 3
./run_train.sh 2 3
--model_name Bastech/MLLM-HWSI. However, you may download and save it locally.Edit edit BASE_DIR, DATA_DIR, TEST_TYPE, TASK in run_infer.sh.
Run
./run_infer.sh
main_test.py file. You may tweak them to your particular applications.python main_chat.py --port <port_number e.g. 8080>
This work acknowledges the authors of the following repositories:
| WSI-LLaVA | CLAM | TRIDENT | HIPT | CONCH | CellViT |
If you find our work useful in your research, please consider citing:
@InProceedings{Alawode_2026_CVPR,
author = {Alawode, Basit and Mahmood, Arif and Al Radi, Muaz Khalifa and Albastaki, Shahad and Khan, Asim and Bilal, Muhammad and Abdalla, Moshira Ali and Bennamoun, Mohammed and Javed, Sajid},
title = {MLLM-HWSI: A Multimodal Large Language Model for Hierarchical Whole Slide Image Understanding},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2026},
pages = {13732-13743}
}
@article{alawode2026mllmhwsi,
title={MLLM-HWSI: A Multimodal Large Language Model for Hierarchical Whole Slide Image Understanding},
author={Basit Alawode and Arif Mahmood and Muaz Khalifa Al-Radi and Shahad Albastaki and Asim Khan and Muhammad Bilal and Moshira Ali Abdalla and Mohammed Bennamoun and Sajid Javed},
year={2026},
eprint={2603.23067},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2603.23067},
}
41 commits
Python
99.8%

Whole Slide Images (WSIs) exhibit hierarchical structure, where diagnostic information emerges from cellular morphology, regional tissue organization, and global context. Existing Computational Pathology (CPath) Multimodal Large Language Models (MLLMs) typically compress an entire WSI into a single embedding, which hinders fine-grained grounding and ignores how pathologists synthesize evidence across different scales. We introduce MLLM-HWSI, a Hierarchical WSI-level MLLM that aligns visual features with pathology language at four distinct scales, cell as word, patch as phrase, region as sentence, and WSI as paragraph to support interpretable evidencegrounded reasoning. MLLM-HWSI decomposes each WSI into multi-scale embeddings with scale-specific projectors and jointly enforces (i) a hierarchical contrastive objective and (ii) a cross-scale consistency loss, preserving semantic coherence from cells to the WSI. We compute diagnostically relevant patches and aggregate segmented cell embeddings into a compact cellular token per-patch using a lightweight Cell–Cell Attention Fusion (CCAF) transformer. The projected multi-scale tokens are fused with text tokens and fed to an instruction-tuned LLM for open-ended reasoning, VQA, report, and caption generation tasks. Trained in three stages, MLLM-HWSI achieves new SOTA results on 13 WSIlevel benchmarks across six CPath tasks. By aligning language with multi-scale visual evidence, MLLM-HWSI provides accurate, interpretable outputs that mirror diagnostic workflows and advance holistic WSI understanding.
git clone https://github.com/BasitAlawode/MLLM-HWSI
cd MLLM-HWSI
conda create -y --name mllm_hwsi python==3.10.0
conda activate mllm_hwsi
pip install torch==2.11.0 torchvision==0.26.0 torchaudio==2.11.0 --index-url https://download.pytorch.org/whl/cu130
pip install -r requirements.txt
Download the train and test set json files from WSI-LLaVA repository.
Download train and test WSI .svs from here and put them in your preferred directory.
Note: Ensure the downloaded WSI slide_ids matches the ones in the json files.
├── ./data # Base data directory
│ ├── trainWSI # training data folder
| │ ├── <slide_id_1>.svs
| │ ├── <slide_id_2>.svs
| │ └── <slide_id_3>.svs
| | ...
│ ├── testWSI # test data folder
| │ ├── <slide_id_1>.svs
| │ ├── <slide_id_2>.svs
| │ └── <slide_id_3>.svs
| | ...
As our method (MLLM-HWSI) involves region, patches, and cell feature extraction from the WSIs, it is recommended to perform these steps before training or testing.
NOTE: Steps 1 to 4 below should be performed sequentially.
python ext_regions.py \
--source <WSI directory> \
--save_dir <regions save directory> \
--seg \
--patch \
--stitch
python ext_feats_conch_hierar_par.py \
--wsi_dir <WSI directory> \
--reports_path <Report json file path or None for inference data> \
--h5_dir_4096 <regions save directory>/patches \
--hipt_repo ./HIPT_4K \
--checkpoint256 <hipt 256 model.pth path> \
--checkpoint4k <hipt 4096 model.pth path> \
--trident_repo ./trident \
--conch_ckpt_path <conch.bin model path> \
--data_mode <train or inference> \
--out_dir <features save directory> \
--extract_patch_features \
--all_gpus \
--workers_per_gpu 1
Note: You may
python ext_cell_feat_par.py \
--wsi_dir <Train or Test WSI directory> \
--region_coords_dir <features save directory>/coords_region4096_valid \
--selected_indices_dir <features save directory>/patches_filtered \
--checkpoint <cellvit 256 model.pth path> \
--output_dir <features save directory>/cells \
--all_gpus \
--workers_per_gpu 1 \
--enforce_amp \
Note: You may
python save_patch_images.py \
--wsi_dir <Train or Test WSI directory> \
--coords_dir <features save directory>/coords_region4096_valid \
--indices_dir <features save directory>/patches_filtered \
--output_dir <features save directory>/sample_images \
--region_size 4096 \
--patch_size 256 \
--max_wsi 2 \
--max_regions_per_wsi 20 \
--selection_mode random
Note:
Edit edit MODEL_DIR, BASE_DIR, and TRAIN_SUB_FOLDER in run_train.sh.
Run
./run_train.sh 2
./run_train.sh 3
./run_train.sh 2 3
--model_name Bastech/MLLM-HWSI. However, you may download and save it locally.Edit edit BASE_DIR, DATA_DIR, TEST_TYPE, TASK in run_infer.sh.
Run
./run_infer.sh
main_test.py file. You may tweak them to your particular applications.python main_chat.py --port <port_number e.g. 8080>
This work acknowledges the authors of the following repositories:
| WSI-LLaVA | CLAM | TRIDENT | HIPT | CONCH | CellViT |
If you find our work useful in your research, please consider citing:
@InProceedings{Alawode_2026_CVPR,
author = {Alawode, Basit and Mahmood, Arif and Al Radi, Muaz Khalifa and Albastaki, Shahad and Khan, Asim and Bilal, Muhammad and Abdalla, Moshira Ali and Bennamoun, Mohammed and Javed, Sajid},
title = {MLLM-HWSI: A Multimodal Large Language Model for Hierarchical Whole Slide Image Understanding},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2026},
pages = {13732-13743}
}
@article{alawode2026mllmhwsi,
title={MLLM-HWSI: A Multimodal Large Language Model for Hierarchical Whole Slide Image Understanding},
author={Basit Alawode and Arif Mahmood and Muaz Khalifa Al-Radi and Shahad Albastaki and Asim Khan and Muhammad Bilal and Moshira Ali Abdalla and Mohammed Bennamoun and Sajid Javed},
year={2026},
eprint={2603.23067},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2603.23067},
}
41 commits
Python
99.8%