SkillAgentSearch skills...

LLaVA Med

Large Language-and-Vision Assistant for Biomedicine, built towards multimodal GPT-4 level capabilities.

Install / Use

npx skills add microsoft/LLaVA-Med

Installs into whichever agent you are using.

About this skill

Quality Score

0/100

Supported Platforms

Universal

README

LLaVA-Med: Large Language and Vision Assistant for Biomedicine

Visual instruction tuning towards building large language and vision models with GPT-4 level capabilities in the biomedicine space.

[Paper, NeurIPS 2023 Datasets and Benchmarks Track (Spotlight)]

LLaVA-Med: Training a Large Language-and-Vision Assistant for Biomedicine in One Day <br>

Chunyuan Li*, Cliff Wong*, Sheng Zhang*, Naoto Usuyama, Haotian Liu, Jianwei Yang, Tristan Naumann, Hoifung Poon, Jianfeng Gao (*Equal Contribution)

<p align="center"> <img src="images/llava_med_logo.png" width="50%"> <br>

Generated by <a href="https://gligen.github.io/">GLIGEN</a> using the grounded inpainting mode, with three boxes: white doctor coat, stethoscope, white doctor hat with a red cross sign.

</p>

Release

  • [May 13, 2024] 🔥LLaVA-Med v1.5 is out! It is not only significantly better (see the evaluation results.) but also much easier to use: no more delta weights! Now you can directly load our model from the 🤗 Hub. The original LLaVA-Med (i.e., v1.0.0) codebase has been moved to Archive.
  • [Nov 8, 2023] LLaVA-Med is open-sourced under the MSR release policy. Huge thanks to commitment of the team, and patience of the community.
  • [Sept, 2023] LLaVA-Med is accepted in NeurIPS 2023 Datasets and Benchmarks Track, as a spotlight presentation.
  • [June 1, 2023] 🔥 We released LLaVA-Med: Large Language and Vision Assistant for Biomedicine, a step towards building biomedical domain large language and vision models with GPT-4 level capabilities. Checkout the paper
<p align="center"> <img src="images/llava_med_pipeline.png" width="90%"> <br>

LLaVA-Med was initialized with the general-domain LLaVA and then continuously trained in a curriculum learning fashion (first biomedical concept alignment then full-blown instruction-tuning). We evaluated LLaVA-Med on standard visual conversation and question answering tasks.

</p>

Code License Data License Usage and License Notices: The data, code, and model checkpoints are intended and licensed for research use only. They are also subject to additional restrictions dictated by the Terms of Use: LLaMA, Vicuna and GPT-4 respectively. The data is made available under CC BY NC 4.0. The data, code, and model checkpoints may be used for non-commercial purposes and any models trained using the dataset should be used only for research purposes. It is expressly prohibited for models trained on this data to be used in clinical care or for any clinical decision making purposes.

Contents

Install

  1. Clone this repository and navigate to LLaVA-Med folder
https://github.com/microsoft/LLaVA-Med.git
cd LLaVA-Med
  1. Install Package: Create conda environment
conda create -n llava-med python=3.10 -y
conda activate llava-med
pip install --upgrade pip  # enable PEP 660 support
pip install -e .

Model Download

Model Descriptions | 🤗 Huggingface Hub | | --- | ---: | | LLaVA-Med v1.5 | microsoft/llava-med-v1.5-mistral-7b |

Serving

Web UI

Launch a controller

python -m llava.serve.controller --host 0.0.0.0 --port 10000

Launch a model worker

python -m llava.serve.model_worker --host 0.0.0.0 --controller http://localhost:10000 --port 40000 --worker http://localhost:40000 --model-path microsoft/llava-med-v1.5-mistral-7b --multi-modal

Wait until the process finishes loading the model and you see "Uvicorn running on ...".

Launch a model worker (Multiple GPUs, when GPU VRAM <= 24GB)

If your the VRAM of your GPU is less than 24GB (e.g., RTX 3090, RTX 4090, etc.), you may try running it with multiple GPUs.

python -m llava.serve.model_worker --host 0.0.0.0 --controller http://localhost:10000 --port 40000 --worker http://localhost:40000 --model-path microsoft/llava-med-v1.5-mistral-7b --multi-modal --num-gpus 2

Wait until the process finishes loading the model and you see "Uvicorn running on ...".

