impira/layoutlm-document-qa is a forked repo from huggingface. License: mit
Go to file
Ankur Goyal 1244b679e0 Update model weights 2022-08-29 16:23:57 -07:00
.gitattributes initial commit 2022-08-07 21:07:19 +00:00
README.md Revert readme change 2022-08-26 17:39:20 -07:00
config.json Upload TFLayoutLMForQuestionAnswering 2022-08-24 17:18:56 +00:00
merges.txt Initial commit 2022-08-07 17:07:34 -07:00
pipeline_document_question_answering.py Small arg handling fixes 2022-08-08 22:04:04 -07:00
pyproject.toml Bug fixes + Copy formatting from transformers repo 2022-08-07 18:42:25 -07:00
pytorch_model.bin Update model weights 2022-08-29 16:23:57 -07:00
qa_helpers.py Bug fixes + Copy formatting from transformers repo 2022-08-07 18:42:25 -07:00
setup.cfg Bug fixes + Copy formatting from transformers repo 2022-08-07 18:42:25 -07:00
special_tokens_map.json Initial commit 2022-08-07 17:07:34 -07:00
tf_model.h5 Update model weights 2022-08-29 16:23:57 -07:00
tokenizer.json Initial commit 2022-08-07 17:07:34 -07:00
tokenizer_config.json Initial commit 2022-08-07 17:07:34 -07:00
vocab.json Initial commit 2022-08-07 17:07:34 -07:00

README.md

language thumbnail license
en https://uploads-ssl.webflow.com/5e3898dff507782a6580d710/614a23fcd8d4f7434c765ab9_logo.png mit

LayoutLM for Visual Question Answering

This is a fine-tuned version of the multi-modal LayoutLM model for the task of question answering on documents. It has been fine-tuned on

Model details

The LayoutLM model was developed at Microsoft (paper) as a general purpose tool for understanding documents. This model is a fine-tuned checkpoint of LayoutLM-Base-Cased, using both the SQuAD2.0 and DocVQA datasets.

Getting started with the model

To run these examples, you must have PIL, pytesseract, and PyTorch installed in addition to transformers.

from transformers import AutoTokenizer, pipeline

tokenizer = AutoTokenizer.from_pretrained(
    "impira/layoutlm-document-qa",
    add_prefix_space=True,
    trust_remote_code=True,
)

nlp = pipeline(
    model="impira/layoutlm-document-qa",
    tokenizer=tokenizer,
    trust_remote_code=True,
)

nlp(
    "https://templates.invoicehome.com/invoice-template-us-neat-750px.png",
    "What is the invoice number?"
)
# {'score': 0.9943977, 'answer': 'us-001', 'start': 15, 'end': 15}

nlp(
    "https://miro.medium.com/max/787/1*iECQRIiOGTmEFLdWkVIH2g.jpeg",
    "What is the purchase amount?"
)
# {'score': 0.9912159, 'answer': '$1,000,000,000', 'start': 97, 'end': 97}

nlp(
    "https://www.accountingcoach.com/wp-content/uploads/2013/10/income-statement-example@2x.png",
    "What are the 2020 net sales?"
)
# {'score': 0.59147286, 'answer': '$ 3,750', 'start': 19, 'end': 20}

NOTE: This model relies on a model definition and pipeline that are currently in review to be included in the transformers project. In the meantime, you'll have to use the trust_remote_code=True flag to run this model.

About us

This model was created by the team at Impira.