Image-Text-to-Text
MiniCPM-OCR
Safetensors
English
Chinese
minicpm_ocr
ocr
document-parsing
multimodal
vision-language
table-recognition
formula-recognition
conversational
Eval Results
Run this model with HF Jobs
Run openbmb/MiniCPM-OCR-1.0 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/openbmb/MiniCPM-OCR-1.0. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/openbmb/MiniCPM-OCR-1.0 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/openbmb/MiniCPM-OCR-1.0. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/openbmb/MiniCPM-OCR-1.0. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use openbmb/MiniCPM-OCR-1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MiniCPM-OCR
How to use openbmb/MiniCPM-OCR-1.0 with MiniCPM-OCR:
pip install "minicpm-ocr[all]" huggingface_hub # Deploy openbmb/MiniCPM-OCR-1.0 as a recognition service before running the Python example: # https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/vllm_deploy_en.md # vLLM: load the model above; use --port 8080, # --served-model-name minicpm-ocr and --max-model-len 40960. # Layout detection uses cuda:0; recognition runs on the deployed service.
from importlib.resources import files from pathlib import Path from minicpmvocr import load_config, pipelined_run from huggingface_hub import snapshot_download layout_model = snapshot_download("PaddlePaddle/PP-DocLayoutV3") cfg = load_config( str(files("minicpmvocr").joinpath("configs/minicpmvocr.yaml")), overrides={ "input": {"file_path": str(Path("demo.png").resolve())}, "engine": { "type": "vllm", "server_url": "http://127.0.0.1:8080", "model_name": "minicpm-ocr", "max_model_len": 40960, }, "layout": {"model_dir": layout_model, "device": "cuda:0"}, # Render PDFs in-process so this example also works without a main guard. "pipeline": {"overlap_layout": True, "render_workers": 1}, }, ) pipelined_run(cfg) - Notebooks
- Google Colab
- Kaggle
Add Chinese model card and usage guide banner
#15
by wunu - opened
Files changed (2)
- README.md+41-1
- README_zh.mdAdded+326
22 unmodified lines2324252627282922 unmodified lines<a href="https://github.com/OpenBMB/MiniCPM"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/minicpm-logo.jpg" width="300" alt="MiniCPM logo"></a></p>Demo ([CN](https://platform.modelbest.cn/console/playground/document-parse) / [Global](https://platform.modelbest.ai/console/playground/document-parse)) · [GitHub](https://github.com/OpenBMB/MiniCPM-OCR) · [Free API](https://platform.modelbest.ai/console/docs/api/document-parse) · [SDK usage](#use-with-the-minicpm-ocr-sdk) · [DSpark](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-DSpark) · [Skill](https://github.com/OpenBMB/MiniCPM-OCR#skill)</div>22 unmodified lines232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686922 unmodified lines<a href="https://github.com/OpenBMB/MiniCPM"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/minicpm-logo.jpg" width="300" alt="MiniCPM logo"></a></p><p align="center"><b>Usage Guide</b></p><table align="center" width="100%"><tr><td align="center" width="25%" valign="top"><b>🚀 Free API</b><br/><sub>Try it online for free, then call the API from your own code.</sub><br/>Playground (<a href="https://platform.modelbest.cn/console/playground/document-parse">CN</a> /<a href="https://platform.modelbest.ai/console/playground/document-parse">Global</a>)<br/>API docs (<a href="https://platform.modelbest.cn/console/docs/api/document-parse">CN</a> /<a href="https://platform.modelbest.ai/console/docs/api/document-parse">Global</a>)</td><td align="center" width="25%" valign="top"><b>🤖 Agent Skill</b><br/><sub>One prompt: the agent installs it and parses your first document.</sub><br/><a href="https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/SKILL_en.md">SKILL.md</a></td><td align="center" width="25%" valign="top"><b>💻 Self-hosting</b><br/><sub>vLLM / SGLang / llama.cpp / Ollama, plus an official Docker image. Data stays on your side.</sub><br/><a href="https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/minicpm_ocr_tutorial_en.md">Deployment guide</a></td><td align="center" width="25%" valign="top"><b>📱 Mobile App</b><br/><sub>On-device and offline. Document parsing is iOS-only for now.</sub><br/><a href="https://github.com/OpenBMB/MiniCPM-V-Apps/blob/main/README.md#11-ios-demo">iOS Demo</a></td></tr></table><p align="center">Demo (<a href="https://platform.modelbest.cn/console/playground/document-parse">CN</a> /<a href="https://platform.modelbest.ai/console/playground/document-parse">Global</a>) · <a href="https://github.com/OpenBMB/MiniCPM-OCR">GitHub</a> · <a href="#use-with-the-minicpm-ocr-sdk">SDK usage</a> · <a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0-DSpark">DSpark</a> · <a href="https://discord.gg/JE8KQqtdn">Discord</a> | <a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0/blob/main/README_zh.md">中文</a></p></div>
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326<div align="center">
<p align="center"> <img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/release-hero.svg" alt="MiniCPM-OCR:快速、准确地将文档解析为文本、表格和公式,通过闪电箭头连接文档与结构化结果;decision model 辅助标出需要复核的区域(示意图)。" width="100%"></p>
<p align="center"> <a href="https://github.com/OpenBMB/MiniCPM"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/minicpm-logo.jpg" width="300" alt="面壁小钢炮 MiniCPM"></a></p>
<p align="center"> <a href="https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/minicpm_ocr_1dot0_zh.md"><strong>MiniCPM-OCR 1.0 模型指南</strong></a> <a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0" title="Hugging Face"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/huggingface_logo-noborder.svg" width="19" height="18" alt="Hugging Face"></a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-1.0" title="ModelScope"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/modelscope_logo_padded.svg" width="25" height="14" alt="ModelScope"></a>   <a href="https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/minicpm_ocr_jev_zh.md"><strong>MiniCPM-OCR Jev 模型指南</strong></a> <a href="https://huggingface.co/openbmb/MiniCPM-OCR-Jev" title="Hugging Face"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/huggingface_logo-noborder.svg" width="19" height="18" alt="Hugging Face"></a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev" title="ModelScope"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/modelscope_logo_padded.svg" width="25" height="14" alt="ModelScope"></a></p>
<p align="center"> <b>使用指南</b></p>
<table align="center" width="100%"> <tr> <td align="center" width="25%" valign="top"> <b>🚀 免费 API</b><br/> <sub>零部署,先在线免费体验,再调接口。</sub><br/> 体验(<a href="https://platform.modelbest.cn/console/playground/document-parse">国内</a> / <a href="https://platform.modelbest.ai/console/playground/document-parse">海外</a>)<br/> API 文档(<a href="https://platform.modelbest.cn/console/docs/api/document-parse">国内</a> / <a href="https://platform.modelbest.ai/console/docs/api/document-parse">海外</a>) </td> <td align="center" width="25%" valign="top"> <b>🤖 Agent Skill</b><br/> <sub>一句话,让编码 Agent 自己装好环境、跑通第一篇文档。</sub><br/> <a href="https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/SKILL.md">SKILL.md</a> </td> <td align="center" width="25%" valign="top"> <b>💻 本地部署</b><br/> <sub>vLLM / SGLang / llama.cpp / Ollama,另有官方 Docker 镜像,数据不出内网。</sub><br/> <a href="https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/minicpm_ocr_tutorial.md">部署教程</a> </td> <td align="center" width="25%" valign="top"> <b>📱 手机 APP</b><br/> <sub>端侧运行,断网可用。文档解析目前仅 iOS。</sub><br/> <a href="https://github.com/OpenBMB/MiniCPM-V-Apps/blob/main/README.md#11-ios-demo">iOS Demo</a> </td> </tr></table>
<p align="center"> 体验平台(<a href="https://platform.modelbest.cn/console/playground/document-parse">国内</a> / <a href="https://platform.modelbest.ai/console/playground/document-parse">海外</a>) · <a href="https://github.com/OpenBMB/MiniCPM-OCR">GitHub</a> · <a href="https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/minicpm_ocr_tutorial.md">SDK</a> · <a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0-DSpark">DSpark</a> · <a href="https://discord.gg/JE8KQqtdn">Discord</a> | <a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0/blob/main/README.md">English</a></p>
</div>
**MiniCPM-OCR 1.0**(1.3B)是 [MiniCPM-V/o](https://github.com/openbmb/MiniCPM-V) 系列中首个 OCR 专用模型,聚焦于以文字为中心的文档理解——文字、表格、公式、图表、印章与结构化信息抽取——并在真实拍摄场景下兼顾解析质量与处理速度。
## 核心亮点
- 🏆 **SOTA 级文档解析**:在面向真实场景文档解析的基准 **Real5-OmniDocBench 上取得 93.68**,并在 OmniDocBench v1.6、Wild-OmniDocBench 和 olmOCR-Bench 上取得领先结果。支持中英文文档与 PDF,涵盖扫描件、弯曲页面、拍摄照片、倾斜页面和翻拍文档。- ⚡ **高效推理**:借助 DSpark 解码加速([BF16](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-DSpark)、[GGUF](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-DSpark-gguf)),端到端处理效率提升 **55%**;吞吐量约为 PaddleOCR-VL-1.6 的 **1.49 倍**、MinerU2.5 Pro 的 **3.62 倍**。- 🔍 **通用识别与信息抽取**:**OCRBench v2 得分 54.7**,并提供关键信息抽取(KIE),便于下游自动化处理。- 🛠️ **易部署、易开发**:发布首日即支持 **vLLM、SGLang、llama.cpp 和 Ollama**,提供多种量化版本与多芯片适配。支持二次微调,并提供 pip SDK、完整 API 和 Agent 工作流。在线体验:[HF Spaces](https://huggingface.co/spaces/openbmb/MiniCPM-OCR) · [CN](http://82.157.64.212:10111/playground/document-parse) · [官方国内](https://platform.modelbest.cn/console/playground/document-parse) · [官方海外](https://platform.modelbest.ai/console/playground/document-parse)。
## 更高吞吐下的 SOTA 解析质量
在所比较的开源 OCR 模型中,MiniCPM-OCR 1.0 达到 **1.2 页/秒**,并在 OmniDocBench v1.6、Real5-OmniDocBench、Wild-OmniDocBench 和 olmOCR-Bench 四个基准上取得最高的等权平均分。
<p align="center"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/efficiency-performance-en.png" alt="开源 OCR 模型的吞吐与解析质量对比。横轴:每秒页数(对数刻度)。纵轴:四个文档解析基准的等权平均分。" width="90%"></p>
<sub>平均分为四个基准的等权平均,所有模型均采用加速配置。配置与复现方式见[复现指南](https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/benchmark_reproduction_en.md);各模型吞吐量见[模型指南](https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/minicpm_ocr_1dot0_en.md#throughput)。</sub>
## 基准评测对比
<p align="center"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/benchmark-radar.png" alt="MiniCPM-OCR 1.0 与其他 OCR 模型在六个基准上的雷达图对比。" width="80%"></p>
### MiniCPM-OCR 1.0 完整评测结果
<p align="center"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/ocr-benchmarks.png" alt="OmniDocBench v1.6、Real5-OmniDocBench、Wild-OmniDocBench、olmOCR-Bench、CHAOS-Bench 与 OCRBench v2 上的详细 OCR 模型评测结果。" width="100%"></p>
<p align="center"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/benchmark-comparison.png" alt="Real5-OmniDocBench、Wild-OmniDocBench、OmniDocBench v1.6、olmOCR-Bench、OCRBench v2 与 CHAOS-Bench 的逐基准柱状图。" width="100%"></p>
每个子图保留各自基准的原始分数,分数越高越好;不同基准之间的分数不可直接比较。测试配置与复现步骤见[复现指南](https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/benchmark_reproduction_en.md),逐基准的讨论见[模型指南](https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/minicpm_ocr_1dot0_en.md#evaluation)。
### 吞吐量
在 NVIDIA GeForce RTX 5090 上,使用 OmniDocBench v1.6 的全部 1651 张图片、图片级并发数为 1、并采用各系统自身的加速配置,MiniCPM-OCR 1.0 达到 **1.2 页/秒**(相对吞吐量 **1.00×**,数值越大越快)。
<p align="center"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/throughput-comparison.png" alt="采用加速配置的 OCR 系统吞吐量对比;MiniCPM-OCR 1.0 达到 1.2 页/秒。" width="100%"></p>
并发数 1 指图片级并发:同一页内的各个区域仍会并行识别。实际吞吐量还取决于页面内容、推理后端、并发数和硬件。
## 效果示例
从左到右依次为:原始文档、检测到的版面、渲染后的 Markdown。
**英文文档**
<p align="center"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/minicpm-english-examples-3-column.gif" alt="英文文档动图:原始文档、检测到的版面、渲染后的 Markdown。" width="100%"></p>
**中文文档**
<p align="center"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/minicpm-chinese-examples-3-column.gif" alt="中文文档动图:原始文档、检测到的版面、渲染后的 Markdown。" width="100%"></p>
<details><summary><b>更多示例</b></summary>
原始文档与解析结果并排展示。
**英文文档**
<p align="center"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/minicpm-ocr-english-cases.png" alt="英文示例的输入与结果对比:手写体、历史与扫描文档、报纸、财务报表及关键信息抽取。" width="100%"></p>
**中文文档**
<p align="center"><img src="https://raw.githubusercontent.com/OpenBMB/MiniCPM-OCR/main/assets/minicpm-ocr/minicpm-ocr-chinese-cases.png" alt="中文示例的输入与结果对比:手写笔记、复杂公式、报纸、财务报表、盖章文档、插图及关键信息抽取。" width="100%"></p>
</details>
## 模型架构
| 项目 | 说明 || :--- | :--- || 参数量 | 1.3B || 基座 | 在 MiniCPM-V 4.6 基础上针对 OCR 训练 || 组件 | SigLIP 视觉编码器 + Qwen3.5 语言模型 || 主要语言 | 中文、英文 || 任务 | 文字、表格、公式、图表、印章和关键信息抽取 || 解析流程 | MiniCPM-OCR 1.0 + PP-DocLayoutV3 版面模型 + `minicpmvocr` SDK || 视觉 token | 4× 压缩,`scale_resolution` 448,最多 9 个切片 |
### 解析流程
整页解析由 [`minicpm-ocr` SDK](https://pypi.org/project/minicpm-ocr/) 统一编排为**两阶段流水线**:两个阶段使用不同的模型、运行在相互独立的环境中,也可以部署在不同的机器上:
- **阶段一 · 版面检测(SDK 环境)**:PP-DocLayoutV3 版面模型检测文档区域(文字、表格、公式、图表、印章等)并确定阅读顺序,SDK 按区域切块。该阶段在 SDK 环境中本地运行,依赖 PaddlePaddle / PaddleX。- **阶段二 · 区域识别(推理服务)**:SDK 通过 HTTP 将每个切块发送给 MiniCPM-OCR 1.0 推理服务(由 vLLM、SGLang、llama.cpp 或 Ollama 部署),提示词按区域类型选择,最后按阅读顺序拼接为 Markdown / JSON。
<p align="center"><img src="https://huggingface.co/openbmb/MiniCPM-OCR-1.0/resolve/main/assets/parsing_pipeline.svg" alt="解析流程图:在 minicpm-ocr SDK 环境中,PP-DocLayoutV3 版面模型检测并切分文档区域;每个切块通过 HTTP 发送给独立的 MiniCPM-OCR 1.0 识别服务(vLLM、SGLang、llama.cpp 或 Ollama);SDK 再按阅读顺序拼接为 Markdown 与 JSON。" width="90%"></p>
更多关于架构、解析流程、部署方式和评测拆解,见[模型指南](https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/minicpm_ocr_1dot0_en.md)。
## 快速开始
### 在线体验
要快速体验以文字为中心的文档理解与结构化信息抽取,推荐使用 [HF Spaces](https://huggingface.co/spaces/openbmb/MiniCPM-OCR)、[CN](http://82.157.64.212:10111/playground/document-parse)、[官方国内](https://platform.modelbest.cn/console/playground/document-parse)、[官方海外](https://platform.modelbest.ai/console/playground/document-parse) / [API](https://platform.modelbest.ai/console/docs/api/document-parse)。
### 使用 MiniCPM-OCR SDK
> **使用 CLI 或 Python API 前的必要步骤:** 请先部署并启动 OCR 模型服务,等待其可以正常接收请求。下面的 SDK 示例是该服务的客户端,不会自动部署或启动 OCR 模型服务。
使用官方 `minicpm-ocr` SDK 解析本地图片或 PDF:它会用 PP-DocLayoutV3 检测版面、逐区域识别,并按阅读顺序保存结构化 JSON 和 Markdown。
安装 Python 3.10+ 与 SDK:
```bashpip install "minicpm-ocr[all]"```
按你的平台参考[安装指南](https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/minicpm_ocr_tutorial_en.md#1-set-up-the-sdk-environment)安装 minicpm-ocr。
#### 前置条件:部署并启动模型服务
在运行 CLI 或 Python API 之前,请先按[部署指南](https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/minicpm_ocr_tutorial_en.md#3-start-the-service)为 `openbmb/MiniCPM-OCR-1.0` 部署并启动一个 vLLM 识别服务。示例假设服务地址为 `http://127.0.0.1:8080`、服务模型名为 `minicpm-ocr`、版面检测使用 NVIDIA GPU。请按实际部署调整地址、后端与设备;若希望示例无需改动即可运行,请把服务配置为监听 `8080` 端口并以 `minicpm-ocr` 作为模型名。
#### CLI
**运行以下命令前,请先启动上文所述的模型服务并等待其就绪。** 将一张本地图片保存为 `demo.png`,然后执行:
```bashminicpmvocr parse demo.png \ --backend vllm \ --server-url http://127.0.0.1:8080 \ --model minicpm-ocr \ --device cuda:0 \ --set run.run_root=output \ --output output/demo.md```
CLI 会在需要时自动把 PP-DocLayoutV3 下载到 `models/PP-DocLayoutV3_infer/`。最终 Markdown 保存到 `output/demo.md`;结构化 JSON 和逐页 Markdown 保存在 `output/<run_tag>/results_json/` 与 `output/<run_tag>/output/`。
解析 PDF 时,把 `demo.png` 换成本地 PDF 路径即可。使用 `--device cpu` 可在 CPU 上做版面检测。运行 `minicpmvocr parse --help` 查看全部 CLI 选项。
#### Python API
**执行本 Python 示例前,上文所述的模型服务必须已经在运行。** 请把 `engine.server_url` 和 `engine.model_name` 设置为与该服务一致。
将一张本地图片保存为 `demo.png`,然后执行:
```pythonfrom importlib.resources import filesfrom pathlib import Path
from minicpmvocr import load_config, pipelined_runfrom minicpmvocr.layouts.download import ensure_layout_model
def main(): layout_model = ensure_layout_model(Path("models/PP-DocLayoutV3_infer"))
cfg = load_config( str(files("minicpmvocr").joinpath("configs/minicpmvocr.yaml")), overrides={ "input": {"file_path": str(Path("demo.png").resolve())}, "engine": { "type": "vllm", "server_url": "http://127.0.0.1:8080", "model_name": "minicpm-ocr", }, "layout": { "model_dir": str(layout_model), "device": "cuda:0", }, "pipeline": {"overlap_layout": True}, "run": {"run_root": str(Path("output").resolve())}, }, )
pipelined_run(cfg)
print("JSON directory:", cfg["_meta"]["result_json_dir"]) print("Markdown directory:", cfg["_meta"]["output_dir"])
if __name__ == "__main__": main()```
`ensure_layout_model()` 会在缺失时下载官方版面模型。结果写入 `output/<run_tag>/results_json/` 和 `output/<run_tag>/output/`。解析 PDF 时,把 `demo.png` 换成本地 PDF 路径即可。
若要在 CPU 上做版面检测,把 `layout.device` 设为 `cpu`。若使用 llama.cpp 提供的 [GGUF 权重](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-gguf),把 `engine.type` 设为 `llamacpp`,并用 `engine.max_model_len` 匹配服务的上下文长度。
配置说明与文档级 Markdown 导出见 [SDK API 参考](https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/minicpm_ocr_sdk_api_en.md)。
### Agent Skill
也可以让编码 Agent 按 [Agent Skill](https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/SKILL_en.md) 配置环境、下载模型并解析第一篇文档。
```textRead and execute https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/SKILL_en.md```
### 模型微调
[LLaMA-Factory](https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/llamafactory_minicpm_ocr_french_en.md) · [ms-swift](https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/swift_minicpm_ocr_french_en.md) —— 数据准备、冻结多模态投影器的全参数 SFT、训练与评测(法文手写文本行)。
### 识别指南
<table> <thead> <tr> <th>任务</th> <th>区域</th> <th>提示词</th> <th>输出</th> </tr> </thead> <tbody> <tr> <td rowspan="6">以文字为中心的文档理解</td> <td>文本块 / 段落 / 标题 / 页面</td> <td><code>Text Recognition:</code></td> <td>纯文本</td> </tr> <tr> <td>表格</td> <td><code>Table Recognition:</code></td> <td>HTML 表格(SDK 后处理)</td> </tr> <tr> <td>公式</td> <td><code>Formula Recognition:</code></td> <td>LaTeX</td> </tr> <tr> <td>行内公式</td> <td><code>Text Recognition:</code></td> <td>LaTeX</td> </tr> <tr> <td>印章</td> <td><code>Seal Recognition:</code></td> <td>纯文本</td> </tr> <tr> <td>图表</td> <td><code>Chart to Table:</code></td> <td>HTML 表格(SDK 后处理)</td> </tr> <tr> <td>结构化信息抽取</td> <td>指定字段</td> <td><code>Extract the "field", .... Format the output as a JSON object with keys: "field", .... If an item is not in the image, use "###".</code></td> <td>JSON</td> </tr> </tbody></table>
## 相关权重
| 格式 | Hugging Face | ModelScope || :--- | :--- | :--- || BF16(原始)**(本仓库)** | [🤗](https://huggingface.co/openbmb/MiniCPM-OCR-1.0) | [ModelScope](https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-1.0) || GGUF(llama.cpp) | [🤗](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-gguf) | [ModelScope](https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-1.0-gguf) || AWQ W4A16 | [🤗](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-AWQ) | [ModelScope](https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-1.0-AWQ) || GPTQ W4A16 | [🤗](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-GPTQ) | [ModelScope](https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-1.0-GPTQ) || DSpark 草稿模型(BF16) | [🤗](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-DSpark) | [ModelScope](https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-1.0-DSpark) || DSpark 草稿模型(GGUF) | [🤗](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-DSpark-gguf) | [ModelScope](https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-1.0-DSpark-gguf) |
DSpark **要求主模型与草稿模型来自同一发布版本** —— 不要把草稿权重与其他主权重混用。详见 [DSpark 加速](https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/minicpm_ocr_tutorial_en.md#3-start-the-service)。
如需对 OCR 质量进行评估(自动接受、人工复核路由、跨模型 best-of-N),参见 [MiniCPM-OCR Jev](https://huggingface.co/openbmb/MiniCPM-OCR-Jev)。
## 常见问题
安装、模型下载、显存、输入格式与异常输出:[FAQ](https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/faq_en.md)。
## 许可
模型权重、代码与文档均按 [Apache License 2.0](https://github.com/OpenBMB/MiniCPM-OCR/blob/main/LICENSE) 发布。README.md+41-1
README_zh.mdAdded+326