Aofei Chang, Le Huang, Alex James Boyd, Parminder Bhatia, Taha Kass-Hout, Cao Xiao, Fenglong Ma
Medical Large Vision-Language Models (Med-LVLMs) have shown strong potential for clinical reasoning and multimodal understanding, yet they often suffer from suboptimal or misaligned visual attention. This can lead to hallucinations, incorrect diagnoses, and unreliable generation. Existing mitigation methods rely heavily on inference-time patching or require additional human supervision—both of which limit scalability and effectiveness.
A³Tune (Automatic Attention Alignment Tuning) is our new fine-tuning framework designed to train models to fix their own attention distribution. Instead of depending on gold segmentation labels, A³Tune builds a scalable supervision pipeline by:
Together, these components produce Med-LVLMs that attend more accurately, hallucinate less, and perform better across medical VQA and report-generation benchmarks.
This repository includes:
We release training and testing metadata (e.g., annotations, splits) in the ./data folder.
However, due to dataset licensing constraints, you must download the raw images yourself.
You can obtain all required images from the official sources below:
The current directory structure is as follows:
A3Tune/
├── readme.md
├── LVLMs/
├── Segment/
The weak label generation process is located in the Segment/ directory. Here, we generate weak labels for each dataset, which are then used for downstream fine-tuning.
Our primary experiments for A³TUNE are located in the LVLMs/llava-med/ directory.
Training Code:
The training code for llava-med can be found at:
llava-med/llava/train/train.py
In this file:
We import MoE module designs for A³MoE and incorporate additional parameters for training.
The preprocessing of weak labels is implemented in the LazySupervisedDataset class.
Implementation details are included in the forward function of the LlavaLlamaForCausalLM class.
The attention tuning loss function, calculate_top_attention_loss is defined in:
LVLMs/llava-med/llava/model/utils.py
Training Scripts: The training scripts for A³TUNE are located in:
llava-med/scripts/train/moe/top_heads
The inference implementation for both A³TUNE and baseline models can be found in the following directory:
llava-med/llava/eval/
Baselines: The required baseline files are stored in:
llava-med/llava/eval/
This includes the baselines avisc, PAI, and VCD. Additionally, we integrate DAMRO and M3ID within the avisc paradigm.
Main Inference File: The main file handling inference for both A³TUNE and baselines is:
llava-med/llava/eval/model_vqa_med.py
transformers)A³Tune requires a patched version of HuggingFace Transformers, customized for different Med-LVLM backbones. Although these modified packages are stored in folders named:
transformers_llava_med/transformers_llava_med1_5/they are installed under the standard package name:
import transformers
This ensures that the rest of the codebase works seamlessly without changing imports.
Folder: transformers_llava_med/
Installed package name: transformers
This version supports:
transformers:pip install -e ./transformers_llava_med
After installation:
import transformers # loads the patched version
Folder: transformers_llava_med1_5/
Installed package name: transformers
This version includes adaptations required for:
transformers:pip install -e ./transformers_llava_med1_5
After installation:
import transformers # loads the LLaVA-Med 1.5–compatible version
You should install either:
pip install -e ./transformers_llava_med
or
pip install -e ./transformers_llava_med1_5
Installing both will cause conflicts because both register under the same name: transformers.
# 1. Install PyTorch (choose the correct CUDA version)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 # we use torch==2.3.1
# 2. Install the remaining packages
pip install -r requirements.txt # for LLaVA-Med
pip install -r requirements_1_5.txt # for LLaVA-Med 1.5
# 3. Install exactly ONE patched transformers version
pip install -e ./transformers_llava_med # for LLaVA-Med
# or
pip install -e ./transformers_llava_med1_5 # for LLaVA-Med 1.5
requirements.txtThe provided requirements.txt lists the full environment used for developing and evaluating A³Tune.
However, not all packages are required for every use case. Some modules (e.g., visualization tools, evaluation toolkits, dataset-specific loaders) may not be necessary depending on what you want to run.
We do not recommend installing PyTorch directly from requirements.txt. Instead, you should install a PyTorch with CUDA version that matches your local CUDA setup.
You may remove or ignore dependencies that are not relevant to your workflow.
If you use A³Tune in your research, please cite:
@inproceedings{chang2025focus,
title = {Focus on What Matters: Enhancing Medical Vision-Language Models with Automatic Attention Alignment Tuning},
author = {Chang, Aofei and Huang, Le and Boyd, Alex James and Bhatia, Parminder
and Kass-Hout, Taha and Xiao, Cao and Ma, Fenglong},
booktitle = {Proceedings of the 63rd Annual Meeting of the Association for
Computational Linguistics (ACL)},
year = {2025},
address = {Vienna, Austria},
doi = {10.18653/v1/2025.acl-long.460},
url = {https://aclanthology.org/2025.acl-long.460/}
}
10 commits
Python
88.9%
Jupyter Notebook
10.3%
Aofei Chang, Le Huang, Alex James Boyd, Parminder Bhatia, Taha Kass-Hout, Cao Xiao, Fenglong Ma
Medical Large Vision-Language Models (Med-LVLMs) have shown strong potential for clinical reasoning and multimodal understanding, yet they often suffer from suboptimal or misaligned visual attention. This can lead to hallucinations, incorrect diagnoses, and unreliable generation. Existing mitigation methods rely heavily on inference-time patching or require additional human supervision—both of which limit scalability and effectiveness.
A³Tune (Automatic Attention Alignment Tuning) is our new fine-tuning framework designed to train models to fix their own attention distribution. Instead of depending on gold segmentation labels, A³Tune builds a scalable supervision pipeline by:
Together, these components produce Med-LVLMs that attend more accurately, hallucinate less, and perform better across medical VQA and report-generation benchmarks.
This repository includes:
We release training and testing metadata (e.g., annotations, splits) in the ./data folder.
However, due to dataset licensing constraints, you must download the raw images yourself.
You can obtain all required images from the official sources below:
The current directory structure is as follows:
A3Tune/
├── readme.md
├── LVLMs/
├── Segment/
The weak label generation process is located in the Segment/ directory. Here, we generate weak labels for each dataset, which are then used for downstream fine-tuning.
Our primary experiments for A³TUNE are located in the LVLMs/llava-med/ directory.
Training Code:
The training code for llava-med can be found at:
llava-med/llava/train/train.py
In this file:
We import MoE module designs for A³MoE and incorporate additional parameters for training.
The preprocessing of weak labels is implemented in the LazySupervisedDataset class.
Implementation details are included in the forward function of the LlavaLlamaForCausalLM class.
The attention tuning loss function, calculate_top_attention_loss is defined in:
LVLMs/llava-med/llava/model/utils.py
Training Scripts: The training scripts for A³TUNE are located in:
llava-med/scripts/train/moe/top_heads
The inference implementation for both A³TUNE and baseline models can be found in the following directory:
llava-med/llava/eval/
Baselines: The required baseline files are stored in:
llava-med/llava/eval/
This includes the baselines avisc, PAI, and VCD. Additionally, we integrate DAMRO and M3ID within the avisc paradigm.
Main Inference File: The main file handling inference for both A³TUNE and baselines is:
llava-med/llava/eval/model_vqa_med.py
transformers)A³Tune requires a patched version of HuggingFace Transformers, customized for different Med-LVLM backbones. Although these modified packages are stored in folders named:
transformers_llava_med/transformers_llava_med1_5/they are installed under the standard package name:
import transformers
This ensures that the rest of the codebase works seamlessly without changing imports.
Folder: transformers_llava_med/
Installed package name: transformers
This version supports:
transformers:pip install -e ./transformers_llava_med
After installation:
import transformers # loads the patched version
Folder: transformers_llava_med1_5/
Installed package name: transformers
This version includes adaptations required for:
transformers:pip install -e ./transformers_llava_med1_5
After installation:
import transformers # loads the LLaVA-Med 1.5–compatible version
You should install either:
pip install -e ./transformers_llava_med
or
pip install -e ./transformers_llava_med1_5
Installing both will cause conflicts because both register under the same name: transformers.
# 1. Install PyTorch (choose the correct CUDA version)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 # we use torch==2.3.1
# 2. Install the remaining packages
pip install -r requirements.txt # for LLaVA-Med
pip install -r requirements_1_5.txt # for LLaVA-Med 1.5
# 3. Install exactly ONE patched transformers version
pip install -e ./transformers_llava_med # for LLaVA-Med
# or
pip install -e ./transformers_llava_med1_5 # for LLaVA-Med 1.5
requirements.txtThe provided requirements.txt lists the full environment used for developing and evaluating A³Tune.
However, not all packages are required for every use case. Some modules (e.g., visualization tools, evaluation toolkits, dataset-specific loaders) may not be necessary depending on what you want to run.
We do not recommend installing PyTorch directly from requirements.txt. Instead, you should install a PyTorch with CUDA version that matches your local CUDA setup.
You may remove or ignore dependencies that are not relevant to your workflow.
If you use A³Tune in your research, please cite:
@inproceedings{chang2025focus,
title = {Focus on What Matters: Enhancing Medical Vision-Language Models with Automatic Attention Alignment Tuning},
author = {Chang, Aofei and Huang, Le and Boyd, Alex James and Bhatia, Parminder
and Kass-Hout, Taha and Xiao, Cao and Ma, Fenglong},
booktitle = {Proceedings of the 63rd Annual Meeting of the Association for
Computational Linguistics (ACL)},
year = {2025},
address = {Vienna, Austria},
doi = {10.18653/v1/2025.acl-long.460},
url = {https://aclanthology.org/2025.acl-long.460/}
}
10 commits
Python
88.9%
Jupyter Notebook
10.3%