Instructions to use agentable/pp-doclayoutv3-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use agentable/pp-doclayoutv3-mlx with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] huggingface-cli download --local-dir pp-doclayoutv3-mlx agentable/pp-doclayoutv3-mlx
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
PP-DocLayoutV3 β MLX
Apple MLX port of PP-DocLayoutV3, the RT-DETR-style document-layout
detector used by model-pp-doclayoutv3
(image β 25-class layout regions with boxes, instance masks, and reading order).
A single PP-DocLayoutV3.safetensors (~142 MB fp32), self-converted from the
ONNX graph (Bei0001/PP-DocLayoutV3-ONNX
β the only export keeping all 4 heads) β no retraining, only a layout conversion
gated on numerical parity. The file also carries the AIFI positional embedding
and the baked decoder constants (order masks, coordinate grids) the MLX forward
needs.
Architecture
RT-DETR family: HGNetV2 CNN backbone β hybrid encoder (AIFI transformer layer + CCFM FPN/PAN fusion + mask-feature head) β 6-layer transformer decoder with multi-scale deformable attention (300 queries) β 4 heads:
logits(1,300,25) β class scorespred_boxes(1,300,4) β DETR cxcywhout_masks(1,300,200,200) β instance masksorder_logits(1,300,300) β reading order
The MLX backend replays the whole ONNX graph faithfully op-by-op (convs via an NHWC transpose-dance; the deformable GridSample, TopK query selection, GatherND, and bilinear Resize all in MLX), so no part of the intricate MSDeformAttn / box decode is re-derived by hand.
Parity
The full forward matches the fp32 ONNX outputs (relative error vs each output's own scale β the order/mask heads carry Β±10000 mask-fill magnitudes):
| output | relative |
|---|---|
| logits | 1.6e-5 |
| pred_boxes | 2.2e-5 |
| out_masks | 1.3e-5 |
| order_logits | 3.2e-6 |
End-to-end, the full Detect pipeline (preprocess β forward β DB-style postproc)
produces byte-identical layout elements (class / box / reading order) to the
ONNX backend on a real document.
Usage
Backs the MLX backend of github.com/agentable/model-pp-doclayoutv3. Build with
-tags mlx on Apple Silicon and place PP-DocLayoutV3.safetensors next to the
ONNX graph in the model directory. The default build stays pure-ONNX (no
MLX/Metal links).
License
Apache-2.0, following upstream PaddleOCR / PaddleX.
Quantized