🚀 MatCha - 基礎模型卡片
MatCha基礎模型可用於視覺問答任務,能有效處理圖表、圖像等視覺語言數據,提升視覺語言模型對圖表和語言數據的聯合建模能力。
🚀 快速開始
本模型是MatCha基礎模型,僅可用於微調。

📚 詳細文檔
內容目錄
- 簡要概述
- 模型使用
- 貢獻者
- 引用信息
簡要概述
論文摘要指出:
視覺語言數據(如圖表、繪圖和信息圖)在人類世界中無處不在。然而,現有的最先進的視覺語言模型在處理這些數據時表現不佳。我們提出了MATCHA(數學推理和圖表反渲染預訓練),以增強視覺語言模型對圖表/繪圖和語言數據進行聯合建模的能力。具體來說,我們提出了幾個預訓練任務,涵蓋了繪圖解構和數值推理,這些都是視覺語言建模中的關鍵能力。我們從最近提出的圖像到文本視覺語言模型Pix2Struct開始進行MATCHA預訓練。在PlotQA和ChartQA等標準基準測試中,MATCHA模型的表現比現有最先進的方法高出近20%。我們還研究了MATCHA預訓練在截圖、教科書圖表和文檔圖形等領域的遷移效果,並觀察到整體性能有所提升,這驗證了MATCHA預訓練在更廣泛的視覺語言任務中的實用性。
模型使用
基礎用法
from transformers import Pix2StructProcessor, Pix2StructForConditionalGeneration
import requests
from PIL import Image
processor = Pix2StructProcessor.from_pretrained('google/matcha-base')
model = Pix2StructForConditionalGeneration.from_pretrained('google/matcha-base')
url = "https://raw.githubusercontent.com/vis-nlp/ChartQA/main/ChartQA%20Dataset/val/png/20294671002019.png"
image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(images=image, text="Is the sum of all 4 places greater than Laos?", return_tensors="pt")
predictions = model.generate(**inputs, max_new_tokens=512)
print(processor.decode(predictions[0], skip_special_tokens=True))
>>> No
從T5x轉換到Hugging Face
你可以使用convert_pix2struct_checkpoint_to_pytorch.py
腳本進行轉換:
python convert_pix2struct_checkpoint_to_pytorch.py --t5x_checkpoint_path PATH_TO_T5X_CHECKPOINTS --pytorch_dump_path PATH_TO_SAVE --is_vqa
如果你要轉換一個大模型,請運行:
python convert_pix2struct_checkpoint_to_pytorch.py --t5x_checkpoint_path PATH_TO_T5X_CHECKPOINTS --pytorch_dump_path PATH_TO_SAVE --use-large --is_vqa
保存後,你可以使用以下代碼將轉換後的模型推送到Hugging Face Hub:
from transformers import Pix2StructForConditionalGeneration, Pix2StructProcessor
model = Pix2StructForConditionalGeneration.from_pretrained(PATH_TO_SAVE)
processor = Pix2StructProcessor.from_pretrained(PATH_TO_SAVE)
model.push_to_hub("USERNAME/MODEL_NAME")
processor.push_to_hub("USERNAME/MODEL_NAME")
貢獻者
該模型最初由Fangyu Liu、Francesco Piccinno等人貢獻,並由Younes Belkada添加到Hugging Face生態系統中。
引用信息
如果你想引用這項工作,請考慮引用原始論文:
@misc{liu2022matcha,
title={MatCha: Enhancing Visual Language Pretraining with Math Reasoning and Chart Derendering},
author={Fangyu Liu and Francesco Piccinno and Syrine Krichene and Chenxi Pang and Kenton Lee and Mandar Joshi and Yasemin Altun and Nigel Collier and Julian Martin Eisenschlos},
year={2022},
eprint={2212.09662},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
模型信息
屬性 |
詳情 |
支持語言 |
英語、法語、羅馬尼亞語、德語、多語言 |
推理功能 |
不支持 |
任務類型 |
視覺問答 |
許可證 |
Apache 2.0 |
標籤 |
matcha |