Home

Awesome

MMC: Advancing Multimodal Chart Understanding with LLM Instruction Tuning

<div align="center"> <a href="https://arxiv.org/abs/2311.10774"><img src="https://img.shields.io/badge/Paper-arXiv-red" alt="arXiv"></a> <a href="https://huggingface.co/datasets/xywang1/MMC"><img src="https://img.shields.io/badge/Dataset-%F0%9F%A4%97%20Hugging_Face-yellow" alt="Hugging Face"></a> <a href="https://aclanthology.org/2024.naacl-long.70"><img src="https://img.shields.io/badge/NAACL-2024-blue" alt="NAACL 2024"></a> </div>

This is the official GitHub repo of the paper MMC: Advancing Multimodal Chart Understanding with Large-scale Instruction Tuning.

News

Highlights

<div align="center"> <img src="./images/overview.png" width="90%"> </div>

Data Release

The chart-text alignment data (MMC-Alignment), chart instruction-tuning data (MMC-Instruction), and benchmark data (MMC-Benchmark) introduced in our paper can be downloaded from Hugging Face Datasets using git clone:

git lfs install
git clone https://huggingface.co/datasets/xywang1/MMC

It contains three sub-directories MMC-Alignment, MMC-Benchmark, and MMC-Instruction:

MMC-Alignment

MMC-Benchmark

MMC-Instruction

Existing Datasets

As mentioned in the paper, chart summarization datasets from Statist, PlotQA, VisText, ChartInfo, and Unichart are used in our experiments for chart-text alignment training. Please refer to the following script for details:

# Existing chart-text alignment images
gdown https://drive.google.com/uc?id=1e1mx_nb5PWjPkuIsJkY8B4xSET9DOWTa
# Existing chart-text alignment text
gdown https://drive.google.com/uc?id=18SJ13V4qEt1ixOQPbRmEnZKQrjS5v14T

For existing Chart QA training data, please refer to the following script:

# Existing chart qa images
gdown https://drive.google.com/uc?id=1Y17wNYdBlPxhB5KKiux2BD8C2FlA5MC9
# Existing chart qa text
gdown https://drive.google.com/uc?id=1tUtntLRgsBJ9v5NcdTMvVI32ruLHAyFe

MMCA Gradio demo

1. Install the environment according to mplug-owl.

We finetuned mplug-owl on 8 V100. If you meet any questions when implement on V100, feel free to let me know!

2. Download the Checkpoint

gdown https://drive.google.com/uc?id=11KJA8bSNi1yxgcijsG3xfBHvWe8C748F

3. Edit the Code

As for the mplug-owl/serve/model_worker.py, edit the following code and enter the path of the lora model weight in lora_path.

self.image_processor = MplugOwlImageProcessor.from_pretrained(base_model)
self.tokenizer = AutoTokenizer.from_pretrained(base_model)
self.processor = MplugOwlProcessor(self.image_processor, self.tokenizer)
self.model = MplugOwlForConditionalGeneration.from_pretrained(
     base_model,
     load_in_8bit=load_in_8bit,
     torch_dtype=torch.bfloat16 if bf16 else torch.half,
     device_map="auto"
 )
self.tokenizer = self.processor.tokenizer

        
peft_config = LoraConfig(target_modules=r'.*language_model.*\.(q_proj|v_proj)', inference_mode=False, r=8,lora_alpha=32, lora_dropout=0.05)
self.model = get_peft_model(self.model, peft_config)
lora_path = 'Your lora model path'
prefix_state_dict = torch.load(lora_path, map_location='cpu')
self.model.load_state_dict(prefix_state_dict)

4. Local Demo

When you launch the demo in local machine, you might find there is no space for the text input. This is because of the version conflict between python and gradio. The simplest solution is to do conda activate LRV

python -m serve.web_server --base-model 'the mplug-owl checkpoint directory' --bf16

Contact

If you have any questions about this work, please email Fuxiao Liu fl3es@umd.edu.

Citation

@article{liu2023mmc,
  title={MMC: Advancing Multimodal Chart Understanding with Large-scale Instruction Tuning},
  author={Liu, Fuxiao and Wang, Xiaoyang and Yao, Wenlin and Chen, Jianshu and Song, Kaiqiang and Cho, Sangwoo and Yacoob, Yaser and Yu, Dong},
  journal={arXiv preprint arXiv:2311.10774},
  year={2023}
}

Disclaimer

We develop this repository for RESEARCH purposes, so it can only be used for personal/research/non-commercial purposes.