模型:
rubentito/layoutlmv3-base-mpdocvqa
这是在Multipage DocVQA (MP-DocVQA)数据集上基于 Microsoft hub 预训练的LayoutLMv3模型。
该模型在 Hierarchical multimodal transformers for Multi-Page DocVQA 中被用作基线模型。
以下是使用此模型以获取给定文本特征的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]  # This is an example bounding box covering the whole image.
document_encoding = processor(image, question, context, boxes=boxes, return_tensors="pt")
outputs = model(**document_encoding)
# Get the answer
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相似度 (ANLS)
这是文本型VQA任务 (ST-VQA和DocVQA) 的标准指标。它评估了模型的推理能力,并对OCR识别错误进行平滑惩罚。详细信息请参考 Scene Text Visual Question Answering 。
答案页预测准确率 (APPA)
在MP-DocVQA任务中,模型可以提供包含回答所需信息的页面的索引。对于这个子任务,使用准确率来评估预测结果:即预测的页面是否正确。详细信息请参考 Hierarchical multimodal transformers for Multi-Page DocVQA 。
表2中展示了扩展实验的结果。您也可以在 RRC Portal 上查看实时排行榜。
| Model | HF name | Parameters | ANLS | APPA | 
|---|---|---|---|---|
| 1238321 | rubentito/bert-large-mpdocvqa | 334M | 0.4183 | 51.6177 | 
| 1239321 | rubentito/longformer-base-mpdocvqa | 148M | 0.5287 | 71.1696 | 
| 12310321 | rubentito/bigbird-base-itc-mpdocvqa | 131M | 0.4929 | 67.5433 | 
| 12311321 | rubentito/layoutlmv3-base-mpdocvqa | 125M | 0.4538 | 51.9426 | 
| 12312321 | rubentito/t5-base-mpdocvqa | 223M | 0.5050 | 0.0000 | 
| 12313321 | rubentito/hivt5-base-mpdocvqa | 316M | 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}
}