Send a test message

python -m llava.serve.test_message --model-name llava-med-v1.5-mistral-7b --controller http://localhost:10000

Launch a gradio web server.

python -m llava.serve.gradio_web_server --controller http://localhost:10000

You can open your browser and chat with a model now.

Evaluation

Medical Visual Chat (GPT-assisted Evaluation)

Our GPT-assisted evaluation pipeline for multimodal modeling is provided for a comprehensive understanding of the capabilities of vision-language models. Please see our paper for more details.

1. Azure OpenAI Connection Info.

Open llava/eval/llm.py and insert your Azure OpenAI Endpoint and API KEY

openai_cxn_dict = {
    'default': {
      'endpoint': "INSERT YOUR AZURE OPENAI ENDPOINT HERE",
      'api_key': "INSERT YOUR AZURE OPENAI API KEY HERE",
    },
  }
  • GPT-4 inference was only tested using Azure OpenAI API. If you are using OpenAI API, you need to replace llava/eval/llm.py (line 55) AsyncAzureOpenAI with AsyncOpenAI.

2. Deployment ID

In llava/eval/eval_multimodal_chat_gpt_score.py (line 55), replace with your GPT-4 model deployment id if necessary:

3. Download Images

python llava/data/download_images.py \
    --input_path data/llava_med_test_image_urls.jsonl \
    --pmc_output_path data/pmc \
    --images_output_path data/images

4. Multimodal Chat Inference

In our case, llava_med_eval_qa50_qa.jsonl contains the questions, context (captions and inline-mentions) and responses generated by text-only GPT-4 (0314), which we treat as ground truth.

PYTHONPATH=. python llava/eval/model_vqa.py \
    --conv-mode mistral_instruct \
    --model-path microsoft/llava-med-v1.5-mistral-7b \
    --question-file data/eval/llava_med_eval_qa50_qa.jsonl \
    --image-folder data/images \
    --answers-file /path/to/answer-file.jsonl \
    --temperature 0.0

5. GPT-4 Evaluation of the Generated Answers

python llava/eval/eval_multimodal_chat_gpt_score.py \
    --answers-file /path/to/answer-file.jsonl \
    --question-file data/eval/llava_med_eval_qa50_qa.jsonl \
    --scores-file /path/to/scores-file.jsonl

6. Summarize the Evaluation Results

python llava/eval/summarize_gpt_review.py \
    --scores-file /path/to/scores-file.jsonl

Data Download

LLaVA-Med Dataset

<p align="center"> <img src="images/llava_med_dataset.png" width="90%"> <br>

The data statistics of biomedical multimodal instruction-following data: (a,b) The root verb-noun pairs of instruction and responses, where the inner circle of the plot represents the root verb of the output response, and the outer circle represents the direct nouns. (c) The distribution of images and QA pairs on the five domains, one image is shown per domain.

</p>

Data Download

| Alignment data files | Size | | --- | ---: | | llava_med_alignment_500k.json | 341.52 MiB |

| Instruction-Tuning data files | Size | | --- | ---: | | llava_med_instruct_10k.json | 19.24 MiB | | llava_med_instruct_60k.json | 84.65 MiB | | llava_med_instruct_60k_inline_mention.json | 83.61 MiB | | llava_med_instruct_fig_captions.json | 161.39 MiB |

| Evaluation files | Size | | --- | ---: | | llava_med_eval_qa50_qa.jsonl | 256.18 KiB | | llava_med_eval_qa50_fig_captions.json | 51.82 KiB | | llava_med_qa50_instruct_caption_in_text_cleaned-60k-3epoch.json | 100.97 KiB |

| Image URLS | Size | | --- | ---: | | llava_med_image_urls.jsonl | 122.82 MiB |

download_images.py is used to download the PMC articles using the above image_urls file and extract the images

To download our langauge-image multimodal instruction-folllowing dataset, please run the following script:

sh download_data.sh

Archive

Model Description

Large Language and Vision Assistant for bioMedicine (i.e., “LLaVA-Med”) is a large language and vision model trained using a curriculum learning method for adapting LLaVA to the biomedical domain. It is an open-source release intended f

Related Skills

View on GitHub
GitHub Stars2.2k
CategoryDevelopment
Updated8d ago
Forks291

Languages

Python

Security Score

80/100

Audited on Jul 31, 2026

No findings