Upload TFLayoutLMForQuestionAnswering

This commit is contained in:
Ankur Goyal 2022-08-24 17:18:56 +00:00 committed by huggingface-web
parent 1f7bede5e0
commit 723ec3f9f8
3 changed files with 38 additions and 42 deletions

View File

@ -1,57 +1,48 @@
--- ---
language: en
thumbnail: https://uploads-ssl.webflow.com/5e3898dff507782a6580d710/614a23fcd8d4f7434c765ab9_logo.png
license: mit license: mit
tags:
- generated_from_keras_callback
model-index:
- name: layoutlm-document-qa
results: []
--- ---
# LayoutLM for Visual Question Answering <!-- This model card has been generated automatically according to the information Keras had access to. You should
probably proofread and complete it, then remove this comment. -->
This is a fine-tuned version of the multi-modal [LayoutLM](https://aka.ms/layoutlm) model for the task of question answering on documents. It has been fine-tuned on # layoutlm-document-qa
## Model details This model is a fine-tuned version of [impira/layoutlm-document-qa](https://huggingface.co/impira/layoutlm-document-qa) on an unknown dataset.
It achieves the following results on the evaluation set:
The LayoutLM model was developed at Microsoft ([paper](https://arxiv.org/abs/1912.13318)) as a general purpose tool for understanding documents. This model is a fine-tuned checkpoint of [LayoutLM-Base-Cased](https://huggingface.co/microsoft/layoutlm-base-uncased), using both the [SQuAD2.0](https://huggingface.co/datasets/squad_v2) and [DocVQA](https://www.docvqa.org/) datasets.
## Getting started with the model ## Model description
To run these examples, you must have [PIL](https://pillow.readthedocs.io/en/stable/installation.html), [pytesseract](https://pypi.org/project/pytesseract/), and [PyTorch](https://pytorch.org/get-started/locally/) installed in addition to [transformers](https://huggingface.co/docs/transformers/index). More information needed
```python ## Intended uses & limitations
from transformers import AutoTokenizer, pipeline
tokenizer = AutoTokenizer.from_pretrained( More information needed
"impira/layoutlm-document-qa",
add_prefix_space=True,
trust_remote_code=True,
)
nlp = pipeline( ## Training and evaluation data
model="impira/layoutlm-document-qa",
tokenizer=tokenizer,
trust_remote_code=True,
)
nlp( More information needed
"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( ## Training procedure
"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( ### Training hyperparameters
"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](https://github.com/huggingface/transformers/pull/18407) and [pipeline](https://github.com/huggingface/transformers/pull/18414) 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. The following hyperparameters were used during training:
- optimizer: None
- training_precision: float32
## About us ### Training results
This model was created by the team at [Impira](https://www.impira.com/).
### Framework versions
- Transformers 4.22.0.dev0
- TensorFlow 2.9.2
- Datasets 2.4.0
- Tokenizers 0.12.1

View File

@ -1,15 +1,17 @@
{ {
"attention_probs_dropout_prob": 0.1, "_name_or_path": "impira/layoutlm-document-qa",
"architectures": [ "architectures": [
"LayoutLMForQuestionAnswering" "LayoutLMForQuestionAnswering"
], ],
"attention_probs_dropout_prob": 0.1,
"bos_token_id": 0,
"classifier_dropout": null,
"custom_pipelines": { "custom_pipelines": {
"document-question-answering": { "document-question-answering": {
"impl": "pipeline_document_question_answering.DocumentQuestionAnsweringPipeline", "impl": "pipeline_document_question_answering.DocumentQuestionAnsweringPipeline",
"pt": "AutoModelForQuestionAnswering" "pt": "AutoModelForQuestionAnswering"
} }
}, },
"bos_token_id": 0,
"eos_token_id": 2, "eos_token_id": 2,
"gradient_checkpointing": false, "gradient_checkpointing": false,
"hidden_act": "gelu", "hidden_act": "gelu",
@ -26,7 +28,7 @@
"pad_token_id": 1, "pad_token_id": 1,
"position_embedding_type": "absolute", "position_embedding_type": "absolute",
"tokenizer_class": "RobertaTokenizer", "tokenizer_class": "RobertaTokenizer",
"transformers_version": "4.6.1", "transformers_version": "4.22.0.dev0",
"type_vocab_size": 1, "type_vocab_size": 1,
"use_cache": true, "use_cache": true,
"vocab_size": 50265 "vocab_size": 50265

3
tf_model.h5 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2796bc2f67ac8e1abe55decfa104c7182376c4bf1f8b97ab87fd8bb4768f2f07
size 511465184