Initial commit

This commit is contained in:
Ankur Goyal 2022-09-06 10:50:42 -07:00
parent 0007979582
commit 1a67f8ef3f
11 changed files with 50090 additions and 0 deletions

29
README.md Normal file
View File

@ -0,0 +1,29 @@
---
language: en
license: cc-by-nc-sa-4.0
tags:
- layoutlm
- document-question-answering
- pdf
- invoices
---
# LayoutLM for Invoices
This is a fine-tuned version of the multi-modal [LayoutLM](https://aka.ms/layoutlm) model for the task of question answering on invoices and other documents. It has been fine-tuned on a proprietary dataset of
invoices as well as both [SQuAD2.0](https://huggingface.co/datasets/squad_v2) and [DocVQA](https://www.docvqa.org/) for general comprehension.
## Non-consecutive tokens
Unlike other QA models, which can only extract consecutive tokens (because they predict the start and end of a sequence), this model can predict longer-range, non-consecutive sequences with an additional
classifier head. For example, it can extract the two-line address as below:
![Two-line Address](./demo.png)
## Getting started with the model
The best way to use this model is via [DocQuery](https://github.com/impira/docquery).
## About us
This model was created by the team at [Impira](https://www.impira.com/).

32
config.json Normal file
View File

@ -0,0 +1,32 @@
{
"_name_or_path": "impira/layoutlm-document-qa",
"architectures": [
"LayoutLMForQuestionAnswering"
],
"attention_probs_dropout_prob": 0.1,
"bos_token_id": 0,
"classifier_dropout": null,
"eos_token_id": 2,
"gradient_checkpointing": false,
"hidden_act": "gelu",
"hidden_dropout_prob": 0.1,
"hidden_size": 768,
"initializer_range": 0.02,
"intermediate_size": 3072,
"layer_norm_eps": 1e-05,
"max_2d_position_embeddings": 1024,
"max_position_embeddings": 514,
"model_type": "layoutlm-docquery",
"num_attention_heads": 12,
"num_hidden_layers": 12,
"pad_token_id": 1,
"position_embedding_type": "absolute",
"tokenizer_class": "RobertaTokenizer",
"token_classification": true,
"token_classifier_reduction": "sum",
"token_classifier_constant": 0.1,
"transformers_version": "4.22.0.dev0",
"type_vocab_size": 1,
"use_cache": true,
"vocab_size": 50265
}

BIN
demo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 KiB

50001
merges.txt Normal file

File diff suppressed because it is too large Load Diff

3
pyproject.toml Normal file
View File

@ -0,0 +1,3 @@
[tool.black]
line-length = 119
target-version = ['py35']

3
pytorch_model.bin Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6e540e17254272534b7868382a0fb05ddc693789938fa4bb2fc6aac29dbc0a83
size 511251617

18
setup.cfg Normal file
View File

@ -0,0 +1,18 @@
[isort]
default_section = FIRSTPARTY
ensure_newline_before_comments = True
force_grid_wrap = 0
include_trailing_comma = True
known_first_party = transformers
line_length = 119
lines_after_imports = 2
multi_line_output = 3
use_parentheses = True
[flake8]
ignore = E203, E501, E741, W503, W605
max-line-length = 119
[tool:pytest]
doctest_optionflags=NUMBER NORMALIZE_WHITESPACE ELLIPSIS

1
special_tokens_map.json Normal file
View File

@ -0,0 +1 @@
{"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "</s>", "pad_token": "<pad>", "cls_token": "<s>", "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": false}}

1
tokenizer.json Normal file

File diff suppressed because one or more lines are too long

1
tokenizer_config.json Normal file
View File

@ -0,0 +1 @@
{"unk_token": "<unk>", "bos_token": "<s>", "eos_token": "</s>", "add_prefix_space": false, "errors": "replace", "sep_token": "</s>", "cls_token": "<s>", "pad_token": "<pad>", "mask_token": "<mask>", "model_max_length": 512, "special_tokens_map_file": null, "name_or_path": "roberta-base"}

1
vocab.json Normal file

File diff suppressed because one or more lines are too long