Update README.md
Browse files
README.md
CHANGED
|
@@ -1,142 +1,104 @@
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
# Model Card for
|
| 7 |
-
|
| 8 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
| 9 |
-
|
| 10 |
-
|
| 11 |
|
| 12 |
## Model Details
|
| 13 |
|
| 14 |
### Model Description
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
| 19 |
|
| 20 |
-
- **Developed by:**
|
| 21 |
-
- **
|
| 22 |
-
- **
|
| 23 |
-
- **
|
| 24 |
-
- **
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
### Model Sources
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
- **Repository:** [More Information Needed]
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
|
| 36 |
## Uses
|
| 37 |
|
| 38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 39 |
-
|
| 40 |
### Direct Use
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
[More Information Needed]
|
| 45 |
|
| 46 |
-
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
|
|
|
| 51 |
|
| 52 |
### Out-of-Scope Use
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
[More Information Needed]
|
| 57 |
|
| 58 |
## Bias, Risks, and Limitations
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
|
| 64 |
### Recommendations
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
|
| 70 |
## How to Get Started with the Model
|
| 71 |
|
| 72 |
-
|
|
|
|
|
|
|
| 73 |
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
## Training Details
|
| 77 |
|
| 78 |
### Training Data
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
|
| 84 |
### Training Procedure
|
| 85 |
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
|
| 103 |
## Evaluation
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
|
| 141 |
## Environmental Impact
|
| 142 |
|
|
@@ -144,56 +106,38 @@ Use the code below to get started with the model.
|
|
| 144 |
|
| 145 |
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
|
| 147 |
-
- **Hardware Type:**
|
| 148 |
-
- **Hours used:**
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
|
| 153 |
-
## Technical Specifications
|
| 154 |
|
| 155 |
### Model Architecture and Objective
|
| 156 |
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
### Compute Infrastructure
|
| 160 |
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
|
| 173 |
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
|
| 175 |
**BibTeX:**
|
| 176 |
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
**APA:**
|
| 180 |
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
-
[More Information Needed]
|
|
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
+
datasets:
|
| 4 |
+
- ds4sd/DocLayNet-v1.2
|
| 5 |
+
base_model:
|
| 6 |
+
- microsoft/layoutlmv3-base
|
| 7 |
---
|
| 8 |
|
| 9 |
+
# Model Card for kbsooo/layoutlmv3_finetuned_doclaynet
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
## Model Details
|
| 12 |
|
| 13 |
### Model Description
|
| 14 |
|
| 15 |
+
This model is a fine-tuned version of [LayoutLMv3](https://huggingface.co/microsoft/layoutlmv3-base) for token classification on the DocLayNet dataset.
|
| 16 |
+
It is designed to classify each token in a document image based on both textual and layout information.
|
|
|
|
| 17 |
|
| 18 |
+
- **Developed by:** kbsooo
|
| 19 |
+
- **Model type:** LayoutLMv3ForTokenClassification
|
| 20 |
+
- **Language(s) (NLP):** Korean (document-oriented)
|
| 21 |
+
- **License:** Check DocLayNet and LayoutLMv3 licenses
|
| 22 |
+
- **Finetuned from model:** microsoft/layoutlmv3-base
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
### Model Sources
|
| 25 |
|
| 26 |
+
- **Repository:** [Hugging Face Model Hub](https://huggingface.co/kbsooo/layoutlmv3_finetuned_doclaynet)
|
| 27 |
+
- **Paper (optional):** [LayoutLMv3 Paper](https://arxiv.org/abs/2112.01041)
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
## Uses
|
| 30 |
|
|
|
|
|
|
|
| 31 |
### Direct Use
|
| 32 |
|
| 33 |
+
This model can be used for:
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
- Token classification in document images (e.g., identifying headings, paragraphs, tables, images, lists)
|
| 36 |
+
- Document understanding tasks where layout + text information is important
|
| 37 |
|
| 38 |
+
### Downstream Use
|
| 39 |
|
| 40 |
+
- Can be integrated into pipelines for document information extraction
|
| 41 |
+
- Useful for document analysis applications: invoice parsing, form processing, etc.
|
| 42 |
|
| 43 |
### Out-of-Scope Use
|
| 44 |
|
| 45 |
+
- Not intended for languages or layouts not represented in the DocLayNet dataset
|
| 46 |
+
- Not suitable for free-form text without document structure
|
|
|
|
| 47 |
|
| 48 |
## Bias, Risks, and Limitations
|
| 49 |
|
| 50 |
+
- The model may misclassify tokens if the document layout or language differs from the training data
|
| 51 |
+
- Biases may exist due to dataset composition (DocLayNet)
|
| 52 |
+
- Limited to 10 classes of document layout elements
|
| 53 |
|
| 54 |
### Recommendations
|
| 55 |
|
| 56 |
+
- Users should preprocess documents similarly to the training setup (tokenization + bounding boxes + image)
|
| 57 |
+
- Verify predictions, especially in production or high-stakes scenarios
|
|
|
|
| 58 |
|
| 59 |
## How to Get Started with the Model
|
| 60 |
|
| 61 |
+
```python
|
| 62 |
+
from transformers import LayoutLMv3ForTokenClassification, AutoProcessor
|
| 63 |
+
import torch
|
| 64 |
|
| 65 |
+
repo = "kbsooo/layoutlmv3_finetuned_doclaynet"
|
| 66 |
+
model = LayoutLMv3ForTokenClassification.from_pretrained(repo)
|
| 67 |
+
processor = AutoProcessor.from_pretrained(repo)
|
| 68 |
+
|
| 69 |
+
image = ... # PIL.Image or np.array
|
| 70 |
+
text = "Sample document text"
|
| 71 |
+
|
| 72 |
+
encoding = processor(image, text, return_tensors="pt")
|
| 73 |
+
outputs = model(**encoding)
|
| 74 |
+
preds = torch.argmax(outputs.logits, dim=-1)
|
| 75 |
+
print(preds)
|
| 76 |
+
```
|
| 77 |
|
| 78 |
## Training Details
|
| 79 |
|
| 80 |
### Training Data
|
| 81 |
|
| 82 |
+
- Dataset: DocLayNet-v1.2
|
| 83 |
+
- Train/Validation split: 200/100 samples
|
| 84 |
+
- Columns: input_ids, attention_mask, bbox, labels, pixel_values, n_words_in, n_words_out
|
| 85 |
|
| 86 |
### Training Procedure
|
| 87 |
|
| 88 |
+
- Optimizer: AdamW
|
| 89 |
+
- Learning rate: 5e-5
|
| 90 |
+
- Epochs: 5
|
| 91 |
+
- Mixed precision: FP16 optional
|
| 92 |
+
- Loss: Cross-entropy per token
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
## Evaluation
|
| 96 |
|
| 97 |
+
- Sample metrics (from validation set):
|
| 98 |
+
- Avg Train Loss: 0.134
|
| 99 |
+
- Avg Val Loss: 0.458
|
| 100 |
+
- Token prediction accuracy should be checked against the DocLayNet labels
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
## Environmental Impact
|
| 104 |
|
|
|
|
| 106 |
|
| 107 |
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 108 |
|
| 109 |
+
- **Hardware Type:** NVIDIA A100
|
| 110 |
+
- **Hours used:** ~1 hr for 5 epochs (for small dataset)
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
+
## Technical Specifications
|
| 113 |
|
| 114 |
### Model Architecture and Objective
|
| 115 |
|
| 116 |
+
- Base model: LayoutLMv3
|
| 117 |
+
- Task: Token classification for document layout elements
|
| 118 |
+
- Input: Tokenized text, bounding boxes, and document images
|
| 119 |
+
- Output: Token-wise logits for 10 classes
|
| 120 |
|
| 121 |
### Compute Infrastructure
|
| 122 |
|
| 123 |
+
- Training performed on Google Colab Pro (A100 GPU)
|
| 124 |
+
- Framework: PyTorch + Hugging Face Transformers
|
|
|
|
| 125 |
|
| 126 |
+
## Citation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 129 |
|
| 130 |
**BibTeX:**
|
| 131 |
|
| 132 |
+
```bibtex
|
| 133 |
+
@article{huang2022layoutlmv3,
|
| 134 |
+
title={LayoutLMv3: Pre-training for Document AI with Unified Text and Image Masking},
|
| 135 |
+
author={Huang, Zejiang and et al.},
|
| 136 |
+
journal={arXiv preprint arXiv:2112.01041},
|
| 137 |
+
year={2022}
|
| 138 |
+
}
|
| 139 |
+
```
|
| 140 |
|
| 141 |
**APA:**
|
| 142 |
|
| 143 |
+
Huang, Z., et al. (2022). LayoutLMv3: Pre-training for Document AI with Unified Text and Image Masking. arXiv preprint arXiv:2112.01041.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|