语言:
- 英文
- 法语
- 罗马尼亚语
- 德语
- 多语言
推理: 不支持
任务标签: 视觉问答
许可证: Apache-2.0
标签:
- 抹茶模型
MatCha基础模型卡

此模型为MatCha基础版本,仅适用于微调场景。
目录
- 摘要
- 使用指南
- 贡献说明
- 引用文献
摘要
论文摘要指出:
图表、统计图和信息图等视觉语言数据在人类社会中无处不在。然而当前最先进的视觉语言模型对此类数据处理能力有限。我们提出MATCHA(数学推理与图表解构预训练)方法,通过联合建模图表与语言数据来增强模型能力。特别设计了涵盖图表解构和数值推理等核心能力的预训练任务。基于最新图像到文本模型Pix2Struct进行预训练后,在PlotQA和ChartQA基准测试中,MATCHA模型以近20%的优势超越现有最佳方法。实验还验证了该预训练方法在截图、教科书图表及文档插图等领域的迁移效果,证实了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="四个地区的总和是否超过老挝?", return_tensors="pt")
predictions = model.generate(**inputs, max_new_tokens=512)
print(processor.decode(predictions[0], skip_special_tokens=True))
>>> 否
T5x格式转换指南
使用以下脚本进行格式转换:
python convert_pix2struct_checkpoint_to_pytorch.py --t5x_checkpoint_path T5X检查点路径 --pytorch_dump_path 保存路径 --is_vqa
大模型转换需添加参数:
python convert_pix2struct_checkpoint_to_pytorch.py --t5x_checkpoint_path T5X检查点路径 --pytorch_dump_path 保存路径 --use-large --is_vqa
转换完成后可通过以下代码推送至Hub:
from transformers import Pix2StructForConditionalGeneration, Pix2StructProcessor
model = Pix2StructForConditionalGeneration.from_pretrained(保存路径)
processor = Pix2StructProcessor.from_pretrained(保存路径)
model.push_to_hub("用户名/模型名")
processor.push_to_hub("用户名/模型名")
贡献说明
本模型由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}
}