Skip to content

Fast, accurate OCR with correctness assessment.

docs: explain the two-stage parsing pipeline in both READMEs

wq-vibe05aaebccc6f5
diff --git a/README.md b/README.md
index 7f47af8..b46506a 100644
--- a/README.md
+++ b/README.md
@@ -151,6 +151,32 @@ See the [MiniCPM-OCR Jev model guide](./docs/minicpm_ocr_jev_en.md) for more on
Choose how to integrate MiniCPM-OCR 1.0 and MiniCPM-OCR Jev:
+### How Document Parsing Works
+
+Full-page parsing runs as a **two-stage pipeline** orchestrated by the `minicpmvocr` SDK. The two stages use separate models, run in separate environments, and may run on different machines:
+
+```mermaid
+flowchart LR
+ DOC["PDF / image"] --> S1
+
+ subgraph SDKENV ["minicpmvocr SDK (its own environment)"]
+ S1["Stage 1 · Layout detection<br>PP-DocLayoutV3 layout model (PaddlePaddle / PaddleX)<br>regions, reading order, cropping"]
+ ASM["Assemble output<br>Markdown / JSON in reading order"]
+ end
+
+ subgraph SRVENV ["Recognition service (separate environment)"]
+ S2["Stage 2 · Region recognition<br>MiniCPM-OCR 1.0<br>vLLM / SGLang / llama.cpp / Ollama"]
+ end
+
+ S1 -- "each cropped region, over HTTP,<br>with a prompt for its region type" --> S2
+ S2 -- "text, tables, formulas, charts, seals" --> ASM
+```
+
+- **Stage 1 — Layout detection (run locally by the SDK).** The PP-DocLayoutV3 layout model detects document regions — text, tables, formulas, charts, seals — and analyzes reading order; the SDK then crops the regions. It runs inside the SDK environment and requires PaddlePaddle / PaddleX.
+- **Stage 2 — Region recognition (inference service).** The SDK sends each cropped region over HTTP to a MiniCPM-OCR 1.0 inference service — served by vLLM, SGLang, llama.cpp, or Ollama — with a prompt matching the region type (`Text Recognition:`, `Table Recognition:`, `Formula Recognition:`, …). The SDK assembles the recognized content into the final Markdown / JSON in reading order.
+
+A full local deployment therefore prepares **two environments side by side**: the SDK environment (pip package `minicpm-ocr`, plus PaddlePaddle / PaddleX for the layout model) and the inference-service environment of the chosen backend. The [Skill](#skill) walks through the complete setup — backend choice, environment installation, model downloads, and verification — and the [SDK tutorial](./docs/minicpm_ocr_tutorial_en.md) covers the same steps for manual deployment. For region prompts and per-stage details, see the [document parsing workflow](./docs/minicpm_ocr_1dot0_en.md#document-parsing-workflow).
+
<a id="使用-agent-skill-部署推荐"></a>
### Skill
diff --git a/README_zh.md b/README_zh.md
index b0554fd..237c2cb 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -149,6 +149,32 @@
选择适合你的 MiniCPM-OCR 1.0 和 MiniCPM-OCR Jev 接入方式:
+### 文档解析的两阶段流程
+
+整页解析由 `minicpmvocr` SDK 统一编排,运行在**两阶段流水线**上:两个阶段使用不同的模型、运行在相互独立的环境中,也可以部署在不同机器上:
+
+```mermaid
+flowchart LR
+ DOC["PDF / 图片"] --> S1
+
+ subgraph SDKENV ["minicpmvocr SDK(独立环境)"]
+ S1["阶段一 · 版面检测<br>PP-DocLayoutV3 版面模型(PaddlePaddle / PaddleX)<br>区域、阅读顺序、切块"]
+ ASM["拼接输出<br>按阅读顺序生成 Markdown / JSON"]
+ end
+
+ subgraph SRVENV ["识别服务(另一套独立环境)"]
+ S2["阶段二 · 区域识别<br>MiniCPM-OCR 1.0<br>vLLM / SGLang / llama.cpp / Ollama"]
+ end
+
+ S1 -- "每个切块经 HTTP 发送,<br>按区域类型匹配提示词" --> S2
+ S2 -- "文本、表格、公式、图表、印章" --> ASM
+```
+
+- **阶段一 · 版面检测(SDK 本地运行)**:PP-DocLayoutV3 版面模型检测文档区域(文本、表格、公式、图表、印章等)并分析阅读顺序,SDK 按区域切块。版面检测在 SDK 环境内运行,依赖 PaddlePaddle / PaddleX。
+- **阶段二 · 区域识别(推理服务)**:SDK 通过 HTTP 将每个切块发送给 MiniCPM-OCR 1.0 推理服务(由 vLLM、SGLang、llama.cpp 或 Ollama 部署),并按区域类型匹配提示词(`Text Recognition:`、`Table Recognition:`、`Formula Recognition:` 等),随后按阅读顺序把识别出的内容拼接为最终的 Markdown / JSON。
+
+因此,完整的本地部署需要同时准备**两套环境**:SDK 环境(pip 包 `minicpm-ocr`,另装 PaddlePaddle / PaddleX 用于版面模型)和所选推理后端的服务环境。[Skill](#skill) 给出了从后端选择、环境安装、模型下载到验证的完整步骤;[SDK 使用教程](./docs/minicpm_ocr_tutorial.md)覆盖了手动部署的相同步骤。各区域提示词与分阶段细节见[文档解析流程](./docs/minicpm_ocr_1dot0_zh.md#文档解析流程)。
+
<a id="使用-agent-skill-部署推荐"></a>
### Skill