Skip to main content

A Docling plugin for PaddlePaddle PP-DocLayout-V3 model document layout detection.

Project description

docling-pp-doc-layout

A Docling plugin that provides document layout detection using the PaddlePaddle PP-DocLayout-V3 model.

This plugin seamlessly integrates with Docling's standard pipeline to replace the default layout models with PP-DocLayout-V3, enabling high-accuracy, instance segmentation-based layout analysis with polygon bounding box support, properly processed in optimized batches for enterprise scalability.


GitHub  |  PyPI


PyPI version Python versions License CI Ruff Coverage

Overview

docling-pp-doc-layout provides the PPDocLayoutV3Model layout engine for Docling. It automatically registers itself into Docling's plugin system upon installation. When configured in a Docling DocumentConverter, it intercepts page images, batches them, and infers document structural elements (text, tables, figures, headers, etc.) using HuggingFace's transformers library.

Key Features:

  • High Accuracy Layout Parsing: Uses the RT-DETR instance segmentation framework.
  • Polygon Conversion: Gracefully flattens complex polygon masks to Docling-compatible bounding boxes.
  • Enterprise Scalability: Configurable batch sizing avoids out-of-memory (OOM) errors on large documents.

Architecture & Integration

When you install this package, Docling discovers it automatically through standard Python package entry points.

flowchart TD
    A[Docling DocumentConverter] --> B[PdfPipeline]

    subgraph Plugin System
    C[Docling PluginManager] -.->|Discovers via entry-points| D[docling-pp-doc-layout]
    D -.->|Registers| E[PPDocLayoutV3Model]
    end

    B -->|Initialization| C
    B -->|Predict Layout Pages| E
    E -->|Batched Tensors| F[HuggingFace AutoModel]
    F -->|Raw Polygons / Boxes| E
    E -->|Post-processed Clusters & BoundingBoxes| B

Requirements

  • Python 3.13+
  • docling>=2.73
  • transformers>=5.1.0
  • torch

Installation

# with uv (recommended)
uv add docling-pp-doc-layout

# with pip
pip install docling-pp-doc-layout

Usage

Using docling-pp-doc-layout is exactly like configuring standard Docling options.

from docling.document_converter import DocumentConverter, PdfFormatOption
from docling.datamodel.pipeline_options import PdfPipelineOptions
from docling_pp_doc_layout.options import PPDocLayoutV3Options

# 1. Define Pipeline Options
pipeline_options = PdfPipelineOptions()

# 2. Configure our custom PPDocLayoutV3Options
pipeline_options.layout_options = PPDocLayoutV3Options(
    batch_size=8,                  # Tweak for GPU VRAM usage
    confidence_threshold=0.5,      # Filter low-confidence detections
    model_name="PaddlePaddle/PP-DocLayoutV3_safetensors" # Target HuggingFace model repo
)

# 3. Create the converter
converter = DocumentConverter(
    format_options={
        "pdf": PdfFormatOption(pipeline_options=pipeline_options)
    }
)

# 4. Convert Document
result = converter.convert("path/to/your/document.pdf")
print("Converted elements:", len(result.document.elements))

Configuration Options

The PPDocLayoutV3Options dataclass gives you full control over the engine:

Parameter Type Default Description
batch_size int 8 How many pages to process per single step. Decrease to lower memory usage; Increase to speed up processing of large documents.
confidence_threshold float 0.5 The minimum confidence score (0.0 - 1.0) required to keep a layout detection cluster.
model_name str "PaddlePaddle/PP-DocLayoutV3_safetensors" HuggingFace repository ID. Allows overriding if you host your local copy or a fine-tuned version.

Development

If you wish to contribute or modify the plugin locally:

git clone https://github.com/DCC-BS/docling-pp-doc-layout.git
cd docling-pp-doc-layout

# Install dependencies and pre-commit hooks
make install

# Run checks (ruff, ty) and tests (pytest)
make check
make test

License

MIT © DCC Data Competence Center

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docling_pp_doc_layout-0.2.0.tar.gz (156.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docling_pp_doc_layout-0.2.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file docling_pp_doc_layout-0.2.0.tar.gz.

File metadata

  • Download URL: docling_pp_doc_layout-0.2.0.tar.gz
  • Upload date:
  • Size: 156.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for docling_pp_doc_layout-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e82f394cfd80dc8015067cc8fe713e4a77b05465698469bac7bd1c4f77d5b82c
MD5 baa2db000baf7dbb49bffd65a02c599f
BLAKE2b-256 40b3e79beb7685255b2df31239eb78f3e03c331b4914f920fe3f11f70bd63ee4

See more details on using hashes here.

File details

Details for the file docling_pp_doc_layout-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: docling_pp_doc_layout-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for docling_pp_doc_layout-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35ededa1bd6bbf8bb5d1e4957f2631a0e6877dbb939fc327c7f10b70519dbfe7
MD5 6c3188a7fd7f1fbe8b705f28f6a8ee85
BLAKE2b-256 be83f5a4ba8536f6ebde486bdb5c2189203b19f3041fe7cbd49ace9bd4b7a0a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page