Home

Awesome

KakaoBrain

🐝 Honeybee: Locality-enhanced Projector for Multimodal LLM

This is an official PyTorch Implementation of Honeybee: Locality-enhanced Projector for Multimodal LLM, Junbum Cha<sup>*</sup>, Wooyoung Kang<sup>*</sup>, Jonghwan Mun<sup>*</sup>, Byungseok Roh. [paper]

<p align="center"><img width="100%" src="./assets/fig.png"></p>

News and Updates

Selected Examples

<p align="center"><img width="80%" src="./assets/examples.png"></p>

Environment

pip install -r requirements.txt

# additional requirements for demo
pip install -r requirements_demo.txt

Model Zoo

We provide checkpoints from both the pre-training (PT) and finetuning (FT) stages.

ModelCheckpointsMMBMMESEED-ILLaVA-wMM-VetMMMUPOPE
Honeybee-C-7B-M144PT / FT70.11891.364.567.134.935.383.2
Honeybee-D-7B-M144PT / FT70.81835.563.866.3---
Honeybee-C-13B-M256PT / FT73.21944.068.275.735.636.484.3
Honeybee-D-13B-M256PT / FT73.51950.066.672.9---
ModelCheckpointsMMBMMESEED-ILLaVA-wScienceQAMM-VetMMMUPOPE
Honeybee-C-7B-M256PT / FT71.01951.365.570.693.238.137.385.5
Honeybee-C-13B-M576PT / FT73.61976.568.677.594.442.236.285.6

Data Preparation

After Downloading all of data below, organize the data in ./data.
Then, modify the data-specific argument files, such as annotation and image root paths, in configs/data_configs/train_dataset and configs/tasks, correspondingly.

Pretraining

For the pretraining stage, we use the BlipCapFilt and COYO datasets. Given their large size, we recommend downloading them according to the guidelines provided by here and storing them in the webdataset format.

Please note that we employ a filtered subset of the original COYO-700M dataset, specifically the COYO100M subset. This subset excludes image-text pairs with a CLIP similarity score below 0.3, as determined using the CLIP ViT-B/32.

Finetuning

Please download the datasets for finetuning from their official sources:

Evaluation

Please follow the official guidelines to prepare benchmark datasets: MMB, MME, SEED-Bench, ScienceQA, LLaVABench, MMVet, MMMU, POPE, and OwlEval.

For GPT-based evaluation, including LLaVABench, MMVet, and MMB (gpt matcher), OpenAI API information should be filled in tasks/llavabench/gpt_eval.py, tasks/mm_vet/mmbet_eval.py, and tasks/mmb/eval_mmb_gpt.py, respectively.

Example Commands

### Pretraining
bash scripts/pt.sh {exp_name} ${args1} ${args2} ...

### Finetuning
bash scripts/ft.sh -p {pretrained_ckpt} {exp_name} ${args1} ${args2} ...

### Evaluation
bash scripts/eval_all.sh {ckpt path}

Examples of easy run for instruction tuning with various dataset combination

# Examples
pretrained_ckpt=<path_to_pretrained_ckpt>
ft_output_dir="output/ft/<path_to_output>"
mkdir -p ${ft_output_dir}

# 1st example: sampling_weights with single quotation marks
deepspeed ./train.py \
	--config-name=finetune output_dir=${ft_output_dir} pretrained_ckpt=${pretrained_ckpt} \
	'data_config/train_dataset=[llava150k,sqa,vicuna40k]' \
	data_config.train_cfg.sampling_weights='[0.5, 0.2, 0.3]' \
	2>&1 | tee ${ft_output_dir}/train.log

# 2nd example: sampling_weights without single quotation marks; there should be no spaces between values.
deepspeed ./train.py \
	--config-name=finetune output_dir=${ft_output_dir} pretrained_ckpt=${pretrained_ckpt} \
	'data_config/train_dataset=[llava150k,sqa,vicuna40k]' \
	data_config.train_cfg.sampling_weights=[0.5,0.2,0.3] \
	2>&1 | tee ${ft_output_dir}/train.log

Strict Reproduction of Official Results

We utilized batch inference in our evaluation to accelerate experiments. The batch inference does not significantly change average scores, but individual scores may vary slightly (about ±0.1~0.2). To strictly reproduce the official results, the use of 8 devices (GPUs) is required; the number of devices influences batch construction, affecting the final scores. We used the default batch size specified in each task config, except for the largest model (Honeybee-C-13B-M576) where we used B=8 due to memory constraints.

Inference and Demo

Example code for the inference is provided in inference_example.ipynb. The example images in ./examples are adopted from mPLUG-Owl.

We also provide gradio demo:

python -m serve.web_server --bf16 --port {PORT} --base-model checkpoints/7B-C-Abs-M144/last

Citation

@inproceedings{cha2023honeybee,
  title={Honeybee: Locality-enhanced Projector for Multimodal LLM},
  author={Junbum Cha and Wooyoung Kang and Jonghwan Mun and Byungseok Roh},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2024}
}

License

The source code is licensed under Apache 2.0 License.
The pretrained weights are licensed under CC-BY-NC 4.0 License.

Acknowledgement: this project is developed based on mPLUG-Owl, which is also under the Apache 2.0 License.

Disclaimer

Kakao Brain "Honeybee" is the name of the Multimodal Large Language Model (MLLM) open source project, not the customer service brand.