# LayoutLM Training Data

Canonical source: [LayoutLM Training Data](https://docsetgenerator.com/layoutlm-training-data)

Guide · LayoutLM export

## Export document pages for LayoutLM consumers

The V2 LayoutLM export is page-oriented. Each JSONL record binds one page to its document, image, split, tokens, boxes, and labels, so a consumer can train on the same page rendition represented by the annotations.

**Command-line setup**

Guide commands use the tools included with your Windows or Linux download; no separate Python installation is needed. Each guide's command examples show the complete command for the platform you choose. [Open platform setup](https://docsetgenerator.com/getting-started#command-line).

Export schema 2.0

### One JSONL record represents one page

The V2 LayoutLM export is `exports/layoutlm.jsonl`. It writes one record per page, not one record per document. Each record includes `document_id`, `page_number`, `image_path`, `image_rendition`, `split`, `tokens`, `bboxes`, and `labels`. The export schema version is `2.0`.

Boxes are normalized to the 0–1000 LayoutLM convention. Labels are `O` for unlabelled words and `B-…` values for semantic labels supplied by the annotation. The tokens, boxes, and labels arrays have matching lengths.

Short example

### Generate a page-level export

Windows PowerShell

```powershell
& '.\_internal\DocumentGenerator_v2.0_cli.exe' generate --type invoice letter --count 2 --seed 42 --output output/layoutlm-small --export layoutlm --validate
```

Linux AppImage

```sh
./DocumentGenerator_v2.0.0_Linux-x86_64.AppImage --cli generate --type invoice letter --count 2 --seed 42 --output output/layoutlm-small --export layoutlm --validate
```

Linux Flatpak

```sh
flatpak run com.docsetgenerator.DocSetGenerator --cli generate --type invoice letter --count 2 --seed 42 --output output/layoutlm-small --export layoutlm --validate
```

A line in the resulting JSONL has this shape:

```
{
  "export_schema_version": "2.0",
  "id": "<document-id>-p001",
  "document_id": "<document-id>",
  "page_number": 1,
  "image_path": "images/<document-id>/page-001.png",
  "image_rendition": "source",
  "split": "train",
  "tokens": ["Invoice", "INV-123"],
  "bboxes": [[80, 70, 180, 110], [210, 70, 360, 110]],
  "labels": ["O", "B-INVOICE_NUMBER"]
}
```

The values in this snippet illustrate the record shape; use the generated file as the source of truth for IDs, paths, tokens, and coordinates.

Rendition choice

### Train on the page your consumer will see

When a run has a delivered rendition—such as a scan transform—COCO and LayoutLM use delivered pages and their matching word geometry. The record's `image_rendition` says whether the image is delivered or source. The canonical `pages` record remains the pristine semantic reference; do not pair a delivered image with source boxes by accident.

`--export-rendition` selects the Label Studio rendition. It does not change LayoutLM's delivered-page behavior. Label Studio uses delivered PDF pages by default and automatically selects pristine previews for native formats, recording each task's actual rendition. Request `--export-rendition pristine` to review pristine pages for every document.

Consumer migration

### Update loaders that assumed document records

#### Old assumption

A single JSON object represented one entire document, with a document-level image or a concatenated token sequence.

#### V2 behavior

A page record carries the document ID and page number. Group by `document_id` only when your model or report needs document context.

Order pages by `page_number` and preserve the export’s `split` assignment. Related source documents, delivery variants and packet pages belong together; reshuffling their pages can mix related content across training and test sets.

Limits

### A valid LayoutLM file does not validate model quality

- `--validate` checks the manifest, annotations, and export consistency. It does not train a model or report token-classification accuracy.
- Delivered geometry describes the selected generated condition. Scan damage, visible corruption, and hidden text have different semantics; use the [delivery guide](https://docsetgenerator.com/degraded-document-dataset) before mixing them in a corpus.
- Generated labels come from the document model and available semantic annotations. They are not a universal entity taxonomy or a guarantee that every visual region has a meaningful class.
- The evaluator's supported parser inputs are narrower than the generator's 33-type catalog. Use [evaluation](https://docsetgenerator.com/evaluation) for the supported scoring boundary.

### Related formats

Compare the pixel-space [COCO export](https://docsetgenerator.com/coco-annotations-documents), semantic [FUNSD-shaped records](https://docsetgenerator.com/funsd-format), and conservative [DocVQA export](https://docsetgenerator.com/docvqa-dataset). Start with [OCR training data](https://docsetgenerator.com/ocr-training-data) when you need a complete dataset recipe.
