This is a LlavaNext model finetuned on a synthetic dataset of bar, line, and pie charts.
The goal is to detect if there is a misleading element in a chart image.
The types of misleading elements that we propose are limited to: non-zero baseline for bar charts,
omission of x-axis data points for line charts, and segments do not sum up to 100% in pie charts.
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
Use the code below to get started with the model. Only works on GPU
1# Load model
2from transformers import (
3 AutoProcessor,
4 LlavaNextForConditionalGeneration,
5 BitsAndBytesConfig
6)
7from peft import PeftConfig, PeftModel
8import requests
9import torch
10
11base_model = "llava-hf/llava-v1.6-mistral-7b-hf"
12adapter_weights_repo = "chart-misinformation-detection/hf-llava-next-finetune-blp4k"
13
14quantization_config = BitsAndBytesConfig(
15 load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.float16
16)
17
18processor = AutoProcessor.from_pretrained(base_model)
19model = LlavaNextForConditionalGeneration.from_pretrained(
20 base_model,
21 torch_dtype=torch.float16,
22 quantization_config=quantization_config,
23)
24
25model = PeftModel.from_pretrained(model, adapter_weights_repo)
26
27# preprocess input
28prompt="[INST] <image>Evaluate if this chart is misleading, and if so explain [/INST]"
29image = Image.open(requests.get(image_url, stream=True).raw)
30inputs = processor(prompt, image, return_tensors="pt")
31
32# inference
33output = model.generate(**inputs, max_new_tokens=500)
34print(processor.decode(output[0], skip_special_tokens=False))
BLP4k dataset(dataset of synthetically created bar, line, and pie charts including misleading and non-misleading ones)
-
Liu, Haotian, Li, Chunyuan, Li, Yuheng, Li, Bo, Zhang, Yuanhan, Shen, Sheng, & Lee, Yong Jae. (2024, January).
LLaVA-NeXT: Improved reasoning, OCR, and world knowledge. Retrieved from
https://llava-vl.github.io/blog/2024-01-30-llava-next/.
-
Liu, Haotian, Li, Chunyuan, Li, Yuheng, & Lee, Yong Jae. (2023). Improved Baselines with Visual Instruction Tuning. arXiv:2310.03744.
-
Liu, Haotian, Li, Chunyuan, Wu, Qingyang, & Lee, Yong Jae. (2023). Visual Instruction Tuning. NeurIPS.