开始使用免费开始使用

使用 LayoutLM 进行文档 VQA

从图像 VQA 过渡到文档 VQA!在本练习中,您将使用 layoutlm-document-qa 模型,从下方这张文档图像中找出 2012–2013 年对员工提供的培训总时长:

Newsletter from an ICT company

数据集(dataset)已加载,pipeline 模块(pipeline)也已导入。

本练习是课程的一部分

使用 Hugging Face 的多模态模型

查看课程

练习说明

  • 使用 'document-question-answering' 任务和 'impira/layoutlm-document-qa' checkpoint 加载 pipeline。
  • 处理 datasettest 集的第 61 个数据点,构造合适的提示语,找出 2012–2013 年向员工提供了多少天的正式培训。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Load the document-question-answering pipeline with the pretrained model
pipe = ____

# Process datapoint 61 to find the amount of training days
result = ____(dataset["____"][61]["____"], "____")

print(result)
编辑并运行代码