🚀 MatCha - 在Chart2text-pew上微調的模型
MatCha是一個視覺語言模型,該模型在Chart2text-pew數據集上進行了微調,微調後的檢查點可能更適合圖表摘要任務。
🚀 快速開始
使用模型
from transformers import Pix2StructProcessor, Pix2StructForConditionalGeneration
import requests
from PIL import Image
processor = Pix2StructProcessor.from_pretrained('google/matcha-chart2text-pew')
model = Pix2StructForConditionalGeneration.from_pretrained('google/matcha-chart2text-pew')
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, return_tensors="pt")
predictions = model.generate(**inputs, max_new_tokens=512)
print(processor.decode(predictions[0], skip_special_tokens=True))
從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")
✨ 主要特性
論文摘要指出:
視覺語言數據,如圖表、圖形和信息圖等,在人類世界中無處不在。然而,現有的視覺語言模型在處理這些數據時表現不佳。我們提出了MATCHA(數學推理和圖表反渲染預訓練)方法,以增強視覺語言模型對圖表/圖形和語言數據進行聯合建模的能力。具體來說,我們提出了幾個預訓練任務,涵蓋了圖形解構和數值推理,這是視覺語言建模中的關鍵能力。我們從最近提出的圖像到文本視覺語言模型Pix2Struct開始進行MATCHA預訓練。在PlotQA和ChartQA等標準基準測試中,MATCHA模型的表現比現有方法高出近20%。我們還研究了MATCHA預訓練在截圖、教科書圖表和文檔圖形等領域的遷移效果,並觀察到整體性能有所提升,這驗證了MATCHA預訓練在更廣泛的視覺語言任務中的有效性。
📄 許可證
本模型採用Apache 2.0許可證。
🤝 貢獻者
此模型最初由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 |
