Fill-Mask
Transformers
Safetensors
English
modernlayoutlm
document-understanding
layoutlm
modernbert
custom_code
Instructions to use kkuroma/ModernLayoutLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kkuroma/ModernLayoutLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="kkuroma/ModernLayoutLM", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForMaskedLM model = AutoModelForMaskedLM.from_pretrained("kkuroma/ModernLayoutLM", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +22 -4
- performance.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
performance.png filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -13,6 +13,8 @@ tags:
|
|
| 13 |
|
| 14 |
# ModernLayoutLM
|
| 15 |
|
|
|
|
|
|
|
| 16 |
ModernLayoutLM is an attempt to produce a long-context (like ModernBERT) bidirectional encoder that incorporates layout information into its training (like LayoutLM). ModernLayoutLM uses the same recipe as Xu et al. (2020) in the creation of LayoutLMv1, where the major difference is swapping BERT with ModernBERT (Warner et al., 2024).
|
| 17 |
|
| 18 |
## Intended use
|
|
@@ -73,7 +75,7 @@ ModernLayoutLM is pretrained with the masked visual-language model of LayoutLMv1
|
|
| 73 |
|
| 74 |
### FUNSD
|
| 75 |
|
| 76 |
-
- Source: Jaume et al. (2019), read from `nielsr/funsd
|
| 77 |
- Released: 2019
|
| 78 |
- Size: 199 scanned forms, 149 train and 50 test
|
| 79 |
- Task: entity labeling over header, question and answer, as 7 BIO labels
|
|
@@ -92,6 +94,19 @@ ModernLayoutLM is pretrained with the masked visual-language model of LayoutLMv1
|
|
| 92 |
- Size: 973 receipts, 594 train, 32 validation and 347 test
|
| 93 |
- Task: key information extraction over company, date, address and total, as 9 BIO labels
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
### Results
|
| 96 |
|
| 97 |
Each column is one model fine-tuned on identical data.
|
|
@@ -105,11 +120,11 @@ Each column is one model fine-tuned on identical data.
|
|
| 105 |
| setting | value |
|
| 106 |
|---|---|
|
| 107 |
| metric | entity F1, and field-level Hmean per ICDAR task 3 on SROIE |
|
| 108 |
-
| seeds | mean ± standard deviation over three seeds |
|
| 109 |
| split | FUNSD on test as it has no validation split, the rest on validation |
|
| 110 |
| learning rate | 3e-4, chosen on FUNSD test, and 5e-5 for LayoutLMv1 as in its paper |
|
| 111 |
-
| epochs | 30 |
|
| 112 |
-
| window | 1024 tokens, 512 for LayoutLMv1 as its positions cap there |
|
| 113 |
| long documents | chunks are stitched back into one document before scoring |
|
| 114 |
|
| 115 |
| dataset | ModernLayoutLM | LayoutLMv1 | ModernLayoutLM (no-pretrain) | ModernLayoutLM (no-bbox) | ModernBERT |
|
|
@@ -117,6 +132,9 @@ Each column is one model fine-tuned on identical data.
|
|
| 117 |
| FUNSD | 0.7565 ± 0.0037 | 0.7785 ± 0.0104 | 0.5939 ± 0.0205 | 0.3000 ± 0.0247 | 0.5884 ± 0.0082 |
|
| 118 |
| CORD | 0.9546 ± 0.0023 | 0.9685 ± 0.0037 | 0.9462 ± 0.0050 | 0.9312 ± 0.0042 | 0.9424 ± 0.0006 |
|
| 119 |
| SROIE | 0.9337 ± 0.0060 | 0.9223 ± 0.0199 | 0.8883 ± 0.0121 | 0.8411 ± 0.0189 | 0.8955 ± 0.0072 |
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
ModernLayoutLM performs comparably to LayoutLMv1, but natively supports long context.
|
| 122 |
|
|
|
|
| 13 |
|
| 14 |
# ModernLayoutLM
|
| 15 |
|
| 16 |
+

|
| 17 |
+
|
| 18 |
ModernLayoutLM is an attempt to produce a long-context (like ModernBERT) bidirectional encoder that incorporates layout information into its training (like LayoutLM). ModernLayoutLM uses the same recipe as Xu et al. (2020) in the creation of LayoutLMv1, where the major difference is swapping BERT with ModernBERT (Warner et al., 2024).
|
| 19 |
|
| 20 |
## Intended use
|
|
|
|
| 75 |
|
| 76 |
### FUNSD
|
| 77 |
|
| 78 |
+
- Source: Jaume et al. (2019), read from `nielsr/funsd`
|
| 79 |
- Released: 2019
|
| 80 |
- Size: 199 scanned forms, 149 train and 50 test
|
| 81 |
- Task: entity labeling over header, question and answer, as 7 BIO labels
|
|
|
|
| 94 |
- Size: 973 receipts, 594 train, 32 validation and 347 test
|
| 95 |
- Task: key information extraction over company, date, address and total, as 9 BIO labels
|
| 96 |
|
| 97 |
+
### RealKIE
|
| 98 |
+
|
| 99 |
+
- Source: Townsend et al. (2024), the FCC Invoices, NDA and Charities sets, read from the Zenodo release with its own OCR
|
| 100 |
+
- Released: 2024
|
| 101 |
+
- Size: long multi-page documents, 38% to 55% of them past 4096 tokens
|
| 102 |
+
- Task: key information extraction labeled as character spans over the OCR text
|
| 103 |
+
|
| 104 |
+
| set | train, validation and test documents | fields | BIO labels | median tokens |
|
| 105 |
+
|---|---|---|---|---|
|
| 106 |
+
| FCC Invoices | 221, 75 and 74 | 11 | 23 | 2,948 |
|
| 107 |
+
| NDA | 248, 93 and 98 | 3 | 7 | 3,522 |
|
| 108 |
+
| Charities | 322, 108 and 108 | 28 | 57 | 4,525 |
|
| 109 |
+
|
| 110 |
### Results
|
| 111 |
|
| 112 |
Each column is one model fine-tuned on identical data.
|
|
|
|
| 120 |
| setting | value |
|
| 121 |
|---|---|
|
| 122 |
| metric | entity F1, and field-level Hmean per ICDAR task 3 on SROIE |
|
| 123 |
+
| seeds | mean ± standard deviation over three seeds, one seed on RealKIE |
|
| 124 |
| split | FUNSD on test as it has no validation split, the rest on validation |
|
| 125 |
| learning rate | 3e-4, chosen on FUNSD test, and 5e-5 for LayoutLMv1 as in its paper |
|
| 126 |
+
| epochs | 30, 10 on RealKIE |
|
| 127 |
+
| window | 1024 tokens, 4096 on RealKIE, 512 for LayoutLMv1 as its positions cap there |
|
| 128 |
| long documents | chunks are stitched back into one document before scoring |
|
| 129 |
|
| 130 |
| dataset | ModernLayoutLM | LayoutLMv1 | ModernLayoutLM (no-pretrain) | ModernLayoutLM (no-bbox) | ModernBERT |
|
|
|
|
| 132 |
| FUNSD | 0.7565 ± 0.0037 | 0.7785 ± 0.0104 | 0.5939 ± 0.0205 | 0.3000 ± 0.0247 | 0.5884 ± 0.0082 |
|
| 133 |
| CORD | 0.9546 ± 0.0023 | 0.9685 ± 0.0037 | 0.9462 ± 0.0050 | 0.9312 ± 0.0042 | 0.9424 ± 0.0006 |
|
| 134 |
| SROIE | 0.9337 ± 0.0060 | 0.9223 ± 0.0199 | 0.8883 ± 0.0121 | 0.8411 ± 0.0189 | 0.8955 ± 0.0072 |
|
| 135 |
+
| RealKIE FCC | 0.8761 | 0.8613 | 0.8569 | 0.7178 | 0.8607 |
|
| 136 |
+
| RealKIE NDA | 0.8586 | 0.8539 | 0.8503 | 0.5735 | 0.8571 |
|
| 137 |
+
| RealKIE Charities | 0.8043 | 0.8071 | 0.7679 | 0.3740 | 0.7725 |
|
| 138 |
|
| 139 |
ModernLayoutLM performs comparably to LayoutLMv1, but natively supports long context.
|
| 140 |
|
performance.png
ADDED
|
Git LFS Details
|