|
|
--- |
|
|
task_categories: |
|
|
- token-classification |
|
|
- image-to-text |
|
|
- object-detection |
|
|
tags: |
|
|
- invoices |
|
|
- finance |
|
|
- document-understanding |
|
|
- layoutlm |
|
|
- ner |
|
|
features: |
|
|
id: |
|
|
dtype: int32 |
|
|
words: |
|
|
dtype: string |
|
|
sequence: string |
|
|
boxes: |
|
|
dtype: int64 |
|
|
sequence: |
|
|
sequence: int64 |
|
|
ner_tags: |
|
|
class_label: |
|
|
names: |
|
|
0: O |
|
|
1: B-BALANCE_DUE |
|
|
2: B-BANK_NAME |
|
|
3: B-CLIENT_ADDRESS |
|
|
4: B-CLIENT_EMAIL |
|
|
5: B-CLIENT_NAME |
|
|
6: B-CLIENT_PHONE |
|
|
7: B-CLIENT_TAX_ID |
|
|
8: B-CURRENCY |
|
|
9: B-DUE_DATE |
|
|
10: B-IBAN |
|
|
11: B-INVOICE_DATE |
|
|
12: B-INVOICE_NUMBER |
|
|
13: B-ITEM_DESC |
|
|
14: B-ITEM_NO |
|
|
15: B-LINE_DISCOUNT |
|
|
16: B-LINE_GROSS_WORTH |
|
|
17: B-LINE_NET_WORTH |
|
|
18: B-LINE_UNIT_PRICE |
|
|
19: B-LINE_VAT |
|
|
20: B-ORDER_NUMBER |
|
|
21: B-QTY |
|
|
22: B-REFERENCE_NUMBER |
|
|
23: B-SELLER_ADDRESS |
|
|
24: B-SELLER_EMAIL |
|
|
25: B-SELLER_NAME |
|
|
26: B-SELLER_PHONE |
|
|
27: B-SELLER_TAX_ID |
|
|
28: B-SUBTOTAL |
|
|
29: B-TOTAL_GROSS_WORTH |
|
|
30: B-TOTAL_NET_WORTH |
|
|
31: B-TOTAL_VAT |
|
|
32: I-BANK_NAME |
|
|
33: I-CLIENT_ADDRESS |
|
|
34: I-CLIENT_EMAIL |
|
|
35: I-CLIENT_NAME |
|
|
36: I-CLIENT_PHONE |
|
|
37: I-INVOICE_NUMBER |
|
|
38: I-ITEM_DESC |
|
|
39: I-LINE_NET_WORTH |
|
|
40: I-LINE_UNIT_PRICE |
|
|
41: I-SELLER_ADDRESS |
|
|
42: I-SELLER_EMAIL |
|
|
43: I-SELLER_NAME |
|
|
44: I-SELLER_PHONE |
|
|
45: I-SELLER_TAX_ID |
|
|
46: I-TOTAL_NET_WORTH |
|
|
image: |
|
|
dtype: image |
|
|
--- |
|
|
|
|
|
# Merged Invoice NER Dataset |
|
|
|
|
|
## Dataset Description |
|
|
|
|
|
This dataset consists of processed invoice documents intended for **Document Layout Analysis** and **Named Entity Recognition (NER)** tasks (e.g., training LayoutLM, LayoutLMv2, LayoutLMv3, or LiLT). |
|
|
|
|
|
The data was created by merging multiple invoice datasets. It includes the document images, OCR-extracted words, bounding boxes, and NER tags. |
|
|
|
|
|
### Supported Tasks |
|
|
- **Token Classification:** Extracting entities like `INVOICE_NUMBER`, `TOTAL_GROSS_WORTH`, `SELLER_NAME`, etc. |
|
|
- **Key Information Extraction (KIE)** |
|
|
|
|
|
## Data Structure |
|
|
|
|
|
Each example in the dataset contains the following fields: |
|
|
|
|
|
- **`id`**: A unique identifier for the document. |
|
|
- **`image`**: The PIL Image of the invoice. |
|
|
- **`words`**: List of strings (tokens) obtained via OCR. |
|
|
- **`boxes`**: List of bounding boxes corresponding to the words. |
|
|
- **Format:** `[x_min, y_min, x_max, y_max]` |
|
|
- **Note:** These boxes are likely in **absolute pixel coordinates** (based on the image size) and **NOT normalized** to 0-1000. You must normalize them before inputting them into models like LayoutLM. |
|
|
- **`ner_tags`**: List of class IDs (integers) in BIO (Beginning, Inside, Outside) format. |
|
|
|
|
|
## Important Usage Warnings |
|
|
|
|
|
### 1. Bounding Box Normalization Required |
|
|
The `boxes` in this dataset are likely stored in absolute pixel values (e.g., `0-2500`). Models like LayoutLM expect boxes normalized to a `0-1000` scale. |
|
|
|
|
|
**How to handle this:** |
|
|
When loading the dataset, you should normalize the boxes relative to the image size: |
|
|
|
|
|
```python |
|
|
def normalize_box(box, width, height): |
|
|
return [ |
|
|
int(1000 * (box[0] / width)), |
|
|
int(1000 * (box[1] / height)), |
|
|
int(1000 * (box[2] / width)), |
|
|
int(1000 * (box[3] / height)), |
|
|
] |
|
|
|
|
|
def preprocess(example): |
|
|
w, h = example['image'].size |
|
|
# Normalize boxes to 0-1000 |
|
|
example['boxes'] = [normalize_box(box, w, h) for box in example['boxes']] |
|
|
return example |
|
|
|
|
|
dataset = load_dataset("your-username/dataset-name") |
|
|
dataset = dataset.map(preprocess) |
|
|
|
|
|
2. Mixed OCR Sources |
|
|
This dataset was created by merging sources that may have used different OCR engines (e.g., Tesseract, EasyOCR, or commercial APIs). |
|
|
Some documents may have slightly different bounding box tightness or word-splitting logic. |
|
|
Ensure your training pipeline is robust to slight variations in OCR quality. |
|
|
3. Missing I-Tags for some entities |
|
|
The label map includes B- (Beginning) tags for all entities, but some entities (like BALANCE_DUE, TOTAL_VAT, IBAN) do not have a corresponding I- (Inside) tag in the schema. |
|
|
If a value spans multiple words (e.g., "Total VAT"), the model may only be able to label the first word, or you may need to map the subsequent words to O or a generic tag during training. |
|
|
4. Privacy / PII |
|
|
This dataset contains invoice data. While processed, users should handle the data with care regarding Personally Identifiable Information (PII) such as names, addresses, and financial details. |
|
|
|