🚀 LayoutLMv3 base在MP-DocVQA上微调模型
本项目使用了来自微软模型库的预训练LayoutLMv3模型,并在多页文档视觉问答(MP-DocVQA)数据集上进行了微调。
该模型在论文Hierarchical multimodal transformers for Multi-Page DocVQA中被用作基线模型。
- MP-DocVQA数据集上的实验结果见论文中的表2。
- 训练超参数可在附录D的表8中找到。
🚀 快速开始
💻 使用示例
基础用法
以下是如何在PyTorch中使用该模型获取给定文本特征的示例代码:
import torch
from transformers import LayoutLMv3Processor, LayoutLMv3ForQuestionAnswering
processor = LayoutLMv3Processor.from_pretrained("rubentito/layoutlmv3-base-mpdocvqa", apply_ocr=False)
model = LayoutLMv3ForQuestionAnswering.from_pretrained("rubentito/layoutlmv3-base-mpdocvqa")
image = Image.open("example.jpg").convert("RGB")
question = "Is this a question?"
context = ["Example"]
boxes = [0, 0, 1000, 1000]
document_encoding = processor(image, question, context, boxes=boxes, return_tensors="pt")
outputs = model(**document_encoding)
start_idx = torch.argmax(outputs.start_logits, axis=1)
end_idx = torch.argmax(outputs.end_logits, axis=1)
answers = self.processor.tokenizer.decode(input_tokens[start_idx: end_idx+1]).strip()
✨ 主要特性
📊 评估指标
平均归一化Levenshtein相似度(Average Normalized Levenshtein Similarity,ANLS)
这是基于文本的视觉问答任务(ST-VQA和DocVQA)的标准评估指标。它在评估方法推理能力的同时,会对OCR识别错误进行平滑惩罚。详细信息可查看论文Scene Text Visual Question Answering。
答案页面预测准确率(Answer Page Prediction Accuracy,APPA)
在MP-DocVQA任务中,模型可以给出回答问题所需信息所在页面的索引。对于这个子任务,使用准确率来评估预测结果,即预测的页面是否正确。详细信息可查看论文Hierarchical multimodal transformers for Multi-Page DocVQA。
📈 模型结果
更多扩展实验结果可查看论文Hierarchical multimodal transformers for Multi-Page DocVQA中的表2。你也可以在RRC门户查看实时排行榜。
模型 |
HF名称 |
参数数量 |
ANLS |
APPA |
Bert large |
rubentito/bert-large-mpdocvqa |
3.34亿 |
0.4183 |
51.6177 |
Longformer base |
rubentito/longformer-base-mpdocvqa |
1.48亿 |
0.5287 |
71.1696 |
BigBird ITC base |
rubentito/bigbird-base-itc-mpdocvqa |
1.31亿 |
0.4929 |
67.5433 |
LayoutLMv3 base |
rubentito/layoutlmv3-base-mpdocvqa |
1.25亿 |
0.4538 |
51.9426 |
T5 base |
rubentito/t5-base-mpdocvqa |
2.23亿 |
0.5050 |
0.0000 |
Hi-VT5 |
rubentito/hivt5-base-mpdocvqa |
3.16亿 |
0.6201 |
79.23 |
📚 详细文档
📖 引用信息
@article{tito2022hierarchical,
title={Hierarchical multimodal transformers for Multi-Page DocVQA},
author={Tito, Rub{\`e}n and Karatzas, Dimosthenis and Valveny, Ernest},
journal={arXiv preprint arXiv:2212.05935},
year={2022}
}
📦 模型信息
属性 |
详情 |
基础模型 |
microsoft/layoutlmv3-base |
许可证 |
cc-by-nc-sa-4.0 |
标签 |
DocVQA、Document Question Answering、Document Visual Question Answering |
数据集 |
rubentito/mp-docvqa |
语言 |
en |