deepDoctection version 1.2.x now handles full document intelligence pipelines. The tool combines layout detection, table structure recognition, OCR, reading-order reconstruction, annotation linking, and structured export in one workflow. Users configure the analyzer explicitly with DocLayNet-based layout detection, Table Transformer structure recognition, and DocTR OCR. The resulting Page objects represent text, figures, tables, relationships, provenance, and reading order. The framework also allows registering custom object types and implementing a PipelineComponent to extract monetary and date entities while classifying documents by their tabular characteristics. A custom pipeline assembles manually with ServiceFactory. Filtering and service rollback are supported. Processed pages serialize, and document annotations transform into ordered JSONL chunks for downstream RAG and retrieval systems.
In this article
Setup and environment
The code installs required dependencies: deepDoctection, transformers, timm, python-doctr, pdfplumber, networkx, and lxml. Environment variables set DD_USE_TORCH to True, DPI to 200, and LOG_LEVEL to INFO. ENABLE_DYNAMIC_OBJECT_TYPES remains False. A compatibility patch disables PEFT adapter lookup for from_pretrained.
The tutorial downloads a sample PDF from a GitHub raw link and an image file. An output directory named /content/out is created. Helper functions visualize images and handle analysis for directories, PDFs, and single image files. Passing a path to a single image without bytes raises a ValueError.
Model configuration
Inspecting the model registry confirms the layout model and its supported document categories. The analyzer configures layout detection, table segmentation, DocTR OCR, word matching, reading-order reconstruction, and layout linking. Specific settings include:
- Layout weights use Aryn/deformable-detr-DocLayNet/model.safetensors
- Table structure weights use deepdoctection/tatr_tab_struct_v2/model.safetensors
- OCR weights use doctr/db_resnet50/db_resnet50-ac60cadc.pt and doctr/crnn_vgg16_bn/crnn_vgg16_bn-0417f351.pt
- Segmentation thresholds set to 0.4 for rows and columns
- Word matching uses IOA with a 0.3 threshold
- Text ordering includes residual text containers with a paragraph break of 0.035
Initialising the analyzer prints the pipeline components and the meta-annotation types it produces.
Processing results
Running the analyzer on the sample PDF materialises pages from the lazy data flow. The first page displays narrative text, layout blocks in reading order, and an annotation category histogram. Figure-caption relationships link via layout_link. Word provenance shows characters, service ID, model ID, and bounding boxes.
Detected tables render as HTML, CSV, and individual cell representations. The example table has a specific number of rows and columns, with defined row and column spans. If no table appears on the PDF pages, the finance.png sample contains one.
Custom extensions
The framework registers custom object types for summary keys. One class defines MONEY_MENTIONS, DATE_MENTIONS, and DOC_FLAVOUR. Another class defines TABULAR, NARRATIVE, and MIXED labels.
Regular expressions identify currency mentions and dates in various formats. The EntityAndFlavourService class serves as a PipelineComponent. It calculates a tabular ratio by dividing total table area by page area. The process extracts unique money and date mentions from the text.
What it means
Developers build custom extraction logic without managing the underlying pipeline mechanics. The system handles file types, including PDFs and images, automatically. Output formats suit retrieval systems and downstream applications. Users extend the framework by registering new object types and services. The tool provides structured data for text, tables, and relationships in a single workflow.




