Layout Detection Configuration#
Docling's layout detection pipeline has two distinct configuration layers: inference-time parameters on LayoutPredictor (in docling-ibm-models) and postprocessing parameters on LayoutPostprocessor (in docling). Both are surfaced through PdfPipelineOptions.layout_options.
PdfPipelineOptions.layout_options#
The top-level entry point is PdfPipelineOptions.layout_options, which accepts a BaseLayoutOptions subclass. Two concrete types exist:
| Class | kind | Purpose |
|---|---|---|
LayoutOptions | docling_layout_default | Default path — uses a named LayoutModelConfig |
LayoutObjectDetectionOptions | layout_object_detection | Pluggable object-detection runtime with preset support |
Both inherit from BaseLayoutOptions, which provides:
keep_empty_clusters(defaultFalse) — retain clusters with no assigned text cells; useful for debugging empty figure regionsskip_cell_assignment(defaultFalse) — bypass the spatial cell→cluster assignment pass entirelycreate_orphan_clusters(defaultTrueonLayoutOptions,FalseonLayoutObjectDetectionOptions) — unassigned text cells become newTEXTclusters
Inference-Time: LayoutPredictor parameters#
LayoutPredictor.__init__ in docling-ibm-models exposes the following parameters:
| Parameter | Default | Effect |
|---|---|---|
base_threshold | 0.3 | Global confidence floor; detections below this are discarded before postprocessing |
blacklist_classes | set() | Set of label strings (e.g., "Form", "Key-Value Region") to suppress entirely at inference time |
device | "cpu" | Inference device ("cpu", "cuda", "mps", "xpu") |
num_threads | 4 | CPU thread count (only used when device="cpu") |
base_threshold is applied inside RTDetrImageProcessor.post_process_object_detection as an initial recall/precision knob . The LayoutModel currently constructs LayoutPredictor with only artifact_path, device, and num_threads — meaning base_threshold stays at its default 0.3 and blacklist_classes is empty unless the predictor is instantiated directly .
Postprocessing: LayoutPostprocessor constants#
After inference, LayoutPostprocessor applies per-label thresholding and overlap resolution using class-level constants — these are not runtime-configurable through PdfPipelineOptions and require source changes to adjust.
CONFIDENCE_THRESHOLDS#
Per-label confidence thresholds applied after the base_threshold gate :
| Labels (0.5 threshold) | Labels (0.45 threshold) |
|---|---|
CAPTION, FOOTNOTE, FORMULA, LIST_ITEM, PAGE_FOOTER, PAGE_HEADER, PICTURE, TABLE, TEXT | SECTION_HEADER, TITLE, CODE, CHECKBOX_SELECTED, CHECKBOX_UNSELECTED, FORM, KEY_VALUE_REGION, DOCUMENT_INDEX |
Detections below these thresholds are filtered in _process_regular_clusters and _process_special_clusters .
LABEL_REMAPPING#
After thresholding, labels are remapped: TITLE → SECTION_HEADER . This is why DocItemLabel.TITLE predictions are never surfaced directly in the assembled document.
OVERLAP_PARAMS#
Three overlap-resolution parameter sets govern which cluster survives when two clusters overlap :
| Cluster type | area_threshold | conf_threshold |
|---|---|---|
regular | 1.3 | 0.05 |
picture | 2.0 | 0.3 |
wrapper | 2.0 | 0.2 |
When two clusters overlap, the candidate is dropped if area_ratio ≤ area_threshold and conf_diff > conf_threshold. Picture and wrapper types require larger area differences and confidence gaps before a cluster is removed .
WRAPPER_TYPES and cross-type overlap#
TABLE, FORM, KEY_VALUE_REGION, and DOCUMENT_INDEX are treated as wrappers . Regular clusters ≥80% contained within a wrapper become its children. A KEY_VALUE_REGION overlapping a TABLE by >90% with a confidence advantage <0.1 is silently dropped in favor of the TABLE . Pictures with IoU >0.8 against a table are also removed .
Full-page pictures (bbox area > 90% of page area) are unconditionally filtered out .
Key Source Files#
| File | Role |
|---|---|
docling/datamodel/pipeline_options.py | BaseLayoutOptions, LayoutOptions, LayoutObjectDetectionOptions |
docling/utils/layout_postprocessor.py | CONFIDENCE_THRESHOLDS, OVERLAP_PARAMS, LABEL_REMAPPING constants |
docling/models/stages/layout/layout_model.py | Wires LayoutPredictor + LayoutPostprocessor; passes options to postprocessor |
docling_ibm_models/layoutmodel/layout_predictor.py | LayoutPredictor.__init__ — base_threshold, blacklist_classes |