Document Layout Detection Models#
Docling's layout detection layer identifies and localizes structural elements on document page images using a family of RT-DETR-based object detection models. Two model families are available: Heron and Egret, each hosted on HuggingFace under the docling-project organization. All variants share the same 17-label taxonomy and a common LayoutPredictor API, making them interchangeable in the pipeline.
Architecture#
All models are loaded via LayoutPredictor in docling-ibm-models, which wraps HuggingFace's AutoModelForObjectDetection and RTDetrImageProcessor. The predictor exposes two inference methods:
predict(image)— single-image inference, yields bounding box dictspredict_batch(images)— batched inference, more efficient for pipeline use
Each result dict contains keys label, confidence, l, t, r, b (pixel coordinates, top-left origin) .
Within the Docling pipeline, LayoutModel.predict_layout() calls predict_batch() and feeds results into LayoutPostprocessor for confidence thresholding, label remapping, cell-to-cluster assignment, orphan cell recovery, and overlap resolution .
Model Variants and Configuration#
Model specifications are defined as LayoutModelConfig instances (Pydantic models) and registered in LayoutModelType:
| Constant | HuggingFace Repo | Family | Trade-off |
|---|---|---|---|
DOCLING_LAYOUT_HERON | docling-project/docling-layout-heron | Heron | Default — balanced |
DOCLING_LAYOUT_HERON_101 | docling-project/docling-layout-heron-101 | Heron | Alternative Heron backbone |
DOCLING_LAYOUT_EGRET_MEDIUM | docling-project/docling-layout-egret-medium | Egret | Fast, lower GPU memory |
DOCLING_LAYOUT_EGRET_LARGE | docling-project/docling-layout-egret-large | Egret | Balanced accuracy/speed |
DOCLING_LAYOUT_EGRET_XLARGE | docling-project/docling-layout-egret-xlarge | Egret | Highest accuracy, slower |
Default model is DOCLING_LAYOUT_HERON, set as the default value of LayoutOptions.model_spec in pipeline_options.py. To override, pass a different spec to LayoutOptions:
from docling.datamodel.layout_model_specs import DOCLING_LAYOUT_EGRET_XLARGE
# pass via LayoutOptions(model_spec=DOCLING_LAYOUT_EGRET_XLARGE)
All variants support CPU, CUDA, MPS, and XPU accelerators .
The 17-Label Taxonomy#
All model variants output the same canonical label set, defined in LayoutLabels:
| ID | Label | Notes |
|---|---|---|
| 0 | Caption | |
| 1 | Footnote | |
| 2 | Formula | |
| 3 | List-item | |
| 4 | Page-footer | |
| 5 | Page-header | |
| 6 | Picture | |
| 7 | Section-header | |
| 8 | Table | |
| 9 | Text | Covers all text, printed and handwritten |
| 10 | Title | |
| 11 | Document Index | DLNv2+ only |
| 12 | Code | DLNv2+ only |
| 13 | Checkbox-Selected | DLNv2+ only |
| 14 | Checkbox-Unselected | DLNv2+ only |
| 15 | Form | DLNv2+ only |
| 16 | Key-Value Region | DLNv2+ only |
Labels 0–10 originate from DLNv1/v2; labels 11–16 were added in DLNv2. The Text label does not distinguish printed from handwritten content — any differentiation requires a downstream classifier .
LayoutPredictor also accepts a blacklist_classes set to suppress specific labels at inference time .
Key Source Files#
| File | Purpose |
|---|---|
docling_ibm_models/layoutmodel/labels.py | Canonical 17-label taxonomy (LayoutLabels) |
docling_ibm_models/layoutmodel/layout_predictor.py | RT-DETR inference engine (LayoutPredictor) |
docling/datamodel/layout_model_specs.py | Model configs and LayoutModelType enum |
docling/datamodel/pipeline_options.py | LayoutOptions.model_spec default and pipeline wiring |
docling/models/stages/layout/layout_model.py | Pipeline stage calling predict_batch() |
docling/utils/layout_postprocessor.py | Post-processing (thresholding, clustering, overlap resolution) |