kronos070 commited on
Commit
192f399
·
verified ·
1 Parent(s): f95ddf5

Upload InvoiceGuard LayoutLMv3 (Test F1: 0.7244)

Browse files
README.md CHANGED
@@ -1,3 +1,41 @@
1
  ---
2
- license: mit
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ license: cc-by-4.0
5
+ tags:
6
+ - layoutlmv3
7
+ - token-classification
8
+ - invoice-extraction
9
+ - document-ai
10
+ - invoiceguard
11
+ datasets:
12
+ - Kwash67/layoutlmv3-invoice-dataset
13
+ metrics:
14
+ - seqeval
15
  ---
16
+
17
+ # 🛡️ InvoiceGuard LayoutLMv3 Invoice Extractor
18
+
19
+ Fine-tuned `microsoft/layoutlmv3-base` model for multimodal token classification and Key Information Extraction (KIE) on commercial invoices.
20
+
21
+ ## Model Details
22
+ - **Base Architecture**: `microsoft/layoutlmv3-base`
23
+ - **Task**: Multimodal Document Token Classification
24
+ - **Dataset**: `Kwash67/layoutlmv3-invoice-dataset` (~2,043 train / 70 val / 125 test)
25
+ - **Training Epochs**: 12 (lr=3e-5, warmup=10%, batch=4, grad_acc=2)
26
+ - **Mixed Precision**: fp16
27
+
28
+ ## Test Set Metrics (Seqeval Entity-Level)
29
+ | Metric | Score |
30
+ | :--- | :--- |
31
+ | **Overall F1** | 0.7244 |
32
+ | **Overall Precision** | 0.7167 |
33
+ | **Overall Recall** | 0.7324 |
34
+
35
+ ## InvoiceGuard Schema Mapping
36
+ Maps dataset entities to 21 canonical InvoiceGuard fields:
37
+ `invoice_number`, `invoice_date`, `due_date`, `seller`, `client`, `seller_tax_id`, `client_tax_id`, `iban`, `item_desc`, `item_qty`, `item_net_price`, `item_net_worth`, `item_vat`, `item_gross_worth`, `subtotal`, `total_vat`, `total_gross_worth`, `currency`, `discount`, `shipping`, `payment_terms`.
38
+
39
+ ## Limitations
40
+ - Optimized for invoices with bounding boxes normalized to `[0..1000]`.
41
+ - Highly dependent on OCR word-level segmentation accuracy.
config.json ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LayoutLMv3ForTokenClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "classifier_dropout": null,
8
+ "coordinate_size": 128,
9
+ "dtype": "float32",
10
+ "eos_token_id": 2,
11
+ "has_relative_attention_bias": true,
12
+ "has_spatial_attention_bias": true,
13
+ "hidden_act": "gelu",
14
+ "hidden_dropout_prob": 0.1,
15
+ "hidden_size": 768,
16
+ "id2label": {
17
+ "0": "O",
18
+ "1": "B-INVOICE_NO",
19
+ "2": "I-INVOICE_NO",
20
+ "3": "B-INVOICE_DATE",
21
+ "4": "I-INVOICE_DATE",
22
+ "5": "B-SELLER",
23
+ "6": "I-SELLER",
24
+ "7": "B-CLIENT",
25
+ "8": "I-CLIENT",
26
+ "9": "B-SELLER_TAX_ID",
27
+ "10": "I-SELLER_TAX_ID",
28
+ "11": "B-CLIENT_TAX_ID",
29
+ "12": "I-CLIENT_TAX_ID",
30
+ "13": "B-IBAN",
31
+ "14": "I-IBAN",
32
+ "15": "B-ITEM_DESC",
33
+ "16": "I-ITEM_DESC",
34
+ "17": "B-ITEM_QTY",
35
+ "18": "I-ITEM_QTY",
36
+ "19": "B-ITEM_NET_PRICE",
37
+ "20": "I-ITEM_NET_PRICE",
38
+ "21": "B-ITEM_NET_WORTH",
39
+ "22": "I-ITEM_NET_WORTH",
40
+ "23": "B-ITEM_VAT",
41
+ "24": "I-ITEM_VAT",
42
+ "25": "B-ITEM_GROSS_WORTH",
43
+ "26": "I-ITEM_GROSS_WORTH",
44
+ "27": "B-TOTAL_NET_WORTH",
45
+ "28": "I-TOTAL_NET_WORTH",
46
+ "29": "B-TOTAL_VAT",
47
+ "30": "I-TOTAL_VAT",
48
+ "31": "B-TOTAL_GROSS_WORTH",
49
+ "32": "I-TOTAL_GROSS_WORTH",
50
+ "33": "B-DUE_DATE",
51
+ "34": "I-DUE_DATE",
52
+ "35": "B-PAYMENT_TERMS",
53
+ "36": "I-PAYMENT_TERMS",
54
+ "37": "B-CURRENCY",
55
+ "38": "I-CURRENCY",
56
+ "39": "B-SUBTOTAL",
57
+ "40": "I-SUBTOTAL",
58
+ "41": "B-DISCOUNT",
59
+ "42": "I-DISCOUNT",
60
+ "43": "B-SHIPPING",
61
+ "44": "I-SHIPPING"
62
+ },
63
+ "initializer_range": 0.02,
64
+ "input_size": 224,
65
+ "intermediate_size": 3072,
66
+ "label2id": {
67
+ "B-CLIENT": 7,
68
+ "B-CLIENT_TAX_ID": 11,
69
+ "B-CURRENCY": 37,
70
+ "B-DISCOUNT": 41,
71
+ "B-DUE_DATE": 33,
72
+ "B-IBAN": 13,
73
+ "B-INVOICE_DATE": 3,
74
+ "B-INVOICE_NO": 1,
75
+ "B-ITEM_DESC": 15,
76
+ "B-ITEM_GROSS_WORTH": 25,
77
+ "B-ITEM_NET_PRICE": 19,
78
+ "B-ITEM_NET_WORTH": 21,
79
+ "B-ITEM_QTY": 17,
80
+ "B-ITEM_VAT": 23,
81
+ "B-PAYMENT_TERMS": 35,
82
+ "B-SELLER": 5,
83
+ "B-SELLER_TAX_ID": 9,
84
+ "B-SHIPPING": 43,
85
+ "B-SUBTOTAL": 39,
86
+ "B-TOTAL_GROSS_WORTH": 31,
87
+ "B-TOTAL_NET_WORTH": 27,
88
+ "B-TOTAL_VAT": 29,
89
+ "I-CLIENT": 8,
90
+ "I-CLIENT_TAX_ID": 12,
91
+ "I-CURRENCY": 38,
92
+ "I-DISCOUNT": 42,
93
+ "I-DUE_DATE": 34,
94
+ "I-IBAN": 14,
95
+ "I-INVOICE_DATE": 4,
96
+ "I-INVOICE_NO": 2,
97
+ "I-ITEM_DESC": 16,
98
+ "I-ITEM_GROSS_WORTH": 26,
99
+ "I-ITEM_NET_PRICE": 20,
100
+ "I-ITEM_NET_WORTH": 22,
101
+ "I-ITEM_QTY": 18,
102
+ "I-ITEM_VAT": 24,
103
+ "I-PAYMENT_TERMS": 36,
104
+ "I-SELLER": 6,
105
+ "I-SELLER_TAX_ID": 10,
106
+ "I-SHIPPING": 44,
107
+ "I-SUBTOTAL": 40,
108
+ "I-TOTAL_GROSS_WORTH": 32,
109
+ "I-TOTAL_NET_WORTH": 28,
110
+ "I-TOTAL_VAT": 30,
111
+ "O": 0
112
+ },
113
+ "layer_norm_eps": 1e-05,
114
+ "max_2d_position_embeddings": 1024,
115
+ "max_position_embeddings": 514,
116
+ "max_rel_2d_pos": 256,
117
+ "max_rel_pos": 128,
118
+ "model_type": "layoutlmv3",
119
+ "num_attention_heads": 12,
120
+ "num_channels": 3,
121
+ "num_hidden_layers": 12,
122
+ "pad_token_id": 1,
123
+ "patch_size": 16,
124
+ "rel_2d_pos_bins": 64,
125
+ "rel_pos_bins": 32,
126
+ "second_input_size": 112,
127
+ "shape_size": 128,
128
+ "text_embed": true,
129
+ "transformers_version": "5.17.0",
130
+ "type_vocab_size": 1,
131
+ "use_cache": false,
132
+ "visual_embed": true,
133
+ "vocab_size": 50265
134
+ }
label_map.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_description": "Mapping from LayoutLMv3 invoice dataset entity labels to InvoiceGuard canonical schema",
3
+ "dataset_to_invoiceguard": {
4
+ "INVOICE_NO": "invoice_number",
5
+ "INVOICE_DATE": "invoice_date",
6
+ "DUE_DATE": "due_date",
7
+ "SELLER": "seller",
8
+ "CLIENT": "client",
9
+ "SELLER_TAX_ID": "seller_tax_id",
10
+ "CLIENT_TAX_ID": "client_tax_id",
11
+ "IBAN": "iban",
12
+ "ITEM_DESC": "item_desc",
13
+ "ITEM_QTY": "item_qty",
14
+ "ITEM_NET_PRICE": "item_net_price",
15
+ "ITEM_NET_WORTH": "item_net_worth",
16
+ "ITEM_VAT": "item_vat",
17
+ "ITEM_GROSS_WORTH": "item_gross_worth",
18
+ "SUBTOTAL": "subtotal",
19
+ "TOTAL_NET_WORTH": "subtotal",
20
+ "TOTAL_VAT": "total_vat",
21
+ "TOTAL_GROSS_WORTH": "total_gross_worth",
22
+ "CURRENCY": "currency",
23
+ "DISCOUNT": "discount",
24
+ "SHIPPING": "shipping",
25
+ "PAYMENT_TERMS": "payment_terms",
26
+ "O": null
27
+ },
28
+ "invoiceguard_schema_fields": [
29
+ "invoice_number",
30
+ "invoice_date",
31
+ "due_date",
32
+ "seller",
33
+ "client",
34
+ "seller_tax_id",
35
+ "client_tax_id",
36
+ "iban",
37
+ "item_desc",
38
+ "item_qty",
39
+ "item_net_price",
40
+ "item_net_worth",
41
+ "item_vat",
42
+ "item_gross_worth",
43
+ "subtotal",
44
+ "total_vat",
45
+ "total_gross_worth",
46
+ "currency",
47
+ "discount",
48
+ "shipping",
49
+ "payment_terms"
50
+ ],
51
+ "unmapped_schema_fields": []
52
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c9d65245ef7ea478997fae5969d1b3b371a954e44a04815ed0d43d3390a1c15e
3
+ size 503835020
processor_config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "apply_ocr": false,
4
+ "do_normalize": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "image_mean": [
8
+ 0.5,
9
+ 0.5,
10
+ 0.5
11
+ ],
12
+ "image_processor_type": "LayoutLMv3ImageProcessor",
13
+ "image_std": [
14
+ 0.5,
15
+ 0.5,
16
+ 0.5
17
+ ],
18
+ "resample": 2,
19
+ "rescale_factor": 0.00392156862745098,
20
+ "size": {
21
+ "height": 224,
22
+ "width": 224
23
+ },
24
+ "tesseract_config": ""
25
+ },
26
+ "processor_class": "LayoutLMv3Processor"
27
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": true,
3
+ "apply_ocr": false,
4
+ "backend": "tokenizers",
5
+ "bos_token": "<s>",
6
+ "cls_token": "<s>",
7
+ "cls_token_box": [
8
+ 0,
9
+ 0,
10
+ 0,
11
+ 0
12
+ ],
13
+ "eos_token": "</s>",
14
+ "errors": "replace",
15
+ "is_local": false,
16
+ "local_files_only": false,
17
+ "mask_token": "<mask>",
18
+ "model_max_length": 512,
19
+ "only_label_first_subword": true,
20
+ "pad_token": "<pad>",
21
+ "pad_token_box": [
22
+ 0,
23
+ 0,
24
+ 0,
25
+ 0
26
+ ],
27
+ "pad_token_label": -100,
28
+ "processor_class": "LayoutLMv3Processor",
29
+ "sep_token": "</s>",
30
+ "sep_token_box": [
31
+ 0,
32
+ 0,
33
+ 0,
34
+ 0
35
+ ],
36
+ "tokenizer_class": "LayoutLMv3Tokenizer",
37
+ "unk_token": "<unk>"
38
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8cb4248308aa78d1f657181b6da3e7f3f0727146207d7e37c922ce200071966e
3
+ size 5201