PP DocLayoutV2

提供商PaddlePaddle
分类object-detection
许可证apache-2.0
下载量175.0K
星标2

简介

PP DocLayoutV2 是由飞桨团队推出的文档布局分析模型,专注于解决复杂文档(如论文、报表、扫描件)的结构化解析问题。它能精准识别文档中的段落、表格、图片及标题等元素,是构建 RAG(检索增强生成)流水线中 PDF 解析环节的关键组件。相比于通用 OCR,它更强调对页面空间结构的理解,能有效避免文本提取时的乱序问题。对于开发者而言,该模型适配 PaddlePaddle 生态,上手门槛低,可直接替代部分昂贵的商业解析工具,提升文档数字化效率。

核心亮点

  • 精准识别复杂文档布局,有效区分表格与正文
  • 大幅优化 RAG 链路中 PDF 解析的文本顺序
  • 基于 Apache-2.0 协议,企业级部署无压力
  • 深度适配飞桨生态,推理速度快且易于部署

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("PaddlePaddle/PP-DocLayoutV2")
tokenizer = AutoTokenizer.from_pretrained("PaddlePaddle/PP-DocLayoutV2")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download PaddlePaddle/PP-DocLayoutV2

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download PaddlePaddle/PP-DocLayoutV2 config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('PaddlePaddle/PP-DocLayoutV2')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/PaddlePaddle/PP-DocLayoutV2

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/PaddlePaddle/PP-DocLayoutV2

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('PaddlePaddle/PP-DocLayoutV2')
tokenizer = AutoTokenizer.from_pretrained('PaddlePaddle/PP-DocLayoutV2')

模型下载

我们推荐使用命令行或者 ModelScope SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 ModelScope:

操作指引
pip install modelscope

命令行下载

下载完整模型库

下载完整模型库
modelscope download --model PaddlePaddle/PP-DocLayoutV2

下载单个文件到指定本地文件夹(以下载 README.md 到当前路径下 dir 目录为例)

下载单个文件到指定本地文件夹(以下载 README.md 到当前路径下 dir 目录为例)
modelscope download --model PaddlePaddle/PP-DocLayoutV2 README.md --local_dir ./dir

更多更丰富的命令行下载选项,可参见具体文档

SDK 下载

SDK 下载
# 模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('PaddlePaddle/PP-DocLayoutV2')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://www.modelscope.cn/PaddlePaddle/PP-DocLayoutV2.git

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/PaddlePaddle/PP-DocLayoutV2.git

ModelScope 模型页直接下载模型文件;无需将模型文件放在本站服务器。

Notebook 快速开发

下载并安装 ModelScope library

下载并安装 ModelScope library
pip install "modelscope[audio,cv,nlp,multi-modal,science]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

模型加载和推理

模型加载和推理
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

p = pipeline('text-generation', 'PaddlePaddle/PP-DocLayoutV2')

完整文档

来源: HuggingFace

---
license: apache-2.0
pipeline_tag: object-detection
tags:

  • PaddleOCR

  • PaddlePaddle

  • ocr

  • layout

  • layout_detection

language:
  • en

  • zh

  • multilingual

library_name: PaddleOCR
---

Introduction

PP-DocLayoutV2 is a dedicated lightweight model for layout analysis, focusing specifically on element detection, classification, and reading order
prediction.

Model Architecture

PP-DocLayoutV2 is composed of two sequentially connected networks. The first is an RT-DETR-based detection model that performs layout element detection and classification. The detected bounding boxes and class labels are then passed to a subsequent pointer network, which is responsible for ordering these layout elements.

<div align="center">
<img src="https://huggingface.co/datasets/PaddlePaddle/PaddleOCR-VL_demo/resolve/main/imgs/PP-DocLayoutV2.png" width="800"/>
</div>

Usage

Install Dependencies

Install PaddlePaddle and PaddleOCR:

bash
python -m pip install paddlepaddle-gpu==3.2.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/
python -m pip install -U "paddleocr[doc-parser]"
python -m pip install https://paddle-whl.bj.bcebos.com/nightly/cu126/safetensors/safetensors-0.6.2.dev0-cp38-abi3-linux_x86_64.whl

> For Windows users, please use WSL or a Docker container.

Basic Usage

Python API usage:

python
from paddleocr import LayoutDetection

model = LayoutDetection(model_name="PP-DocLayoutV2")
output = model.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/layout.jpg", batch_size=1, layout_nms=True)
for res in output:
res.print()
res.save_to_img(save_path="./output/")
res.save_to_json(save_path="./output/res.json")

For more usage details and parameter explanations, see the documentation.

Citation

If you find PaddleOCR-VL helpful, feel free to give us a star and citation.

bibtex
@misc{cui2025paddleocrvlboostingmultilingualdocument,
      title={PaddleOCR-VL: Boosting Multilingual Document Parsing via a 0.9B Ultra-Compact Vision-Language Model}, 
      author={Cheng Cui and Ting Sun and Suyin Liang and Tingquan Gao and Zelun Zhang and Jiaxuan Liu and Xueqing Wang and Changda Zhou and Hongen Liu and Manhui Lin and Yue Zhang and Yubo Zhang and Handong Zheng and Jing Zhang and Jun Zhang and Yi Liu and Dianhai Yu and Yanjun Ma},
      year={2025},
      eprint={2510.14528},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2510.14528}, 
}