Fast, accurate OCR with correctness assessment.
Merge origin/main into webdemo.
hezhihui928fb1ccf450
diff --cc docs/SKILL.mdindex 21319c9,fb19c8b..c2f443b--- a/docs/SKILL.md+++ b/docs/SKILL.md@@@ -1,6 -1,6 +1,6 @@@---name: minicpmvocr-sdk- description: 安装、部署和验证 MiniCPM-OCR 1.0 文档解析 SDK 与 vLLM、SGLang 或 llama.cpp 推理服务,包括 DSpark、PDF/图片转 Markdown、本地 Web Demo 和安装排错。Jev 打分服务使用 SKILL_jev.md。-description: 安装、部署和验证 MiniCPM-OCR 1.0 文档解析 SDK 与 vLLM、SGLang、llama.cpp 或 Ollama 推理服务,包括 DSpark、PDF/图片转 Markdown 和安装排错。Jev 打分服务使用 SKILL_jev.md。++description: 安装、部署和验证 MiniCPM-OCR 1.0 文档解析 SDK 与 vLLM、SGLang、llama.cpp 或 Ollama 推理服务,包括 DSpark、PDF/图片转 Markdown、本地 Web Demo 和安装排错。Jev 打分服务使用 SKILL_jev.md。---# MiniCPM-OCR 1.0 安装、部署与验证@@@ -16,10 -16,10 +16,11 @@@ SDK(命令 `minicpmvocr`,发行包| Linux x86_64 + NVIDIA,默认方案 | `.venv-vllm`,可用 DSpark | `vllm` | [SDK 教程](./minicpm_ocr_tutorial.md) || Linux x86_64 + NVIDIA,选择 SGLang | `.venv-sglang`,可用 DSpark | `sglang` | [SGLang 指南](./sglang_deploy_zh.md) || CPU、本地 GPU 或 Apple Silicon,选择 llama.cpp | `sources/llama.cpp/build`,使用 GGUF,可用 DSpark | `llamacpp` | [llama.cpp 指南](./llamacpp_deploy_zh.md) |- | 已有兼容推理服务 | 复用服务,只装 SDK | 按服务协议选择 | 本文第 7 节 |- | 第 7 节已跑通全页解析,要开本地页面 | 复用 `.minicpm-ocr` 和已有识别服务 | 按识别服务 | [Web Demo 部署教程](./webdemo_deploy_zh.md) 与本文第 9 节 |+ | CPU、本地 GPU 或 Apple Silicon,选择 Ollama | Ollama ≥0.40.12,使用 GGUF,可用 DSpark | `ollama` | [Ollama 部署指南](./ollama_deploy_zh.md) |+ | 已有兼容推理服务 | 复用服务,只装 SDK | 按服务协议选择 | 本文第 8 节 |++| 第 8 节已跑通全页解析,要开本地页面 | 复用 `.minicpm-ocr` 和已有识别服务 | 按识别服务 | [Web Demo 部署教程](./webdemo_deploy_zh.md) 与本文第 10 节 |- - SGLang 使用 `--backend sglang`;SDK 内部将 `sglang` 映射到 `openai` 兼容客户端,`list-backends` 不单独列出 SGLang。llama.cpp 用 `llamacpp`,不要复用 vLLM 特有请求字段。+ - SGLang 使用 `--backend sglang`;SDK 内部将 `sglang` 映射到 `openai` 兼容客户端,`list-backends` 不单独列出 SGLang。llama.cpp 用 `llamacpp`,Ollama 用 `ollama`(走 Ollama 原生 `/api/chat`,必须用 `--model` 指定已注册的模型名);都不要复用 vLLM 特有请求字段。- llama.cpp 的 Metal 服务不要求 CUDA;完整解析还需要能运行 PP-DocLayoutV3 的 SDK 环境。若本机没有对应 PaddlePaddle wheel,单独安排兼容的 SDK 主机,不把 Metal 服务可用当成整个 SDK 已可用。- SDK 与服务可以分处两台机器。先确认实际系统、GPU/内存、可用磁盘、目标工作目录和服务地址;已知信息无需再问。@@@ -416,30 -538,3 +539,30 @@@ Ollama 在 `ollama serve` 的终端输�汇报实际使用的后端、源码 SHA/包版本、模型文件、设备、地址,以及安装检查、健康检查、带图请求、单页解析分别通过与否。安装成功、服务就绪、识别正确、DSpark 生效是不同结论。不要在排错时删除用户环境、重置源码或用未核实的临时补丁掩盖版本不匹配。参数与 API 细节见 [SDK 配置说明](./minicpm_ocr_sdk_api.md);Jev 打分服务使用 [Jev Skill](./SKILL_jev.md),不混用其权重、分类架构和验证标准。+- ## 9. 可选:本地 Web Demo++## 10. 可选:本地 Web Demo+- 第 7 节全页解析已经通过后,才启动本地页面。命令和注释以 [Web Demo 部署教程](./webdemo_deploy_zh.md) 为准,不要另写一套启动方式。++第 8 节全页解析已经通过后,才启动本地页面。命令和注释以 [Web Demo 部署教程](./webdemo_deploy_zh.md) 为准,不要另写一套启动方式。++在已经跑通的 `.minicpm-ocr` 环境里补页面服务,并准备旋转自适应模型:++```bash+source .minicpm-ocr/bin/activate+python -m pip install fastapi uvicorn python-multipart+bash webdemo/backend/prepare_upright_models.sh+```+- 识别服务沿用第 4–6 节已经在跑的 `minicpm-ocr`,地址是 `http://127.0.0.1:18499`。后端的 `OCR_ENGINE_TYPE` 按实际服务填写:vLLM 为 `vllm`,SGLang 为 `openai`,llama.cpp 为 `llamacpp`。Ollama 见部署教程。后端默认端口 `8966`,旋转自适应默认打开,模型目录是 `models/paddle_upright`。`curl -f http://127.0.0.1:8966/health` 返回 `{"status":"ok"}` 只说明进程已起来。++识别服务沿用第 4–7 节已经在跑的 `minicpm-ocr`,地址是 `http://127.0.0.1:18499`。后端的 `OCR_ENGINE_TYPE` 按实际服务填写:vLLM 为 `vllm`,SGLang 为 `openai`,llama.cpp 为 `llamacpp`。Ollama 见部署教程。后端默认端口 `8966`,旋转自适应默认打开,模型目录是 `models/paddle_upright`。`curl -f http://127.0.0.1:8966/health` 返回 `{"status":"ok"}` 只说明进程已起来。++前端需要 Node.js 22 或更高版本。在 `webdemo/frontend` 用 Corepack 安装依赖并启动后,打开 `http://localhost:5173/playground/document-parse`。关键信息抽取页是 `http://localhost:5173/playground/field-extract`。++后端同样也提供了 API 服务,以下是相关的 API 接口。++| 接口 | 用途 |+|---|---|+| `POST /api/document-parse/jobs` | 异步图片或 PDF,HTTP 200 返回任务 |+| `GET /api/document-parse/jobs/{id}` | HTTP 200 返回进度与结果 |+| `DELETE /api/document-parse/jobs/{id}` | 取消任务,HTTP 200 返回任务状态 |+| `POST /api/kie` | 同步单图,HTTP 200 返回单页响应 |++文档解析的图片和 PDF 都创建任务,响应里 `status` 为 `Running`。关键信息抽取走 `POST /api/kie`,只接受单张图片:JSON 请求体带 `image` 和 `fields`。这一路不创建任务,也不接收 PDF。关键信息抽取的异步形式可以参照文档解析进行改造。diff --cc docs/SKILL_en.mdindex c49a5cc,46690a0..a843f6e--- a/docs/SKILL_en.md+++ b/docs/SKILL_en.md@@@ -1,6 -1,6 +1,6 @@@---name: minicpmvocr-sdk- description: Install, deploy and verify the MiniCPM-OCR 1.0 document parsing SDK with vLLM, SGLang or llama.cpp, including DSpark, PDF/image to Markdown, the local Web Demo and installation troubleshooting. Use SKILL_jev_en.md for Jev scoring services.-description: Install, deploy and verify the MiniCPM-OCR 1.0 document parsing SDK with vLLM, SGLang, llama.cpp or Ollama, including DSpark, PDF/image to Markdown and installation troubleshooting. Use SKILL_jev_en.md for Jev scoring services.++description: Install, deploy and verify the MiniCPM-OCR 1.0 document parsing SDK with vLLM, SGLang, llama.cpp or Ollama, including DSpark, PDF/image to Markdown, the local Web Demo and installation troubleshooting. Use SKILL_jev_en.md for Jev scoring services.---# MiniCPM-OCR 1.0 installation, deployment and verification@@@ -16,10 -16,10 +16,11 @@@ The SDK (command `minicpmvocr`, distrib| Linux x86_64 + NVIDIA, default route | `.venv-vllm`, DSpark available | `vllm` | [SDK tutorial](./minicpm_ocr_tutorial_en.md) || Linux x86_64 + NVIDIA, SGLang selected | `.venv-sglang`, DSpark available | `sglang` | [SGLang guide](./sglang_deploy.md) || CPU, local GPU or Apple Silicon, llama.cpp selected | `sources/llama.cpp/build`, GGUF weights, DSpark available | `llamacpp` | [llama.cpp guide](./llamacpp_deploy.md) |- | Existing compatible inference service | Reuse it; install only the SDK | Select by protocol | Section 7 below |- | Section 7 full-page parse already works, and a local page is needed | Reuse `.minicpm-ocr` and the running recognition service | Match the recognition service | [Web Demo deployment tutorial](./webdemo_deploy.md) and section 9 below |+ | CPU, local GPU or Apple Silicon, Ollama selected | Ollama ≥0.40.12, GGUF weights, DSpark available | `ollama` | [Ollama guide](./ollama_deploy.md) |+ | Existing compatible inference service | Reuse it; install only the SDK | Select by protocol | Section 8 below |++| Section 8 full-page parse already works, and a local page is needed | Reuse `.minicpm-ocr` and the running recognition service | Match the recognition service | [Web Demo deployment tutorial](./webdemo_deploy.md) and section 10 below |- - Use `--backend sglang` for SGLang. The SDK internally maps `sglang` to the `openai`-compatible client; `list-backends` does not list SGLang separately. Select `llamacpp` for llama.cpp and avoid vLLM-specific request fields.+ - Use `--backend sglang` for SGLang. The SDK internally maps `sglang` to the `openai`-compatible client; `list-backends` does not list SGLang separately. Select `llamacpp` for llama.cpp and `ollama` for Ollama (it uses Ollama's native `/api/chat` and requires `--model` with the registered model name); avoid vLLM-specific request fields for both.- A llama.cpp Metal server does not require CUDA. Full parsing also needs an SDK environment that can run PP-DocLayoutV3. If PaddlePaddle has no matching local wheel, use a compatible SDK host; a working Metal server alone does not validate the entire SDK.- The SDK and server may run on different machines. Establish the actual OS, GPU/memory, free disk space, destination directory and endpoint; reuse information already provided.@@@ -416,30 -538,3 +539,30 @@@ For Ollama, check the output of the `olReport the actual backend, source SHAs/package versions, model files, device, endpoint and the separate outcomes of installation checks, health checks, image requests and one-page parsing. Installation success, service readiness, correct recognition and active DSpark are distinct conclusions. Do not delete user environments, reset source or conceal version mismatches with unverified temporary patches.See [SDK configuration](./minicpm_ocr_sdk_api_en.md) for parameter and API details. For Jev scoring, use the [Jev Skill](./SKILL_jev_en.md); its weights, classification architecture and validation criteria are separate.+- ## 9. Optional: local Web Demo++## 10. Optional: local Web Demo+- Start the local page only after the full-page parse in section 7 has passed. Follow the commands and comments in the [Web Demo deployment tutorial](./webdemo_deploy.md). Do not invent a second startup procedure.++Start the local page only after the full-page parse in section 8 has passed. Follow the commands and comments in the [Web Demo deployment tutorial](./webdemo_deploy.md). Do not invent a second startup procedure.++On the `.minicpm-ocr` environment that already parses pages, add the page server packages and prepare the rotation-adaptation models:++```bash+source .minicpm-ocr/bin/activate+python -m pip install fastapi uvicorn python-multipart+bash webdemo/backend/prepare_upright_models.sh+```+- Keep the `minicpm-ocr` recognition service from sections 4–6 running at `http://127.0.0.1:18499`. Set the backend `OCR_ENGINE_TYPE` from that service: `vllm` for vLLM, `openai` for SGLang, and `llamacpp` for llama.cpp. Ollama is covered in the deployment tutorial. The backend listens on `8966` by default. Rotation adaptation is on by default and uses `models/paddle_upright`. `curl -f http://127.0.0.1:8966/health` returning `{"status":"ok"}` means the process is up.++Keep the `minicpm-ocr` recognition service from sections 4–7 running at `http://127.0.0.1:18499`. Set the backend `OCR_ENGINE_TYPE` from that service: `vllm` for vLLM, `openai` for SGLang, and `llamacpp` for llama.cpp. Ollama is covered in the deployment tutorial. The backend listens on `8966` by default. Rotation adaptation is on by default and uses `models/paddle_upright`. `curl -f http://127.0.0.1:8966/health` returning `{"status":"ok"}` means the process is up.++The frontend needs Node.js 22 or later. After installing dependencies with Corepack and starting the dev server in `webdemo/frontend`, open `http://localhost:5173/playground/document-parse`. Key information extraction is at `http://localhost:5173/playground/field-extract`.++The backend also provides an API. The endpoints are listed below.++| Endpoint | Purpose |+|---|---|+| `POST /api/document-parse/jobs` | Async image or PDF. HTTP 200 returns a job |+| `GET /api/document-parse/jobs/{id}` | HTTP 200 returns progress and results |+| `DELETE /api/document-parse/jobs/{id}` | Cancel the job. HTTP 200 returns the job status |+| `POST /api/kie` | Sync single image. HTTP 200 returns one page |++Document parsing creates a job for both images and PDFs. The response `status` is `Running`. Key information extraction uses `POST /api/kie` and accepts one image: a JSON body with `image` and `fields`. That call does not create a job and does not accept a PDF. The async form of key information extraction can be adapted by following document parsing.