Fast, accurate OCR with correctness assessment.
update deploy skill
赵寻96900cf3cef8
diff --git a/README.md b/README.mdindex 9ac422c..f6f41ed 100644--- a/README.md+++ b/README.md@@ -7,7 +7,7 @@<p align="center"><a href="./docs/minicpm_ocr_1dot0_en.md"><strong>MiniCPM-OCR 1.0 Guide</strong></a> <a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0" title="Hugging Face"><img src="./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="./assets/minicpm-ocr/modelscope_logo_padded.svg" width="25" height="14" alt="ModelScope"></a> - <a href="./docs/minicpm_ocr_jev_en.md"><strong>MiniCPM-OCR Jev Guide</strong></a> <a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev" title="Hugging Face"><img src="./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="./assets/minicpm-ocr/modelscope_logo_padded.svg" width="25" height="14" alt="ModelScope"></a>+ <a href="./docs/minicpm_ocr_jev_en.md"><strong>MiniCPM-OCR Jev Guide</strong></a> <a href="https://huggingface.co/openbmb/MiniCPM-OCR-Jev" title="Hugging Face"><img src="./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="./assets/minicpm-ocr/modelscope_logo_padded.svg" width="25" height="14" alt="ModelScope"></a></p><p align="center">@@ -139,7 +139,13 @@ Ask a coding agent to follow the MiniCPM-OCR 1.0 [skill](./docs/SKILL_en.md) toRead and execute https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/SKILL_en.md```-If you have already cloned this repository, you can use `./docs/SKILL_en.md` directly.+Ask a coding agent to follow the MiniCPM-OCR Jev [skill](./docs/SKILL_jev_en.md) to deploy, start, and verify the scoring service locally, with vLLM, SGLang, llama.cpp, or Ollama as the inference backend. Send the following instruction to the agent:++```text+Read and execute https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/SKILL_jev_en.md+```++If you have already cloned this repository, you can use `./docs/SKILL_en.md` and `./docs/SKILL_jev_en.md` directly.<a id="api"></a>@@ -189,7 +195,7 @@ Run the models on your own hardware: MiniCPM-OCR 1.0 parses PDFs and images into<tr><td nowrap>MiniCPM‑OCR <strong>Jev</strong></td><td width="360">An OCR correctness decision model for text, formulas, and tables. Given an image and its OCR result, it returns a quality score from 0 to 1.</td>-<td align="center" valign="middle" colspan="2"><a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>BF16</strong> <a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev-gguf">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-gguf"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>GGUF</strong><br><a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev-AWQ">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-AWQ"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>AWQ</strong> <a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev-GPTQ">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-GPTQ"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>GPTQ</strong></td>+<td align="center" valign="middle" colspan="2"><a href="https://huggingface.co/openbmb/MiniCPM-OCR-Jev">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>BF16</strong> <a href="https://huggingface.co/openbmb/MiniCPM-OCR-Jev-gguf">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-gguf"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>GGUF</strong><br><a href="https://huggingface.co/openbmb/MiniCPM-OCR-Jev-AWQ">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-AWQ"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>AWQ</strong> <a href="https://huggingface.co/openbmb/MiniCPM-OCR-Jev-GPTQ">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-GPTQ"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>GPTQ</strong></td></tr></table>diff --git a/README_zh.md b/README_zh.mdindex f3459d9..b501af3 100644--- a/README_zh.md+++ b/README_zh.md@@ -7,7 +7,7 @@<p align="center"><a href="./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="./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="./assets/minicpm-ocr/modelscope_logo_padded.svg" width="25" height="14" alt="ModelScope"></a> - <a href="./docs/minicpm_ocr_jev_zh.md"><strong>MiniCPM-OCR Jev 模型指南</strong></a> <a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev" title="Hugging Face"><img src="./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="./assets/minicpm-ocr/modelscope_logo_padded.svg" width="25" height="14" alt="ModelScope"></a>+ <a href="./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="./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="./assets/minicpm-ocr/modelscope_logo_padded.svg" width="25" height="14" alt="ModelScope"></a></p><p align="center">@@ -137,7 +137,13 @@Read and execute https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/SKILL.md```-已克隆本仓库时,也可直接使用 `./docs/SKILL.md`。+让编码 Agent 按 MiniCPM-OCR Jev [skill](./docs/SKILL_jev.md) 完成打分服务的本地部署、启动和验证,支持 vLLM、SGLang、llama.cpp 和 Ollama 四个推理后端。将以下指令发送给 Agent:++```text+Read and execute https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/SKILL_jev.md+```++已克隆本仓库时,也可直接使用 `./docs/SKILL.md` 和 `./docs/SKILL_jev.md`。<a id="api"></a>@@ -187,7 +193,7 @@ Read and execute https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/SKILL.md<tr><td nowrap>MiniCPM‑OCR <strong>Jev</strong></td><td width="360">面向文本、公式和表格的 OCR 正确性判别模型,输入图像及 OCR 结果即可获得 0–1 的质量评分。</td>-<td align="center" valign="middle" colspan="2"><a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>BF16</strong> <a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev-gguf">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-gguf"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>GGUF</strong><br><a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev-AWQ">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-AWQ"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>AWQ</strong> <a href="https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev-GPTQ">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-GPTQ"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>GPTQ</strong></td>+<td align="center" valign="middle" colspan="2"><a href="https://huggingface.co/openbmb/MiniCPM-OCR-Jev">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>BF16</strong> <a href="https://huggingface.co/openbmb/MiniCPM-OCR-Jev-gguf">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-gguf"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>GGUF</strong><br><a href="https://huggingface.co/openbmb/MiniCPM-OCR-Jev-AWQ">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-AWQ"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>AWQ</strong> <a href="https://huggingface.co/openbmb/MiniCPM-OCR-Jev-GPTQ">🤗</a> <a href="https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-GPTQ"><img src="./assets/minicpm-ocr/modelscope_logo.png" width="20" alt="ModelScope"></a> <strong>GPTQ</strong></td></tr></table>diff --git a/docs/SKILL_jev.md b/docs/SKILL_jev.mdnew file mode 100644index 0000000..eff0f67--- /dev/null+++ b/docs/SKILL_jev.md@@ -0,0 +1,451 @@+---+name: minicpm-ocr-jev-sdk+description: 安装、部署和验证 MiniCPM-OCR Jev 打分服务(SDK 本地部署,vLLM / SGLang / llama.cpp / Ollama 四个推理后端)。在用户要装 Jev SDK、起打分服务、给 OCR 结果打一致性分数或在多个候选里选优、排查起服与打分报错时使用。+---++# MiniCPM-OCR Jev SDK 本地部署++Jev 判断一段 OCR 文本与原图是否一致:送原图与候选文本,返回 0–1 的一致性分数。SDK 部署把渲染器与模型服务分开装在主机上——引擎做前向,服务层做打分,两者必须在不同的虚拟环境里。++本文的命令与 `docs/{vllm,sglang,llamacpp,ollama}_deploy_jev_zh.md` 同源,每节都标了对应文档的小节;改任一方需同步。想用 Docker 而不是 SDK 的话走 `minicpm_ocr_jev_tutorial_zh.md` 的方式一,本 skill 不覆盖。++## 1. 确定方案++先问清两件事:**用哪个推理后端**、**渲染图由谁提供**。用户没有偏好时用 vLLM + 内置渲染器。++按渲染图来源分两种形态,用同一个模型、同一套打分代码:++| | 不带渲染器服务 | 内置渲染器服务 |+|---|---|---|+| 渲染图 | 由调用方提供 | 服务自己渲染(也可由调用方提供) |+| 渲染环境 | **不需要**,无 Chromium、Node、字体 | 需要 |+| 接口 | `/v1/score`,返回 `prob_1` | `/v1/rm/score*`,返回 `prob_yes`,与 Docker 镜像同构 |+| 功能 | 逐条打分 | 逐条打分、块内选优、批量选优,带 precheck |+| 启动脚本 | `sdk/start_score.sh` | `sdk/start_render_score.sh` |++四个后端的环境成本相差很大,按用户的约束选:++| 后端 | 系统 CUDA toolkit | 要编译 | 引擎环境体积 | 可用平台 | 适合 |+|---|---|---|---|---|---|+| vLLM | 不需要 | 否 | 8.4 GB | 仅 Linux + NVIDIA | 默认选择,吞吐最好 |+| SGLang | **需要** | 否 | 9.5 GB | 仅 Linux + NVIDIA | 已有 SGLang 技术栈 |+| llama.cpp | **需要**(仅 Linux) | **是** | 214 MB(build) | Linux + NVIDIA/macOS | 显存小、不想装 torch |+| Ollama | 不需要 | 否 | 转换环境 4.8 GB | Linux + NVIDIA/macOS | 要求最轻,已有 Ollama |++- llama.cpp 与 Ollama 都要先把权重转成 GGUF,转换环境(CPU 版 torch)4.8 GB,转完可删。+- Ollama 跑的就是 llama.cpp 的 runner,两者分数同源,**不要拿它们互相验证**。+- ⭐ **用户在 macOS(Apple Silicon)上时只有 llama.cpp 与 Ollama 两条路**:vLLM 与 SGLang 依赖 CUDA 栈,mac 上起不来,不要建议。两者在 mac 上都走 Metal,命令与 Linux 的差别见 5.3/5.4。+- ⭐ **macOS 上只做不带渲染器服务**:内置渲染器服务要固定字体环境,那一步依赖 apt,mac 上做不到(见 6.2)。++## 2. 安装前检查++```bash+# Linux + NVIDIA+nvidia-smi # 驱动 ≥535+nvidia-smi --query-compute-apps=pid,used_memory --format=csv # 找一张空闲卡+df -h . # vLLM/SGLang 留 ≥15 GB++# macOS+sysctl -n machdep.cpu.brand_string # 须为 Apple M 系列+sysctl -n hw.memsize # 统一内存 ≥16 GB+xcode-select -p # Command Line Tools 已装+python3 -V # 系统自带的是 3.9,不够,须另装 ≥3.10+df -h .+```++显存门槛随后端而变:vLLM ≥12 GB,SGLang ≥16 GB,llama.cpp 与 Ollama ≥8 GB。macOS 上对应统一内存 ≥16 GB。++需要用户提供的东西(没有给出时先问,不要猜):++| 占位符 | 含义 |+|---|---|+| `<WEIGHTS>` | Jev 权重目录的绝对路径;用户没有现成副本时按第 3 节下载 |+| `<GPU>` | 用哪张卡(先按上面的命令确认它空闲);macOS 上不适用 |++以下命令都在仓库的 `scripts/minicpm-ocr-jev/` 下执行,虚拟环境建在 `/opt/venv-*`;macOS 上往 `/opt` 写要 sudo,建在 home 目录下即可(`~/venv-*`),后面各处路径跟着换。++## 3. 取源码、权重与系统前置包++部署文档从 `cd scripts/minicpm-ocr-jev/` 开始,前提是本机已有仓库:++```bash+git clone https://github.com/OpenBMB/MiniCPM-OCR.git+cd MiniCPM-OCR/scripts/minicpm-ocr-jev+```++权重=[MiniCPM-OCR-Jev](https://huggingface.co/openbmb/MiniCPM-OCR-Jev),四个后端共用同一份(llama.cpp 与 Ollama 再从它转 GGUF)。用户已有副本时跳过本步,把它的绝对路径当 `<WEIGHTS>`:++```bash+python3 -m venv /opt/venv-dl && /opt/venv-dl/bin/pip install -U "huggingface_hub[cli]"+HF_ENDPOINT=https://hf-mirror.com /opt/venv-dl/bin/hf download openbmb/MiniCPM-OCR-Jev \+ --local-dir ./models/MiniCPM-OCR-Jev+```++- 下完 `<WEIGHTS>` 即 `$PWD/models/MiniCPM-OCR-Jev`,目录应含 `config.json`、`model.safetensors`、`tokenizer.json`、`preprocessor_config.json`、`chat_template.jinja`。+- 已有 `hf` 命令时直接用,不必建 `/opt/venv-dl`;装进系统 Python 会被 PEP 668 拒绝(见第 9 节)。这个 venv 下完即可删。+- ModelScope:`modelscope download --model OpenBMB/MiniCPM-OCR-Jev --local_dir ./models/MiniCPM-OCR-Jev`。++系统包按后端装(对应各文档「环境要求」):++```bash+# vLLM / SGLang+sudo apt-get install -y python3 python3-venv python3-pip curl gcc g++ python3-dev+# llama.cpp+sudo apt-get install -y python3 python3-venv python3-pip git curl cmake build-essential+# Ollama+sudo apt-get install -y python3 python3-venv python3-pip curl++# macOS + llama.cpp:编译器与 git 来自 Command Line Tools,CMake 另装+xcode-select --install+brew install cmake++# macOS + Ollama:不需要任何系统包,只要有一个 ≥3.10 的 Python+```++- `gcc`、`g++`、`python3-dev` 是 **runtime** 依赖,vLLM 与 SGLang 都在首次前向时现场编译 Triton 扩展,装完不要删。+- 慢网下先给 pip 指一个就近镜像,否则引擎环境的 8–9 GB 依赖会卡死:++```bash+export PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple+```++通过标准:`python3 -V` ≥ 3.10,`gcc -dumpversion` 有输出(llama.cpp 另需 `cmake --version` ≥3.14)。macOS 上不查 `gcc -dumpversion`,改查 `xcode-select -p` 有输出。++## 4. 探测上游支持(动手装之前先做)++**四个后端里有两个的本模型支持是晚近才进上游的**,装之前先确认手上这个版本有。探针都是结构性的——查注册表、查源码、查起服自检:++| 后端 | 探什么 | 什么时候能探 |+|---|---|---|+| vLLM | `Qwen3_5ForConditionalGeneration` 在模型注册表里 | `serve/setup_backend.sh` 装完自动报,不必手动探 |+| SGLang | `Qwen3_5VLForSequenceClassification` 在模型注册表里 | 装完 `sglang[all]` 之后 |+| llama.cpp | 源码里有 `COMMON_DECISION_TYPE_MINICPM_OCR_JEV` | **clone 之后、编译之前** |+| Ollama | 起服自检通过 | 装完、转完 GGUF、注册完之后 |++```bash+# SGLang+/opt/venv-sglang/bin/python -c "+from sglang.srt.models.registry import ModelRegistry+print('Qwen3_5VLForSequenceClassification' in ModelRegistry.models)"++# llama.cpp(在 clone 出来的源码树里)+grep -rq COMMON_DECISION_TYPE_MINICPM_OCR_JEV tools/server/ && echo supported || echo NOT+```++⚠ **不要用版本号判断,也不要相信引擎的能力自报**:++- `ollama show` 的 Capabilities 在 runner 完全不支持时**照样报 `decision, vision` 两项全绿**——它读的是 GGUF 元数据,不是 runner 的能力。+- SGLang 的版本号不告诉你架构有没有注册。+- 探针返回 `False` / `NOT` 时走[第 8 节](#8-上游未就位时的临时路径),**不要删掉已装好的环境**——临时路径复用它。++## 5. 装引擎并启动++四个引擎的端口都用 18499(文档默认值)。一台机器上同时起多个后端时错开端口,并把服务层的引擎地址跟着改。++### 5.1 vLLM(对应 `vllm_deploy_jev_zh.md` 一)++```bash+bash serve/setup_backend.sh /opt/venv-vllm+PATH=/opt/venv-vllm/bin:$PATH bash sdk/start_engine.sh <GPU> 18499 <WEIGHTS>+```++- `setup_backend.sh` 自己会检查系统包,缺了就打印可直接粘贴的 apt 命令并退出。+- 这个脚本不是 `serve/start_vllm.sh`:镜像那条路径传 pass-through 模板、自己拼 prompt,SDK 这条路径发交错 content list、让模型自带模板渲染。混用会被起服自检拦住。++通过标准:装完打印 `Qwen3_5ForConditionalGeneration registered`;起服日志出现 `Application startup complete.`(首次启动要过 torch.compile 与 CUDA graph,约 2 分钟)。++### 5.2 SGLang(对应 `sglang_deploy_jev_zh.md` 一)++SGLang 要系统装一套完整 CUDA toolkit,**并且让它能被找到**——`deep_gemm` 在 import 期就会去找:++```bash+export CUDA_HOME=/usr/local/cuda # 或指向实际路径+export PATH=$CUDA_HOME/bin:$PATH++python3 -m venv /opt/venv-sglang && source /opt/venv-sglang/bin/activate+pip install "sglang[all]"+```++虚拟环境里 pip 装进来的 `nvidia-*` 包不能代替系统 toolkit。装完做[第 4 节](#4-探测上游支持动手装之前先做)的 SGLang 探针,再起引擎:++```bash+python -m sglang.launch_server \+ --model-path <WEIGHTS> \+ --is-embedding \+ --json-model-override-args '{"architectures": ["Qwen3_5VLForSequenceClassification"]}' \+ --port 18499+```++- `--is-embedding`:走池化路径,不加就没有 `/classify` 可调。+- `--json-model-override-args`:权重 `config.json` 写的是生成类时需要它,覆盖成分类类才会返回 value head 的两个 logit。`config.json` 本身已写 `Qwen3_5VLForSequenceClassification` 时可省略。+- 不要加 `--chat-template`:SGLang 不套模板,SDK 直接发拼好的整串 prompt。++通过标准:日志出现 `The server is fired up and ready to roll!`;`curl http://127.0.0.1:18499/get_model_info` 里 `architectures` 是 `["Qwen3_5VLForSequenceClassification"]`。++### 5.3 llama.cpp(对应 `llamacpp_deploy_jev_zh.md` 一)++```bash+git clone https://github.com/ggml-org/llama.cpp.git && cd llama.cpp++python3 -m venv /opt/venv-convert && source /opt/venv-convert/bin/activate+pip install -r requirements/requirements-convert_hf_to_gguf.txt+```++转换依赖必须装进单独的 venv——Debian/Ubuntu 等会按 PEP 668 拒绝装进系统 Python。装完先做[第 4 节](#4-探测上游支持动手装之前先做)的 grep 探针,再编译:++```bash+# 配置,按平台二选一+# Linux + NVIDIA+cmake -B build -DGGML_CUDA=ON -DCMAKE_BUILD_TYPE=Release+# macOS:Metal 后端默认启用,不需要任何额外开关+cmake -B build -DCMAKE_BUILD_TYPE=Release++cmake --build build -j --target llama-server+```++configure 日志里出现 `Including METAL backend`(mac)或 `Including CUDA backend`(Linux)才算后端挂上了。++**仅 Linux**:CUDA toolkit 装在 `/usr/local/cuda` 之外时,先把它的库注册进 `ldconfig`,否则链接 `llama-server` 时会报几十个 `undefined reference to [email protected]`:++```bash+echo /path/to/cuda/lib64 | sudo tee /etc/ld.so.conf.d/cuda.conf && sudo ldconfig+```++转 GGUF(语言模型与视觉编码器各一份,**两份都要从改过 `architectures` 的目录转**):++```bash+mkdir -p ./models/MiniCPM-OCR-Jev-gguf+for f in <WEIGHTS>/*; do+ [ "$(basename "$f")" = config.json ] || ln -sf "$f" ./models/MiniCPM-OCR-Jev-gguf/+done+python - <<'EOF'+import json, os+c = json.load(open(os.environ["W"] + "/config.json"))+c["architectures"] = ["MiniCPMOCRForSequenceClassification"]+json.dump(c, open("./models/MiniCPM-OCR-Jev-gguf/config.json", "w"), indent=2, ensure_ascii=False)+EOF++python convert_hf_to_gguf.py ./models/MiniCPM-OCR-Jev-gguf \+ --outtype bf16 --outfile ./models/MiniCPM-OCR-Jev-bf16.gguf+python convert_hf_to_gguf.py ./models/MiniCPM-OCR-Jev-gguf --mmproj \+ --outtype bf16 --outfile ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf+```++(上面那段 heredoc 前先 `export W=<WEIGHTS>`。)`mmproj` 从转换目录转才会带上与训练一致的图片缩放下限,否则小图分数偏。++```bash+./build/bin/llama-server \+ -m ./models/MiniCPM-OCR-Jev-bf16.gguf \+ --mmproj ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf \+ -ngl 99 -c 32768 --port 18499+```++通过标准:转出 3.6 GB + 641 MB 两份 GGUF;起服日志出现 `decision model type: openbmb-minicpm-ocr-jev` 与 `listening on`;`curl http://127.0.0.1:18499/health` 返回 `{"status":"ok"}`。两个平台同此标准。日志里**没有**那行 `decision model type` 就是这个构建不认模型,回[第 4 节](#4-探测上游支持动手装之前先做)。++### 5.4 Ollama(对应 `ollama_deploy_jev_zh.md` 一)++四个后端里要求最轻的一条:不装 CUDA toolkit,也不编译任何东西。但**要先按 5.3 把 GGUF 转出来**(只需 clone + 装转换依赖,跳过编译)。++```bash+# Linux+curl -fsSL https://ollama.com/install.sh | sh+# macOS+brew install ollama++cat > Modelfile <<'EOF'+FROM ./models/MiniCPM-OCR-Jev-bf16.gguf+FROM ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf+EOF++ollama serve & # 默认 11434+ollama create minicpm-ocr-jev -f Modelfile+ollama show minicpm-ocr-jev+```++模型名 `minicpm-ocr-jev` 要与 `sdk/backends/ollama.yaml` 里的 `model` 一致,改名则两处同改。++通过标准:**只有起服自检能确认这个后端可用**(见[第 7 节](#7-验证))。`ollama show` 报 `decision, vision` 只说明 GGUF 转对了,runner 认不认它不负责。两个平台同此标准,macOS 上的 Ollama 也走 llama.cpp + Metal。++## 6. 装服务层并启动++两种形态二选一,不要都起。引擎地址按第 5 节实际用的端口填。++### 6.1 不带渲染器服务(对应各文档 二)++```bash+python3 -m venv /opt/venv-score && source /opt/venv-score/bin/activate+pip install "fastapi>=0.110" "uvicorn>=0.27" "httpx>=0.27" "pydantic>=2.6" "PyYAML>=6.0" "Pillow==12.3.0"+```++```bash+PATH=/opt/venv-score/bin:$PATH bash sdk/start_score.sh 18501 http://127.0.0.1:18499+```++### 6.2 内置渲染器服务(对应各文档 三)++```bash+PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple \+PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright \+ bash sdk/setup_render.sh /opt/venv-render+```++它装 Node、CJK 字体、Chromium 与服务依赖,并把字体环境固定下来(约 2.5 分钟,205 MB)。++⚠ **macOS 上不要起这个服务**:装 Node 与 CJK 字体、固定字体环境这几步都靠 `apt-get`,mac 上会跳过。渲染图是模型输入,字体栈一换分数就换,打出来的分不能与发布值对照。mac 上用 6.1 的不带渲染器服务,渲染图由调用方提供。++```bash+PATH=/opt/venv-render/bin:$PATH bash sdk/start_render_score.sh 18500 http://127.0.0.1:18499+```++必须用 `/opt/venv-render` 这个解释器启动——渲染在本进程内完成。要提吞吐调 `RM_RENDER_BROWSERS`,不要加 worker。++### 6.3 vLLM 以外的后端要指定后端配置++```bash+JEV_BACKEND_CONFIG=sdk/backends/sglang.yaml \+PATH=/opt/venv-score/bin:$PATH bash sdk/start_score.sh 18501 http://127.0.0.1:18499+```++把 `sglang.yaml` 换成 `llamacpp.yaml` / `ollama.yaml`。**不设这个变量时服务按 vLLM 协议发请求**:SGLang 那边连得上但分数不可用,llama.cpp 与 Ollama 那边端点对不上、起服即失败。++## 7. 验证++### 7.1 起服自检++```bash+curl -s http://127.0.0.1:18501/healthz+```++只看 `status`,`ok` 即通过。其余字段是明细,各后端的正常值不同:++| 后端 | `prompt.source` | `forward_shape` | 说明 |+|---|---|---|---|+| vLLM | `engine` | `2 logits` | 引擎拼的 prompt 被逐项校过 |+| SGLang | `client` | `2 logits` | prompt 由 SDK 拼,校的是即将发出的字符串 |+| llama.cpp / Ollama | `server_template` | `2 probabilities` | 模板内置在 GGUF 里,读不回来,prompt 不校 |++`token_equality` 为 `skipped` 是跳过不是失败。`status` 不是 `ok` 时读 `prompt.notes` 或 `error`——它会带上引擎的原话。++### 7.2 用自带用例打分++自检只说明服务起得来,分数对不对要用 `examples/` 下三个用例核:++```bash+python3 - <<'EOF'+import base64, json, urllib.request+for name in ("01_text_putnam", "02_formula_putnam", "03_table_gb_standard"):+ c = json.load(open(f"examples/{name}/case.json"))+ role = c["reference_render_of"]+ text = next(x["text"] for x in c["candidates"] if x["role"] == role)+ b64 = lambda f: base64.b64encode(open(f"examples/{name}/{f}", "rb").read()).decode()+ body = {"items": [{"original_image": b64(c["block_image"]),+ "render_image": b64(c["reference_render"]), "ocr_text": text}]}+ req = urllib.request.Request("http://127.0.0.1:18501/v1/score",+ data=json.dumps(body).encode(), headers={"Content-Type": "application/json"})+ got = json.load(urllib.request.urlopen(req))["results"][0]["prob_1"]+ print(f"{name:24} got {got:.5f} reference {c['observed_prob_yes'][role]:.5f}")+EOF+```++通过标准:三行分数与参考值相差都在 0.02 以内。**这是判断"装对了"的唯一客观标准**——HTTP 200 不是,`/healthz` 也不是。++内置渲染器服务换成 `/v1/rm/score_best`、请求体给 `image` + `category` + `candidates`,服务自己渲染;两个候选都打,`best_index` 应指向 `ground_truth` 那个。++打分前必看 `verdict`(镜像接口)或 `error`(`/v1/score`):`0.0` 与 `-1.0` 是打分失败的固定返回值,不是低分。++## 8. 上游未就位时的临时路径++```+验证日期:2026-10-28+当时的上游状态:SGLang PR #45829 未合入主仓;Ollama 最新 release v0.40.11/v0.40.12 捆绑的是 llama.cpp 0.7.x,不含本模型支持+失效条件:第 4 节的探针通过,本节即可整段删除+```++⚠ 走本节装出来的东西**与部署文档承诺的不是同一条路径**,要向用户明说走了临时路径、上游就位后应按官方路径重装。若今天的上游版本已不同于上面记录的,先重新验证再用本节。++### 8.1 SGLang:用 PR 源码树覆盖++**保留 `sglang[all]` 装好的全部依赖**(sgl-kernel、flashinfer 等都要用),只换 python 包:++```bash+source /opt/venv-sglang/bin/activate+pip uninstall -y sglang+cd <sglang PR 源码树>/python+SGLANG_BUILD_RUST_EXTS=none pip install -e . --no-build-isolation+```++`SGLANG_BUILD_RUST_EXTS=none` 是必需的:构建后端会去找 `cargo`,没有 Rust 工具链就直接失败。装完重做探针,应返回 `True`。++### 8.2 Ollama:成套换 runner++Ollama 发行版是预编译捆绑的,带的是它自己 vendor 的 llama.cpp。把 runner 换成 5.3 编出来的产物:++```bash+O=/usr/local/lib/ollama # install.sh 的默认位置+L=<llama.cpp>/build/bin+cp -a $O/llama-server $O/llama-server.stock # 备份+ln -sfn $L/llama-server $O/+for f in $L/lib*.so*; do ln -sfn "$f" "$O/$(basename "$f")"; done+ln -sfn $L/libggml-cuda.so $O/cuda_v13/libggml-cuda.so+```++⚠ **只换那个二进制无效**:原装 `llama-server` 只有 15 KB,模型支持在 `libllama-server-impl.so` 等共享库里。只换二进制仍然跑得起来、仍然报同样的错,据此会得出"换了也不行"的相反结论。++⚠ 这个换法**跨过了 Ollama 自己的兼容补丁**,为什么能跨过未查清;Ollama 升级后要重新验证。换完重起 `ollama serve` 与服务层,自检应为 `ok`。++## 9. 报错处理++### 安装++| 现象 | 处理 |+|---|---|+| `missing system packages: gcc g++ python3-dev` | `setup_backend.sh` 的自检,照它打印的 apt 命令装 |+| pip 装几分钟一个包都没下完 | 没设镜像源,见第 3 节 |+| `error: externally-managed-environment` | PEP 668,转换依赖要装进单独 venv(5.3),不要装进系统 Python |+| `RuntimeError: cargo is required to discover the Rust extension modules` | 装 SGLang PR 源码树时漏了 `SGLANG_BUILD_RUST_EXTS=none` |+| `undefined reference to [email protected]`(约 60 个) | CUDA 库没注册进 ldconfig,见 5.3 |++### 起引擎++| 现象 | 处理 |+|---|---|+| `AssertionError` 在 `deep_gemm/cuda_helpers.py: find_cuda_home` | SGLang 找不到系统 CUDA toolkit,设 `CUDA_HOME`(5.2) |+| `RuntimeError: Failed to find C compiler`,**权重已经加载完** | Triton 要现场编译,装 `gcc g++ python3-dev`(第 3 节) |+| `ValueError: Cannot find model module. 'Qwen3_5VLForSequenceClassification' is not a registered model` | SGLang 这个版本没有本模型支持,走 8.1 |+| 起服后进程被 kill、日志末尾 `EXIT=137` | 往上翻日志找真实异常,137 只是被 SIGKILL |+| `failed to init decision model: unsupported decision model type` | 这个 llama.cpp / Ollama runner 不认模型,走 8.2 或换 ≥v0.8.0 的 llama.cpp |+| llama.cpp 日志没有 `decision model type` 那行 | 同上 |++### 起服务与打分++| 现象 | 处理 |+|---|---|+| `refusing to start: the engine does not assemble the prompt this checkpoint was trained on` | 自检拦下了。读同一段报错里引擎的原话——通常是引擎参数错或 runner 不支持 |+| `backend HTTP 500: llama-server process has terminated` | 引擎侧挂了,去 `ollama serve` / `llama-server` 自己的日志看 |+| 起服卡在 `Waiting for application startup.` | 自检正在打引擎,等;超过两分钟去看引擎日志 |+| 分数全是 `0.0` 或 `-1.0` | 不是低分,是打分失败的固定返回值,读 `verdict` / `error` |+| 分数能打出来但与参考值差很多 | `category` 填错(公式块送成 `text` 会按字面渲染);或 `mmproj` 不是从改过 `architectures` 的目录转的 |+| 分数只差小数点后第三位 | 自装渲染器与镜像渲染器的像素差异,排序不变,属正常 |+| 换了后端分数对不上 | 跨后端比绝对分要用同一批输入先对齐;Ollama 与 llama.cpp 同源,不算独立验证 |++## 10. 已验证版本++| 组件 | 版本 |+|---|---|+| vLLM | vLLM 0.32.0,torch 2.13.0+cu130,transformers 5.19.0,venv 8.4 GB |+| SGLang | 稳定版 0.5.22 **无本模型支持**;PR #45829 源码树可用,venv 9.5 GB |+| llama.cpp | release **v0.8.0**(含 PR #30980,2026-10-27 合入 master),build 214 MB |+| Ollama | v0.40.11 原装 **无本模型支持**,换 runner 后可用 |+| 服务层 | Python 3.12.3,fastapi 0.162.0,uvicorn 0.54.0,httpx 0.28.1,pydantic 2.14.1,Pillow 12.3.0,venv 59 MB |+| 渲染环境 | playwright 1.62.0,KaTeX 0.16.47,渲染流水线 v8.5,venv 205 MB |+| GGUF | 语言模型 3.6 GB + mmproj 641 MB |+| 硬件 | RTX 5090 单卡,驱动 590.48.01,CUDA 13.0.88,Ubuntu 24.04.5(2026-10-28) |+| macOS | Apple M5/16 GB 统一内存/macOS 26.x,Command Line Tools 26.6.0,llama.cpp v0.8.0 自编(Metal),转换依赖 torch 2.11.0 arm64 + transformers 4.57.6(2026-10-29) |++## 11. 汇报规则++- 5090 与 M5 都只是验证用的机器,不要说必须用某一款。门槛是第 2 节那几个数。+- 只汇报实际跑过的检查。没跑 7.2 就不要说分数对;`/healthz` 返回 `ok` 只能说服务起来了。+- 走了第 8 节的临时路径时必须明说,并说清它与文档路径的差别。+- 四个后端的分数不要互相当作独立验证,Ollama 与 llama.cpp 尤其——它们跑的是同一个二进制。+- 分数只能当排序量用。不要替用户解释某个绝对分代表什么质量水平。diff --git a/docs/SKILL_jev_en.md b/docs/SKILL_jev_en.mdnew file mode 100644index 0000000..2900201--- /dev/null+++ b/docs/SKILL_jev_en.md@@ -0,0 +1,455 @@+---+name: minicpm-ocr-jev-sdk+description: Install, deploy and verify the MiniCPM-OCR Jev scoring service (SDK local deployment, four inference backends: vLLM / SGLang / llama.cpp / Ollama). Use when the user wants to install the Jev SDK, start a scoring service, score OCR output for consistency or pick the best of several candidates, or troubleshoot startup and scoring errors.+---++# MiniCPM-OCR Jev SDK local deployment++Jev judges whether a piece of OCR text matches the original image: send the original image and the candidate text, get back a consistency score between 0 and 1. The SDK deployment installs the renderer and the model service separately on the host — the engine does the forward pass, the service layer does the scoring, and the two must live in different virtual environments.++The commands here come from the same source as `docs/{vllm,sglang,llamacpp,ollama}_deploy_jev_en.md`, and every section names the section of those documents it mirrors; change one side and the other must follow. If the user wants Docker rather than the SDK, go to path one in `minicpm_ocr_jev_tutorial_en.md`; this skill does not cover it.++## 1. Determine the plan++First settle two things: **which inference backend**, and **who provides the render image**. If the user has no preference, use vLLM plus the render+score service.++There are two service shapes, split by where the render image comes from; both use the same model and the same scoring code:++| | Score service | Render+score service |+|---|---|---|+| Render image | Provided by the caller | Rendered by the service (the caller may also provide it) |+| Render environment | **Not needed** — no Chromium, Node or fonts | Needed |+| Endpoint | `/v1/score`, returns `prob_1` | `/v1/rm/score*`, returns `prob_yes`, identical to the Docker image |+| Features | Scoring only | Scoring, best-of-N within a block, batched best-of-N, with precheck |+| Start script | `sdk/start_score.sh` | `sdk/start_render_score.sh` |++The four backends differ a lot in what they cost to set up; pick by the user's constraints:++| Backend | System CUDA toolkit | Compiles | Engine environment size | Platforms | Suited to |+|---|---|---|---|---|---|+| vLLM | Not needed | No | 8.4 GB | Linux + NVIDIA only | Default choice, best throughput |+| SGLang | **Needed** | No | 9.5 GB | Linux + NVIDIA only | An existing SGLang stack |+| llama.cpp | **Needed** (Linux only) | **Yes** | 214 MB (build) | Linux + NVIDIA / macOS | Small VRAM, no torch wanted |+| Ollama | Not needed | No | 4.8 GB conversion env | Linux + NVIDIA / macOS | Lightest requirements, an existing Ollama |++- llama.cpp and Ollama both need the weights converted to GGUF first; the conversion environment (CPU torch) is 4.8 GB and can be deleted afterwards.+- Ollama runs llama.cpp's own runner, so their scores share one source — **do not use one to verify the other**.+- ⭐ **On macOS (Apple Silicon) only llama.cpp and Ollama are available**: vLLM and SGLang depend on the CUDA stack and will not start on a mac, so do not suggest them. Both macOS paths go through Metal; where the commands differ from Linux is covered in 5.3 / 5.4.+- ⭐ **On macOS only run the score service**: the render+score service needs a pinned font environment, and that step depends on apt, which is not available on a mac (see 6.2).++## 2. Pre-installation checks++```bash+# Linux + NVIDIA+nvidia-smi # driver ≥535+nvidia-smi --query-compute-apps=pid,used_memory --format=csv # find an idle GPU+df -h . # leave ≥15 GB for vLLM/SGLang++# macOS+sysctl -n machdep.cpu.brand_string # must be Apple M series+sysctl -n hw.memsize # unified memory ≥16 GB+xcode-select -p # Command Line Tools installed+python3 -V # the system one is 3.9, too old; install ≥3.10 separately+df -h .+```++The VRAM floor depends on the backend: vLLM ≥12 GB, SGLang ≥16 GB, llama.cpp and Ollama ≥8 GB. On macOS that translates to ≥16 GB of unified memory.++Things the user has to supply (ask when they are not given; do not guess):++| Placeholder | Meaning |+|---|---|+| `<WEIGHTS>` | Absolute path of the Jev weights directory; download it as in section 3 when the user has no copy |+| `<GPU>` | Which GPU to use (confirm it is idle with the commands above); not applicable on macOS |++Every command below runs under `scripts/minicpm-ocr-jev/` in the repository, with the virtual environments created in `/opt/venv-*`; on macOS writing to `/opt` needs sudo, so put them under the home directory instead (`~/venv-*`) and adjust the paths that follow.++## 3. Source, weights and system packages++The deployment documents start at `cd scripts/minicpm-ocr-jev/`, which assumes the repository is already on the machine:++```bash+git clone https://github.com/OpenBMB/MiniCPM-OCR.git+cd MiniCPM-OCR/scripts/minicpm-ocr-jev+```++The weights are [MiniCPM-OCR-Jev](https://huggingface.co/openbmb/MiniCPM-OCR-Jev), one copy shared by all four backends (llama.cpp and Ollama convert their GGUF from it). Skip this step when the user already has a copy, and take its absolute path as `<WEIGHTS>`:++```bash+python3 -m venv /opt/venv-dl && /opt/venv-dl/bin/pip install -U "huggingface_hub[cli]"+HF_ENDPOINT=https://hf-mirror.com /opt/venv-dl/bin/hf download openbmb/MiniCPM-OCR-Jev \+ --local-dir ./models/MiniCPM-OCR-Jev+```++- `<WEIGHTS>` is then `$PWD/models/MiniCPM-OCR-Jev`, and the directory should contain `config.json`, `model.safetensors`, `tokenizer.json`, `preprocessor_config.json` and `chat_template.jinja`.+- If `hf` is already available, use it directly instead of creating `/opt/venv-dl`; installing into the system Python is refused under PEP 668 (see section 9). That venv can be deleted once the download finishes.+- ModelScope: `modelscope download --model OpenBMB/MiniCPM-OCR-Jev --local_dir ./models/MiniCPM-OCR-Jev`.++System packages depend on the backend (this mirrors the "Requirements" section of each document):++```bash+# vLLM / SGLang+sudo apt-get install -y python3 python3-venv python3-pip curl gcc g++ python3-dev+# llama.cpp+sudo apt-get install -y python3 python3-venv python3-pip git curl cmake build-essential+# Ollama+sudo apt-get install -y python3 python3-venv python3-pip curl++# macOS + llama.cpp: the compiler and git come with the Command Line Tools; CMake is separate+xcode-select --install+brew install cmake++# macOS + Ollama: no system packages needed, all it takes is a Python ≥3.10+```++- `gcc`, `g++` and `python3-dev` are **runtime** dependencies: both vLLM and SGLang compile Triton extensions on the first forward pass, so do not remove them after installing.+- On a slow network, point pip at a nearby mirror first, or the 8–9 GB of engine dependencies will stall:++```bash+export PIP_INDEX_URL=https://<your-mirror>/simple+# in mainland China, for example: https://mirrors.ustc.edu.cn/pypi/simple+```++Pass criteria: `python3 -V` is ≥ 3.10 and `gcc -dumpversion` prints something (llama.cpp additionally needs `cmake --version` ≥3.14). On macOS do not check `gcc -dumpversion`; check that `xcode-select -p` prints something instead.++## 4. Probe upstream support (do this before installing anything)++**Support for this model reached upstream only recently in two of the four backends**, so confirm the version at hand has it before installing. The probes are all structural — look in the model registry, in the source, or at the startup self-check:++| Backend | What to probe | When it can be probed |+|---|---|---|+| vLLM | `Qwen3_5ForConditionalGeneration` is in the model registry | Reported automatically once `serve/setup_backend.sh` finishes; no manual probe needed |+| SGLang | `Qwen3_5VLForSequenceClassification` is in the model registry | After `sglang[all]` is installed |+| llama.cpp | `COMMON_DECISION_TYPE_MINICPM_OCR_JEV` is in the source | **After the clone, before the build** |+| Ollama | The startup self-check passes | After installing, converting the GGUF and registering the model |++```bash+# SGLang+/opt/venv-sglang/bin/python -c "+from sglang.srt.models.registry import ModelRegistry+print('Qwen3_5VLForSequenceClassification' in ModelRegistry.models)"++# llama.cpp (inside the cloned source tree)+grep -rq COMMON_DECISION_TYPE_MINICPM_OCR_JEV tools/server/ && echo supported || echo NOT+```++⚠ **Do not judge by version number, and do not trust what the engine reports about its own capabilities**:++- `ollama show` reports `decision, vision` **both green even when the runner has no support at all** — it reads the GGUF metadata, not the runner's capabilities.+- An SGLang version number tells you nothing about whether the architecture is registered.+- When a probe returns `False` / `NOT`, go to [section 8](#8-temporary-path-while-upstream-support-is-missing), and **do not delete the environment you already installed** — the temporary path reuses it.++## 5. Install and start the engine++All four engines use port 18499 (the documents' default). When several backends run on one machine, stagger the ports and change the engine address in the service layer to match.++### 5.1 vLLM (mirrors `vllm_deploy_jev_en.md` §1)++```bash+bash serve/setup_backend.sh /opt/venv-vllm+PATH=/opt/venv-vllm/bin:$PATH bash sdk/start_engine.sh <GPU> 18499 <WEIGHTS>+```++- `setup_backend.sh` checks the system packages itself; if any are missing it prints a ready-to-paste apt command and exits.+- This script is not `serve/start_vllm.sh`: the image path passes a pass-through template and assembles the prompt itself, while the SDK path sends an interleaved content list and lets the model's own template render it. Mixing them is caught by the startup self-check.++Pass criteria: the install prints `Qwen3_5ForConditionalGeneration registered`; the startup log reaches `Application startup complete.` (the first start goes through torch.compile and CUDA graph capture, about 2 minutes).++### 5.2 SGLang (mirrors `sglang_deploy_jev_en.md` §1)++SGLang needs a full CUDA toolkit installed system-wide, **and it has to be findable** — `deep_gemm` looks for it at import time:++```bash+export CUDA_HOME=/usr/local/cuda # or the actual path+export PATH=$CUDA_HOME/bin:$PATH++python3 -m venv /opt/venv-sglang && source /opt/venv-sglang/bin/activate+pip install "sglang[all]"+```++The `nvidia-*` packages pip pulls into the virtual environment are no substitute for the system toolkit. Once this finishes, run the SGLang probe from [section 4](#4-probe-upstream-support-do-this-before-installing-anything), then start the engine:++```bash+python -m sglang.launch_server \+ --model-path <WEIGHTS> \+ --is-embedding \+ --json-model-override-args '{"architectures": ["Qwen3_5VLForSequenceClassification"]}' \+ --port 18499+```++- `--is-embedding`: takes the pooling path; without it there is no `/classify` to call.+- `--json-model-override-args`: needed when the weights' `config.json` names a generative class — overriding it to the classification class is what makes the two value-head logits come back. It can be omitted when `config.json` already says `Qwen3_5VLForSequenceClassification`.+- Do not add `--chat-template`: SGLang applies no template, the SDK sends the fully assembled prompt string.++Pass criteria: the log reaches `The server is fired up and ready to roll!`; `curl http://127.0.0.1:18499/get_model_info` shows `architectures` as `["Qwen3_5VLForSequenceClassification"]`.++### 5.3 llama.cpp (mirrors `llamacpp_deploy_jev_en.md` §1)++```bash+git clone https://github.com/ggml-org/llama.cpp.git && cd llama.cpp++python3 -m venv /opt/venv-convert && source /opt/venv-convert/bin/activate+pip install -r requirements/requirements-convert_hf_to_gguf.txt+```++The conversion dependencies have to go into their own venv — Debian/Ubuntu and others refuse to install into the system Python under PEP 668. Run the grep probe from [section 4](#4-probe-upstream-support-do-this-before-installing-anything) before building:++```bash+# Configure; pick the line for your platform+# Linux + NVIDIA+cmake -B build -DGGML_CUDA=ON -DCMAKE_BUILD_TYPE=Release+# macOS: the Metal backend is on by default, no extra switch needed+cmake -B build -DCMAKE_BUILD_TYPE=Release++cmake --build build -j --target llama-server+```++The backend is only attached if the configure log says `Including METAL backend` (mac) or `Including CUDA backend` (Linux).++**Linux only**: when the CUDA toolkit lives somewhere other than `/usr/local/cuda`, register its libraries with `ldconfig` first, otherwise linking `llama-server` produces dozens of `undefined reference to [email protected]`:++```bash+echo /path/to/cuda/lib64 | sudo tee /etc/ld.so.conf.d/cuda.conf && sudo ldconfig+```++Convert to GGUF (one file for the language model and one for the vision encoder; **both have to be converted from the directory with the patched `architectures`**):++```bash+mkdir -p ./models/MiniCPM-OCR-Jev-gguf+for f in <WEIGHTS>/*; do+ [ "$(basename "$f")" = config.json ] || ln -sf "$f" ./models/MiniCPM-OCR-Jev-gguf/+done+python - <<'EOF'+import json, os+c = json.load(open(os.environ["W"] + "/config.json"))+c["architectures"] = ["MiniCPMOCRForSequenceClassification"]+json.dump(c, open("./models/MiniCPM-OCR-Jev-gguf/config.json", "w"), indent=2, ensure_ascii=False)+EOF++python convert_hf_to_gguf.py ./models/MiniCPM-OCR-Jev-gguf \+ --outtype bf16 --outfile ./models/MiniCPM-OCR-Jev-bf16.gguf+python convert_hf_to_gguf.py ./models/MiniCPM-OCR-Jev-gguf --mmproj \+ --outtype bf16 --outfile ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf+```++(Run `export W=<WEIGHTS>` before that heredoc.) Converting `mmproj` from the conversion directory is what carries over the image downscale floor the model was trained with; otherwise small images score off.++```bash+./build/bin/llama-server \+ -m ./models/MiniCPM-OCR-Jev-bf16.gguf \+ --mmproj ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf \+ -ngl 99 -c 32768 --port 18499+```++Pass criteria: the conversion produces two GGUF files of 3.6 GB and 641 MB; the startup log shows `decision model type: openbmb-minicpm-ocr-jev` and `listening on`; `curl http://127.0.0.1:18499/health` returns `{"status":"ok"}`. Same criteria on both platforms. If that `decision model type` line is **missing**, this build does not know the model — go back to [section 4](#4-probe-upstream-support-do-this-before-installing-anything).++### 5.4 Ollama (mirrors `ollama_deploy_jev_en.md` §1)++The lightest of the four: no CUDA toolkit, and nothing to compile. But **the GGUF files from 5.3 have to exist first** (only the clone and the conversion dependencies are needed there; the build can be skipped).++```bash+# Linux+curl -fsSL https://ollama.com/install.sh | sh+# macOS+brew install ollama++cat > Modelfile <<'EOF'+FROM ./models/MiniCPM-OCR-Jev-bf16.gguf+FROM ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf+EOF++ollama serve & # 11434 by default+ollama create minicpm-ocr-jev -f Modelfile+ollama show minicpm-ocr-jev+```++The model name `minicpm-ocr-jev` has to match `model` in `sdk/backends/ollama.yaml`; rename in one place and you rename in both.++Pass criteria: **only the startup self-check can confirm this backend works** (see [section 7](#7-verification)). `ollama show` reporting `decision, vision` only says the GGUF conversion was right; it says nothing about whether the runner knows the model. Same criteria on both platforms — Ollama on macOS also runs llama.cpp plus Metal.++## 6. Install and start the service layer++Pick one of the two shapes; do not start both. Fill in the engine address with the port actually used in section 5.++### 6.1 Score service (mirrors §2 of each document)++```bash+python3 -m venv /opt/venv-score && source /opt/venv-score/bin/activate+pip install "fastapi>=0.110" "uvicorn>=0.27" "httpx>=0.27" "pydantic>=2.6" "PyYAML>=6.0" "Pillow==12.3.0"+```++```bash+PATH=/opt/venv-score/bin:$PATH bash sdk/start_score.sh 18501 http://127.0.0.1:18499+```++### 6.2 Render+score service (mirrors §3 of each document)++```bash+PIP_INDEX_URL=https://<your-mirror>/simple \+PLAYWRIGHT_DOWNLOAD_HOST=https://<your-playwright-mirror> \+ bash sdk/setup_render.sh /opt/venv-render+# in mainland China, for example:+# PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple+# PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright+```++It installs Node, CJK fonts, Chromium and the service dependencies, and pins the font environment down (about 2.5 minutes, 205 MB).++⚠ **Do not start this service on macOS**: installing Node and the CJK fonts and pinning the font environment all rely on `apt-get`, and those steps are skipped on a mac. The render image is model input, so a different font stack means different scores, and what you measure cannot be compared against the published values. On a mac use the score service from 6.1 and have the caller provide the render image.++```bash+PATH=/opt/venv-render/bin:$PATH bash sdk/start_render_score.sh 18500 http://127.0.0.1:18499+```++It must be started with the `/opt/venv-render` interpreter — rendering happens inside this process. For more throughput raise `RM_RENDER_BROWSERS`; do not add workers.++### 6.3 Backends other than vLLM need a backend config++```bash+JEV_BACKEND_CONFIG=sdk/backends/sglang.yaml \+PATH=/opt/venv-score/bin:$PATH bash sdk/start_score.sh 18501 http://127.0.0.1:18499+```++Replace `sglang.yaml` with `llamacpp.yaml` / `ollama.yaml`. **Without that variable the service speaks the vLLM protocol**: SGLang will connect but the scores are unusable, while llama.cpp and Ollama expose different endpoints and the service fails to start.++## 7. Verification++### 7.1 Startup self-check++```bash+curl -s http://127.0.0.1:18501/healthz+```++Look at `status` only; `ok` means it passed. The other fields are details, and what counts as normal differs by backend:++| Backend | `prompt.source` | `forward_shape` | Note |+|---|---|---|---|+| vLLM | `engine` | `2 logits` | The prompt the engine assembled was checked field by field |+| SGLang | `client` | `2 logits` | The SDK assembles the prompt; what is checked is the string about to be sent |+| llama.cpp / Ollama | `server_template` | `2 probabilities` | The template is baked into the GGUF and cannot be read back, so the prompt is not checked |++`token_equality` being `skipped` means skipped, not failed. When `status` is not `ok`, read `prompt.notes` or `error` — it carries the engine's own words.++### 7.2 Score the bundled cases++The self-check only says the service starts; whether the scores are right is settled by the three cases under `examples/`:++```bash+python3 - <<'EOF'+import base64, json, urllib.request+for name in ("01_text_putnam", "02_formula_putnam", "03_table_gb_standard"):+ c = json.load(open(f"examples/{name}/case.json"))+ role = c["reference_render_of"]+ text = next(x["text"] for x in c["candidates"] if x["role"] == role)+ b64 = lambda f: base64.b64encode(open(f"examples/{name}/{f}", "rb").read()).decode()+ body = {"items": [{"original_image": b64(c["block_image"]),+ "render_image": b64(c["reference_render"]), "ocr_text": text}]}+ req = urllib.request.Request("http://127.0.0.1:18501/v1/score",+ data=json.dumps(body).encode(), headers={"Content-Type": "application/json"})+ got = json.load(urllib.request.urlopen(req))["results"][0]["prob_1"]+ print(f"{name:24} got {got:.5f} reference {c['observed_prob_yes'][role]:.5f}")+EOF+```++Pass criterion: all three scores are within 0.02 of the reference. **This is the only objective test of "it is installed correctly"** — HTTP 200 is not, and neither is `/healthz`.++For the render+score service, switch to `/v1/rm/score_best` and give the body `image` plus `category` plus `candidates`; the service renders on its own. Both candidates get scored, and `best_index` should point at the `ground_truth` one.++Before reading any score, check `verdict` (the Docker-image-shaped endpoints) or `error` (`/v1/score`): `0.0` and `-1.0` are the fixed return values for a failed scoring, not low scores.++## 8. Temporary path while upstream support is missing++```+Verified on: 2026-10-28+Upstream state at the time: SGLang PR #45829 not merged into the main repository; the latest Ollama releases v0.40.11/v0.40.12 bundle llama.cpp 0.7.x, which has no support for this model+Expiry condition: once the probes in section 4 pass, this whole section can be deleted+```++⚠ What this section installs is **not the path the deployment documents promise**. Tell the user plainly that a temporary path was taken and that it should be reinstalled the official way once upstream catches up. If today's upstream versions differ from the ones recorded above, verify again before using this section.++### 8.1 SGLang: override with the PR source tree++**Keep everything `sglang[all]` installed** (sgl-kernel, flashinfer and the rest are all still used); replace only the python package:++```bash+source /opt/venv-sglang/bin/activate+pip uninstall -y sglang+cd <sglang PR source tree>/python+SGLANG_BUILD_RUST_EXTS=none pip install -e . --no-build-isolation+```++`SGLANG_BUILD_RUST_EXTS=none` is required: the build backend goes looking for `cargo` and fails outright without a Rust toolchain. Run the probe again afterwards; it should return `True`.++### 8.2 Ollama: swap the runner as a set++An Ollama release is a precompiled bundle carrying its own vendored llama.cpp. Replace the runner with what 5.3 built:++```bash+O=/usr/local/lib/ollama # install.sh's default location+L=<llama.cpp>/build/bin+cp -a $O/llama-server $O/llama-server.stock # back it up+ln -sfn $L/llama-server $O/+for f in $L/lib*.so*; do ln -sfn "$f" "$O/$(basename "$f")"; done+ln -sfn $L/libggml-cuda.so $O/cuda_v13/libggml-cuda.so+```++⚠ **Replacing only that binary does nothing**: the stock `llama-server` is just 15 KB, and the model support lives in shared libraries such as `libllama-server-impl.so`. With only the binary replaced it still starts and still raises the same error, which leads to the opposite conclusion — that swapping does not help.++⚠ This swap **steps over Ollama's own compatibility patches**, and why it can be stepped over has not been established; re-verify after any Ollama upgrade. Restart `ollama serve` and the service layer afterwards; the self-check should be `ok`.++## 9. Error handling++### Installation++| Symptom | What to do |+|---|---|+| `missing system packages: gcc g++ python3-dev` | `setup_backend.sh`'s own check; install with the apt command it printed |+| pip runs for minutes without finishing a single package | No mirror configured, see section 3 |+| `error: externally-managed-environment` | PEP 668; the conversion dependencies go into their own venv (5.3), not into the system Python |+| `RuntimeError: cargo is required to discover the Rust extension modules` | `SGLANG_BUILD_RUST_EXTS=none` was left out when installing the SGLang PR source tree |+| `undefined reference to [email protected]` (about 60 of them) | The CUDA libraries are not registered with ldconfig, see 5.3 |++### Starting the engine++| Symptom | What to do |+|---|---|+| `AssertionError` in `deep_gemm/cuda_helpers.py: find_cuda_home` | SGLang cannot find the system CUDA toolkit; set `CUDA_HOME` (5.2) |+| `RuntimeError: Failed to find C compiler`, **with the weights already loaded** | Triton compiles on the spot; install `gcc g++ python3-dev` (section 3) |+| `ValueError: Cannot find model module. 'Qwen3_5VLForSequenceClassification' is not a registered model` | This SGLang version has no support for the model, go to 8.1 |+| The process is killed after startup, log ends with `EXIT=137` | Scroll up for the real exception; 137 only means SIGKILL |+| `failed to init decision model: unsupported decision model type` | This llama.cpp / Ollama runner does not know the model; go to 8.2 or move to llama.cpp ≥v0.8.0 |+| The llama.cpp log has no `decision model type` line | Same as above |++### Starting the service and scoring++| Symptom | What to do |+|---|---|+| `refusing to start: the engine does not assemble the prompt this checkpoint was trained on` | The self-check stopped it. Read the engine's own words in the same error — usually a wrong engine argument or an unsupported runner |+| `backend HTTP 500: llama-server process has terminated` | The engine side died; look at `ollama serve` / `llama-server`'s own log |+| Startup hangs at `Waiting for application startup.` | The self-check is calling the engine; wait, and check the engine log if it goes past two minutes |+| Every score is `0.0` or `-1.0` | Not low scores — these are the fixed return values for a failed scoring; read `verdict` / `error` |+| Scores come back but are far from the reference | Wrong `category` (a formula block sent as `text` is rendered literally); or `mmproj` was not converted from the directory with the patched `architectures` |+| Scores differ only in the third decimal | Pixel differences between the self-installed renderer and the image's renderer; the ranking is unchanged, this is normal |+| Scores do not line up after switching backends | Comparing absolute scores across backends requires aligning on one set of inputs first; Ollama and llama.cpp share a source and do not count as independent verification |++## 10. Verified versions++| Component | Version |+|---|---|+| vLLM | vLLM 0.32.0, torch 2.13.0+cu130, transformers 5.19.0, venv 8.4 GB |+| SGLang | Stable 0.5.22 has **no support for this model**; the PR #45829 source tree works, venv 9.5 GB |+| llama.cpp | Release **v0.8.0** (includes PR #30980, merged into master on 2026-10-27), build 214 MB |+| Ollama | Stock v0.40.11 has **no support for this model**; works after the runner swap |+| Service layer | Python 3.12.3, fastapi 0.162.0, uvicorn 0.54.0, httpx 0.28.1, pydantic 2.14.1, Pillow 12.3.0, venv 59 MB |+| Render environment | playwright 1.62.0, KaTeX 0.16.47, render pipeline v8.5, venv 205 MB |+| GGUF | Language model 3.6 GB + mmproj 641 MB |+| Hardware | Single RTX 5090, driver 590.48.01, CUDA 13.0.88, Ubuntu 24.04.5 (2026-10-28) |+| macOS | Apple M5 / 16 GB unified memory / macOS 26.x, Command Line Tools 26.6.0, llama.cpp v0.8.0 built from source (Metal), conversion dependencies torch 2.11.0 arm64 + transformers 4.57.6 (2026-10-29) |++## 11. Reporting rules++- The 5090 and the M5 are only the machines this was verified on; do not say either one is required. The floors are the numbers in section 2.+- Report only the checks that actually ran. Without 7.2 do not say the scores are right; `/healthz` returning `ok` only says the service came up.+- When the temporary path in section 8 was taken, say so explicitly and spell out how it differs from the documented path.+- Do not treat the four backends' scores as independent verification of one another, least of all Ollama and llama.cpp — they run the same binary.+- The scores are an ordering quantity only. Do not interpret an absolute score as some level of quality on the user's behalf.diff --git a/docs/llamacpp_deploy_jev_en.md b/docs/llamacpp_deploy_jev_en.mdindex 40ad92a..e3f1562 100644--- a/docs/llamacpp_deploy_jev_en.md+++ b/docs/llamacpp_deploy_jev_en.md@@ -6,7 +6,7 @@This document covers the SDK deployment path with llama.cpp's `llama-server` as the forward engine: how to install, start, and call the **score service** and the **render+score service**.-llama.cpp is a lightweight inference backend written in C++. Two things set it apart from the other backends: the model has to be converted to GGUF first, and the prompt is assembled by the engine from a template baked into the GGUF rather than by the SDK.+This backend differs from the others in two ways: the model has to be converted to GGUF first, and the prompt is assembled by the engine from a template baked into the GGUF rather than by the SDK.Both services share one forward engine. The only difference is where the render image comes from:@@ -29,40 +29,70 @@ The engine and the service must go into two separate virtual environments; do no## Requirements-- **GPU**: NVIDIA, ≥8GB VRAM-- **Driver**: ≥535-- **CUDA Toolkit**: ≥12.0-- **CMake**: ≥3.14-- **C++ compiler**: C++17 (GCC ≥9)-- **Python**: ≥3.10-- **llama.cpp**: latest stable release-- **Pinned versions**: `Pillow` 12.3.0, `playwright` 1.62.0 (render+score service only)+| | Linux + NVIDIA | macOS (Apple Silicon) |+| -------------- | ---------------------------------------------------------- | -------------------------------- |+| Accelerator | NVIDIA, ≥8GB VRAM | M-series chip, ≥16GB unified memory |+| Driver | ≥535 | Not needed; Metal ships with the OS |+| CUDA Toolkit | ≥12.0 | Not needed |+| Build tools | CMake ≥3.14, GCC ≥9 | Xcode Command Line Tools, CMake |+| Backend switch | `-DGGML_CUDA=ON` | None; Metal is on by default |+| Python | ≥3.10 | ≥3.10; the system one is 3.9, install your own |+| llama.cpp | ≥ v0.8.0, the release support for this model lands in | Same |+| Pinned versions | `Pillow` 12.3.0, `playwright` 1.62.0 (render+score service only) | `Pillow` 12.3.0 |++**CUDA Toolkit** (Linux only): make sure the linker can find its libraries. When it lives outside `/usr/local/cuda`, register it with `ldconfig`:++```bash+echo /path/to/cuda/lib64 | sudo tee /etc/ld.so.conf.d/cuda.conf+sudo ldconfig+```++**System packages**:++```bash+# Linux+sudo apt-get install -y python3 python3-venv python3-pip git curl cmake build-essential++# macOS: the compiler and git come with the Command Line Tools; CMake is separate+xcode-select --install+brew install cmake+```---## 1. Forward engine-### Build+### Source and conversion dependencies++Two things, both needed: fetch the source (used for the build and for the GGUF conversion), and install the Python dependencies the conversion needs.```bashgit clone https://github.com/ggml-org/llama.cpp.git && cd llama.cpp-cmake -B build -DGGML_CUDA=ON -DCMAKE_BUILD_TYPE=Release-cmake --build build -j --target llama-server++# A virtual environment can live anywhere; the same goes for every /opt/venv-* below.+# macOS: writing to /opt needs sudo, so put it under your home directory, e.g. ~/venv-convert+python3 -m venv /opt/venv-convert+source /opt/venv-convert/bin/activatepip install -r requirements/requirements-convert_hf_to_gguf.txt```-The last line installs the Python dependencies the GGUF conversion needs. The list ships with the llama.cpp repository and pulls in:+The conversion dependencies go into a virtual environment of their own: Debian/Ubuntu and friends refuse installs into the system Python. On a slow network add `-i https://<your-mirror>/simple` (in mainland China, for example `https://mirrors.ustc.edu.cn/pypi/simple`).-```text-torch 2.11.0 (from download.pytorch.org/whl/cpu — conversion needs no GPU)-transformers 4.57.6-numpy ~=2.2.6-sentencepiece >=0.1.98,<0.3.0-gguf >=0.1.0-protobuf >=4.21.0,<5.0.0+### Build++```bash+cd llama.cpp++# Configure; pick the line for your platform+# Linux + NVIDIA+cmake -B build -DGGML_CUDA=ON -DCMAKE_BUILD_TYPE=Release+# macOS: the Metal backend is on by default, no extra switch needed+cmake -B build -DCMAKE_BUILD_TYPE=Release++cmake --build build -j --target llama-server```-These are used only during conversion and have nothing to do with the two service environments below, so any environment will do.+If you only need the GGUF conversion and not the engine (for example when Ollama runs the forward pass), skip this step — conversion is pure Python and does not need the build artifacts.### Convert to GGUF@@ -70,6 +100,7 @@ Convert the language model and the vision encoder (`mmproj`) separately. The con```bashcd llama.cpp+source /opt/venv-convert/bin/activatemkdir -p ./models/MiniCPM-OCR-Jev-gguffor f in ./models/MiniCPM-OCR-Jev/*; do[ "$(basename "$f")" = config.json ] || ln -sf "$PWD/$f" ./models/MiniCPM-OCR-Jev-gguf/@@ -103,7 +134,7 @@ cd llama.cpp```- `--mmproj`: the vision encoder GGUF. Without it there is only the text path and the two images cannot get in.-- `-ngl 99`: put every layer on the GPU.+- `-ngl 99`: put every layer on the GPU — the same flag on macOS, where it maps to Metal.- `-c 32768`: context length, shared by the parallel slots.- `-np N`: serve N requests in parallel.@@ -118,12 +149,13 @@ You already have the render image and only want the score.### Install```bash+# Same on macOS, except that /opt needs sudo — use ~/venv-score insteadpython3 -m venv /opt/venv-scoresource /opt/venv-score/bin/activatepip install "fastapi>=0.110" "uvicorn>=0.27" "httpx>=0.27" "pydantic>=2.6" "PyYAML>=6.0" "Pillow==12.3.0"```-**Reference dependency versions**+**Reference dependency versions** (the same set on Linux and macOS)```textpython 3.12.3@@ -183,8 +215,6 @@ All three fields are required: `original_image` is the base64 of the original blYou only have candidate text and want the service to render before scoring. Precheck, render and forward all happen in this one process.-This service calls the scoring layer in-process: it does **not** need a separate score service running, and does not need a port reserved for one.-### Install```bash@@ -192,13 +222,20 @@ cd scripts/minicpm-ocr-jev/bash sdk/setup_render.sh /opt/venv-render```-It installs Node, CJK fonts, Chromium and the service dependencies. On a slow network, point it at two mirrors:+It installs Node, CJK fonts, Chromium and the service dependencies.++> **This section is Linux only.** The script relies on `apt-get` to install Node and the CJK fonts and to pin the font environment to the one the reference deployment uses; on macOS those steps are skipped. Rendered text is model input, and a different font stack means different scores, so **scores produced by this service on macOS cannot be compared against the published numbers**. On macOS use the score service from the previous section (you provide the render image), or switch to the Docker image.++On a slow network, point it at two mirrors:```bashcd scripts/minicpm-ocr-jev/-PIP_INDEX_URL=https://<mirror>/simple \-PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \+PIP_INDEX_URL=https://<your-mirror>/simple \+PLAYWRIGHT_DOWNLOAD_HOST=https://<your-playwright-mirror> \bash sdk/setup_render.sh /opt/venv-render+# in mainland China, for example:+# PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple+# PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright```### Start@@ -279,4 +316,28 @@ curl -s http://127.0.0.1:18501/healthzLook at `status` only: `ok` means the self-check passed and the service is ready. The other fields under `prompt` are self-check details, and the shape above is what a healthy one looks like. When `status` is not `ok`, `prompt.notes` says which part failed.-`source` reading `server_template`, `last_token` reading `null` and `token_equality` reading `skipped` are the normal values for this backend, not a fault. One consequence for how the numbers may be read: the scale of this leg's scores can only be established by comparing it against a known backend on the same inputs.+`source` reading `server_template`, `last_token` reading `null` and `token_equality` reading `skipped` are the normal values for this backend, not a fault. One consequence for how the numbers may be read: the scale of this backend's scores can only be established by comparing it against a known backend on the same inputs.++### Verify with the bundled cases++This backend's self-check does not verify the prompt (see above), so this step must not be skipped: score the three cases under `examples/` and compare against the reference score `observed_prob_yes` in each `case.json`:++```bash+cd scripts/minicpm-ocr-jev+python3 - <<'EOF'+import base64, json, urllib.request+for name in ("01_text_putnam", "02_formula_putnam", "03_table_gb_standard"):+ c = json.load(open(f"examples/{name}/case.json"))+ role = c["reference_render_of"]+ text = next(x["text"] for x in c["candidates"] if x["role"] == role)+ b64 = lambda f: base64.b64encode(open(f"examples/{name}/{f}", "rb").read()).decode()+ body = {"items": [{"original_image": b64(c["block_image"]),+ "render_image": b64(c["reference_render"]), "ocr_text": text}]}+ req = urllib.request.Request("http://127.0.0.1:18501/v1/score",+ data=json.dumps(body).encode(), headers={"Content-Type": "application/json"})+ got = json.load(urllib.request.urlopen(req))["results"][0]["prob_1"]+ print(f"{name:24} got {got:.5f} reference {c['observed_prob_yes'][role]:.5f}")+EOF+```++All three scores within 0.02 of the reference is normal, on Linux and macOS alike. For the render+score service, change the endpoint to `/v1/rm/score_best` and the body to `image` plus `candidates` (see [3. Render+score service · Request](#request-1)); the service renders on its own — that variant is only compared against the reference scores on Linux, for the reason given at the top of that section.diff --git a/docs/llamacpp_deploy_jev_zh.md b/docs/llamacpp_deploy_jev_zh.mdindex baccb56..29c79fe 100644--- a/docs/llamacpp_deploy_jev_zh.md+++ b/docs/llamacpp_deploy_jev_zh.md@@ -6,7 +6,7 @@本文介绍SDK部署模式下,以 llama.cpp 的 `llama-server` 作为前向引擎时,**不带渲染器服务**与**内置渲染器服务**的安装、启动、接口与请求格式。-llama.cpp 是 C++ 实现的轻量推理后端。与其他后端的两点不同:模型要先转成 GGUF 格式;prompt 由引擎按烘在 GGUF 里的模板自己拼,不由 SDK 拼。+本后端与其他后端有两点不同:模型要先转成 GGUF 格式;prompt 由引擎按 GGUF 内置的模板自己拼,不由 SDK 拼。两种服务共用同一个前向引擎,区别只在渲染图从哪里来:@@ -29,40 +29,70 @@ llama.cpp 是 C++ 实现的轻量推理后端。与其他后端的两点不同## 环境要求-- **GPU**:NVIDIA,显存 ≥8GB-- **驱动**:≥535-- **CUDA Toolkit**:≥12.0-- **CMake**:≥3.14-- **C++ 编译器**:支持 C++17(GCC ≥9)-- **Python**:≥3.10-- **llama.cpp**:最新稳定版-- **固定版本**:`Pillow` 12.3.0、`playwright` 1.62.0(仅内置渲染器服务)+| | Linux + NVIDIA | macOS(Apple Silicon) |+| ------------ | --------------------------------------------- | ------------------------------ |+| 加速器 | NVIDIA,显存 ≥8GB | M 系列芯片,统一内存 ≥16GB |+| 驱动 | ≥535 | 不需要,Metal 由系统提供 |+| CUDA Toolkit | ≥12.0 | 不需要 |+| 编译工具 | CMake ≥3.14、GCC ≥9 | Xcode Command Line Tools、CMake |+| 后端开关 | `-DGGML_CUDA=ON` | 无,Metal 默认启用 |+| Python | ≥3.10 | ≥3.10,系统自带的是 3.9,须另装 |+| llama.cpp | ≥ v0.8.0,该版本起含本模型支持 | 同左 |+| 固定版本 | `Pillow` 12.3.0、`playwright` 1.62.0(仅内置渲染器服务) | `Pillow` 12.3.0 |++**CUDA Toolkit**(仅 Linux):确保链接器能找到它的库。装在 `/usr/local/cuda` 之外的路径时,把它注册进 `ldconfig`:++```bash+echo /path/to/cuda/lib64 | sudo tee /etc/ld.so.conf.d/cuda.conf+sudo ldconfig+```++**系统包**:++```bash+# Linux+sudo apt-get install -y python3 python3-venv python3-pip git curl cmake build-essential++# macOS:编译器与 git 来自 Command Line Tools,CMake 另装+xcode-select --install+brew install cmake+```---## 一、前向引擎-### 编译+### 准备源码与转换依赖++两件事都要:取源码(编译与转 GGUF 都用它),装转 GGUF 的 Python 依赖。```bashgit clone https://github.com/ggml-org/llama.cpp.git && cd llama.cpp-cmake -B build -DGGML_CUDA=ON -DCMAKE_BUILD_TYPE=Release-cmake --build build -j --target llama-server++# 虚拟环境放哪都行,下面各处的 /opt/venv-* 同理+# macOS:往 /opt 写要 sudo,放 home 目录即可,例如 ~/venv-convert+python3 -m venv /opt/venv-convert+source /opt/venv-convert/bin/activatepip install -r requirements/requirements-convert_hf_to_gguf.txt```-最后一行装的是转 GGUF 要用的 Python 依赖,清单随 llama.cpp 仓库一起下来,装进来的是:+转换依赖装进单独的虚拟环境:Debian/Ubuntu 等系统会拒绝往系统 Python 里装。慢网下加 `-i https://mirrors.ustc.edu.cn/pypi/simple`。-```text-torch 2.11.0 (取自 download.pytorch.org/whl/cpu,转换不用 GPU)-transformers 4.57.6-numpy ~=2.2.6-sentencepiece >=0.1.98,<0.3.0-gguf >=0.1.0-protobuf >=4.21.0,<5.0.0+### 编译++```bash+cd llama.cpp++# 配置,按平台二选一+# Linux + NVIDIA+cmake -B build -DGGML_CUDA=ON -DCMAKE_BUILD_TYPE=Release+# macOS:Metal 后端默认启用,不需要任何额外开关+cmake -B build -DCMAKE_BUILD_TYPE=Release++cmake --build build -j --target llama-server```-这些只在转换时用到,与下面两个服务的虚拟环境互不相干,装在哪个环境里都可以。+只转 GGUF 不起引擎的话(例如用 Ollama 做前向),这一步可以跳过 —— 转换是纯 Python,不需要编译产物。### 转 GGUF@@ -70,6 +100,7 @@ protobuf >=4.21.0,<5.0.0```bashcd llama.cpp+source /opt/venv-convert/bin/activatemkdir -p ./models/MiniCPM-OCR-Jev-gguffor f in ./models/MiniCPM-OCR-Jev/*; do[ "$(basename "$f")" = config.json ] || ln -sf "$PWD/$f" ./models/MiniCPM-OCR-Jev-gguf/@@ -103,7 +134,7 @@ cd llama.cpp```- `--mmproj`:视觉编码器那份 GGUF,不给就只有文本通路,两张图进不去。-- `-ngl 99`:把全部层放到 GPU 上。+- `-ngl 99`:把全部层放到 GPU 上,macOS 上对应 Metal,写法相同。- `-c 32768`:上下文长度,由并行槽位共享。- `-np N`:并行处理 N 个请求。@@ -118,12 +149,13 @@ cd llama.cpp### 安装```bash+# macOS 同样这么装,只是 /opt 要 sudo,换成 ~/venv-score 即可python3 -m venv /opt/venv-scoresource /opt/venv-score/bin/activatepip install "fastapi>=0.110" "uvicorn>=0.27" "httpx>=0.27" "pydantic>=2.6" "PyYAML>=6.0" "Pillow==12.3.0"```-**依赖版本参考**+**依赖版本参考**(这组版本在 Linux 与 macOS 上一致)```textpython 3.12.3@@ -183,8 +215,6 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '你只有候选文本,让服务渲染完再打分。precheck、render、forward 三个阶段都在这个进程里完成。-本服务在进程内直接调用打分层,**不需要另外起一个不带渲染器服务**,也不需要给它留端口。-### 安装```bash@@ -192,12 +222,16 @@ cd scripts/minicpm-ocr-jev/bash sdk/setup_render.sh /opt/venv-render```-它装 Node、CJK 字体、Chromium 与服务依赖。慢网下设两个镜像源:+它装 Node、CJK 字体、Chromium 与服务依赖。++> **这一节是 Linux 专属。** 脚本靠 `apt-get` 装 Node 与 CJK 字体,并把字体环境固定成参考部署那一套;macOS 上这几步都会跳过。而渲染出来的图是模型输入,字体栈换了分数就换,**macOS 上这个服务打出来的分数不能与发布值对照**。macOS 请用上一节的不带渲染器服务(渲染图由你提供),或者改用 Docker 镜像。++慢网下设两个镜像源:```bashcd scripts/minicpm-ocr-jev/-PIP_INDEX_URL=https://<mirror>/simple \-PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \+PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple \+PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright \bash sdk/setup_render.sh /opt/venv-render```@@ -260,7 +294,7 @@ curl -s http://127.0.0.1:18500/v1/rm/score_best -H 'Content-Type: application/js## 四、启动自检-prompt 由引擎按烘在 GGUF 里的模板拼,从服务这一侧读不到,所以 prompt 这一项**自检不作校验、如实报告**,服务照常启动。能校的是另一项:用一张 1×1 的图真打一次前向,确认引擎按分类模型返回了 2 个数而不是一串隐藏层输出。+prompt 由引擎按 GGUF 内置的模板拼,从服务这一侧读不到,所以 prompt 这一项**自检不作校验、如实报告**,服务照常启动。能校的是另一项:用一张 1×1 的图真打一次前向,确认引擎按分类模型返回了 2 个数而不是一串隐藏层输出。起服后查 `/healthz`,`status` 为 `ok` 即正常:@@ -279,4 +313,28 @@ curl -s http://127.0.0.1:18501/healthz只看 `status`:`ok` 就是自检通过、服务可用,`prompt` 下的其余字段是自检留下的明细,照上面的样子即为正常。`status` 不是 `ok` 时,`prompt.notes` 写明是哪一项没过。-`source` 为 `server_template`、`last_token` 为 `null`、`token_equality` 为 `skipped`,这三项在本后端下就是正常值,不是故障。由此带来的一个口径后果:这条腿分数的尺度,只能靠与已知后端对同一批输入比对来确立。+`source` 为 `server_template`、`last_token` 为 `null`、`token_equality` 为 `skipped`,这三项在本后端下就是正常值,不是故障。由此带来一个后果:本后端分数的尺度,只能靠与已知后端对同一批输入比对来确立。++### 用自带用例验证++本后端的自检不校 prompt(见上),所以这一步不能跳过:用 `examples/` 下三个用例打一遍,与 `case.json` 里的参考分数 `observed_prob_yes` 对照:++```bash+cd scripts/minicpm-ocr-jev+python3 - <<'EOF'+import base64, json, urllib.request+for name in ("01_text_putnam", "02_formula_putnam", "03_table_gb_standard"):+ c = json.load(open(f"examples/{name}/case.json"))+ role = c["reference_render_of"]+ text = next(x["text"] for x in c["candidates"] if x["role"] == role)+ b64 = lambda f: base64.b64encode(open(f"examples/{name}/{f}", "rb").read()).decode()+ body = {"items": [{"original_image": b64(c["block_image"]),+ "render_image": b64(c["reference_render"]), "ocr_text": text}]}+ req = urllib.request.Request("http://127.0.0.1:18501/v1/score",+ data=json.dumps(body).encode(), headers={"Content-Type": "application/json"})+ got = json.load(urllib.request.urlopen(req))["results"][0]["prob_1"]+ print(f"{name:24} got {got:.5f} reference {c['observed_prob_yes'][role]:.5f}")+EOF+```++三行分数与参考值相差都在 0.02 以内即为正常,Linux 与 macOS 同此判据。内置渲染器服务把端点换成 `/v1/rm/score_best`、请求体换成 `image` + `candidates`(见[三、内置渲染器服务 · 请求](#请求-1)),服务会自己渲染 —— 这个变体只在 Linux 上拿来对参考分,原因见该节开头。diff --git a/docs/minicpm_ocr_jev_tutorial_en.md b/docs/minicpm_ocr_jev_tutorial_en.mdindex 397359d..833cd1e 100644--- a/docs/minicpm_ocr_jev_tutorial_en.md+++ b/docs/minicpm_ocr_jev_tutorial_en.md@@ -6,7 +6,7 @@ MiniCPM-OCR Jev is used to check whether an OCR parsing result matches the origiTo deploy MiniCPM-OCR Jev on a wider range of AI chips, see the [FlagOS multi-chip deployment guide](./flagos_deploy_en.md) for supported platforms, model downloads, and container image usage.-[Hardware requirements](#hardware-requirements) · [Deploy with Docker](#option-1-docker-image) · [Deploy with the SDK](#option-2-sdk-deployment)+[Hardware requirements](#hardware-requirements) · [Deploy with Docker](#option-1-docker-image) · [Deploy with the SDK](#option-2-sdk-deployment) · [Verify the deployment](#verify-the-deployment)---@@ -19,6 +19,8 @@ To deploy MiniCPM-OCR Jev on a wider range of AI chips, see the [FlagOS multi-ch| Python | ≥3.10 (SDK deployment only) || Disk | about 5–9 GB for the forward environment, about 1.5 GB for the render environment, about 2.5 GB for the weights |+The commands in this document were verified on Ubuntu 24.04 with driver 590.48 and CUDA 13.0. Other distributions and versions work as well; adjust the apt commands for your own package manager.+---## Deployment options@@ -39,7 +41,7 @@ cd scripts/minicpm-ocr-jevdocker build -f serve/Dockerfile -t minicpm-ocr-jev-1-0:latest .```-On a slow network add `--build-arg PIP_INDEX_URL=https://<mirror>/simple` and `--build-arg PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>`.+On a slow network add `--build-arg PIP_INDEX_URL=https://<your-mirror>/simple` and `--build-arg PLAYWRIGHT_DOWNLOAD_HOST=https://<your-playwright-mirror>` (in mainland China, for example `https://mirrors.ustc.edu.cn/pypi/simple` and `https://cdn.npmmirror.com/binaries/playwright`).Run (mount the weights, map the port):@@ -105,6 +107,23 @@ The SDK needs two separately installed virtual environments:| Engine environment | the forward pass | depends on the backend; see the corresponding documents above || Service environment | the scoring service, plus rendering when the renderer is built in | Python ≥3.10; `Pillow==12.3.0`, `playwright==1.62.0` |+A CUDA toolkit is not needed for all four backends: vLLM and Ollama use the GPU runtime each ships with, while SGLang and llama.cpp need one installed system-wide. The exact requirement is stated under "Requirements" in each backend document.++The engine environment pulls several GB of dependencies; on a slow network point pip at a nearby mirror:++```bash+export PIP_INDEX_URL=https://<your-mirror>/simple+# in mainland China, for example: https://mirrors.ustc.edu.cn/pypi/simple+```++---++## Verify the deployment++`scripts/minicpm-ocr-jev/examples/` holds three cases (text, formula, table), each with the original image, a reference render, the candidate text, and the reference score `observed_prob_yes` recorded in `case.json`. Once deployment is done, score them and compare against those values to confirm the install is correct; the commands are in the "Startup self-check" section of each backend document.++A score within 0.02 of the reference is normal.+---## How it worksdiff --git a/docs/minicpm_ocr_jev_tutorial_zh.md b/docs/minicpm_ocr_jev_tutorial_zh.mdindex ccdb124..437bd61 100644--- a/docs/minicpm_ocr_jev_tutorial_zh.md+++ b/docs/minicpm_ocr_jev_tutorial_zh.md@@ -6,7 +6,7 @@ MiniCPM-OCR Jev 用于判断一段 OCR 解析结果与原图是否一致:输如需在更多不同 AI 芯片上部署 MiniCPM-OCR Jev,支持平台、模型下载和镜像用法见 [FlagOS 多芯片部署指南](./flagos_deploy_zh.md)。-[硬件要求](#硬件要求) · [Docker 镜像部署](#方式一docker-镜像) · [SDK 本地部署](#方式二sdk-本地部署)+[硬件要求](#硬件要求) · [Docker 镜像部署](#方式一docker-镜像) · [SDK 本地部署](#方式二sdk-本地部署) · [验证部署](#验证部署)---@@ -19,6 +19,8 @@ MiniCPM-OCR Jev 用于判断一段 OCR 解析结果与原图是否一致:输| Python | ≥3.10(仅 SDK 方式需要) || 磁盘 | 前向环境约 5–9 GB、渲染环境约 1.5 GB、权重约 2.5 GB |+本文档的命令在 Ubuntu 24.04 + 驱动 590.48 + CUDA 13.0 上验证过。其他发行版与版本同样可用,apt 命令按各自的包管理器调整。+---## 部署方式@@ -39,7 +41,7 @@ cd scripts/minicpm-ocr-jevdocker build -f serve/Dockerfile -t minicpm-ocr-jev-1-0:latest .```-慢网下加上 `--build-arg PIP_INDEX_URL=https://<mirror>/simple` 和 `--build-arg PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>`。+慢网下加上 `--build-arg PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple` 和 `--build-arg PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright`。运行(挂载权重、映射端口):@@ -105,6 +107,22 @@ SDK 要两个独立安装的虚拟环境:| 引擎环境 | 前向推理 | 随后端而定,见上述对应文档 || 服务环境 | 打分服务;用内置渲染器时含渲染 | Python ≥3.10;`Pillow==12.3.0`、`playwright==1.62.0` |+CUDA toolkit 不是四个后端都要装:vLLM 与 Ollama 用各自自带的 GPU 运行时,SGLang 与 llama.cpp 要系统装一套。具体要求写在各后端文档的「环境要求」里。++引擎环境要装几 GB 依赖,慢网下给 pip 指一个就近镜像:++```bash+export PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple+```++---++## 验证部署++`scripts/minicpm-ocr-jev/examples/` 下有三个用例(文本、公式、表格),各带原图、参考渲染图、候选文本,以及 `case.json` 里记录的参考分数 `observed_prob_yes`。部署完成后用它们打一遍分、与参考值对照,就能确认装对了;命令见各后端文档的「启动自检」节。++分数与参考值相差 0.02 以内为正常。+---## 工作方式diff --git a/docs/ollama_deploy_jev_en.md b/docs/ollama_deploy_jev_en.mdindex a58e414..637c60d 100644--- a/docs/ollama_deploy_jev_en.md+++ b/docs/ollama_deploy_jev_en.md@@ -29,12 +29,25 @@ The engine and the service must go into two separate virtual environments; do no## Requirements-- **GPU**: NVIDIA, ≥8GB VRAM-- **Driver**: ≥535-- **Python**: ≥3.10-- **Ollama**: latest stable release-- **llama.cpp**: latest stable release (for the GGUF conversion only)-- **Pinned versions**: `Pillow` 12.3.0, `playwright` 1.62.0 (render+score service only)+| | Linux + NVIDIA | macOS (Apple Silicon) |+| --------------- | ---------------------------------------------------------------- | ----------------------------------- |+| Accelerator | NVIDIA, ≥8GB VRAM | M-series chip, ≥16GB unified memory |+| Driver | ≥535 | Not needed; Metal ships with the OS |+| CUDA Toolkit | Not needed | Not needed |+| Python | ≥3.10 | ≥3.10; the system one is 3.9, install your own |+| Ollama | Latest stable release, whose bundled runner must include support for this model | Same |+| llama.cpp | ≥ v0.8.0 — only its conversion script is used, no build required | Same |+| Pinned versions | `Pillow` 12.3.0, `playwright` 1.62.0 (render+score service only) | `Pillow` 12.3.0 |++**System packages**:++```bash+# Linux+sudo apt-get install -y python3 python3-venv python3-pip curl++# macOS+# No system packages needed; all it takes is a Python ≥3.10+```---@@ -47,7 +60,7 @@ The engine and the service must go into two separate virtual environments; do nocurl -fsSL https://ollama.com/install.sh | sh# macOS-# brew install ollama+brew install ollama# Windows# Download from https://ollama.com/download/windows@@ -55,7 +68,9 @@ curl -fsSL https://ollama.com/install.sh | sh### Register the model-First convert the weights to GGUF; see [llama.cpp deployment · Convert to GGUF](./llamacpp_deploy_jev_en.md#convert-to-gguf). The resulting GGUF carries the `systemone` chat template and the decision-model marker, which is how Ollama recognises it as a decision model.+First convert the weights to GGUF. Both steps live in the llama.cpp deployment document: follow [Source and conversion dependencies](./llamacpp_deploy_jev_en.md#source-and-conversion-dependencies) to fetch the source and install the conversion dependencies (**skip its "Build" section** — conversion is pure Python), then [Convert to GGUF](./llamacpp_deploy_jev_en.md#convert-to-gguf) for the two GGUF files.++The resulting GGUF carries the `systemone` chat template and the decision-model marker, which is how Ollama recognises it as a decision model.Write a `Modelfile`. The first `FROM` is the language model, the second is the vision encoder:@@ -67,11 +82,11 @@ FROM ./models/mmproj-MiniCPM-OCR-Jev-bf16.ggufRegister it and confirm:```bash-ollama create ocr-jev -f Modelfile-ollama show ocr-jev # Capabilities: decision, vision+ollama create minicpm-ocr-jev -f Modelfile+ollama show minicpm-ocr-jev # Capabilities: decision, vision```-The Capabilities line from `ollama show` must list both `decision` and `vision`; either one missing means the GGUF conversion was not right. The model name `ocr-jev` also goes into the SDK's backend config — rename it in both places or not at all.+The Capabilities line from `ollama show` must list both `decision` and `vision`; either one missing means the GGUF conversion was not right. It reads the GGUF metadata, so having both does not yet mean the engine will run — that check is in [4. Startup self-check](#4-startup-self-check). The model name `minicpm-ocr-jev` also goes into the SDK's backend config — rename it in both places or not at all.### Start@@ -88,12 +103,13 @@ You already have the render image and only want the score.### Install```bash+# Same on macOS, except that /opt needs sudo — use ~/venv-score insteadpython3 -m venv /opt/venv-scoresource /opt/venv-score/bin/activatepip install "fastapi>=0.110" "uvicorn>=0.27" "httpx>=0.27" "pydantic>=2.6" "PyYAML>=6.0" "Pillow==12.3.0"```-**Reference dependency versions**+**Reference dependency versions** (the same set on Linux and macOS)```textpython 3.12.3@@ -153,8 +169,6 @@ All three fields are required: `original_image` is the base64 of the original blYou only have candidate text and want the service to render before scoring. Precheck, render and forward all happen in this one process.-This service calls the scoring layer in-process: it does **not** need a separate score service running, and does not need a port reserved for one.-### Install```bash@@ -162,13 +176,20 @@ cd scripts/minicpm-ocr-jev/bash sdk/setup_render.sh /opt/venv-render```-It installs Node, CJK fonts, Chromium and the service dependencies. On a slow network, point it at two mirrors:+It installs Node, CJK fonts, Chromium and the service dependencies.++> **This section is Linux only.** The script relies on `apt-get` to install Node and the CJK fonts and to pin the font environment to the one the reference deployment uses; on macOS those steps are skipped. Rendered text is model input, and a different font stack means different scores, so **scores produced by this service on macOS cannot be compared against the published numbers**. On macOS use the score service from the previous section (you provide the render image), or switch to the Docker image.++On a slow network, point it at two mirrors:```bashcd scripts/minicpm-ocr-jev/-PIP_INDEX_URL=https://<mirror>/simple \-PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \+PIP_INDEX_URL=https://<your-mirror>/simple \+PLAYWRIGHT_DOWNLOAD_HOST=https://<your-playwright-mirror> \bash sdk/setup_render.sh /opt/venv-render+# in mainland China, for example:+# PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple+# PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright```### Start@@ -239,7 +260,7 @@ curl -s http://127.0.0.1:18501/healthz``````json-{"status": "ok", "served_model": "ocr-jev",+{"status": "ok", "served_model": "minicpm-ocr-jev","prompt": {"template_md5": "9aab68e8ba8ab4da17ba9752bddb199c","source": "server_template","last_token": null, "expected_last_token": 271,@@ -249,4 +270,30 @@ curl -s http://127.0.0.1:18501/healthzLook at `status` only: `ok` means the self-check passed and the service is ready. The other fields under `prompt` are self-check details, and the shape above is what a healthy one looks like. When `status` is not `ok`, `prompt.notes` says which part failed.-`source` reading `server_template`, `last_token` reading `null` and `token_equality` reading `skipped` are the normal values for this backend, not a fault. One consequence for how the numbers may be read: the scale of this leg's scores can only be established by comparing it against a known backend on the same inputs.+`source` reading `server_template`, `last_token` reading `null` and `token_equality` reading `skipped` are the normal values for this backend, not a fault. One consequence for how the numbers may be read: the scale of this backend's scores can only be established by comparing it against a known backend on the same inputs.++This section is also the check that tells you whether Ollama's bundled runner accepts this model: when it does not, `status` is not `ok` and `error` carries what `ollama serve` reported. The Capabilities line from `ollama show` does not cover this (see [Register the model](#register-the-model)).++### Verify with the bundled cases++The self-check only confirms the service starts. To confirm the scores are right as well, score the three cases under `examples/` and compare against the reference score `observed_prob_yes` in each `case.json`:++```bash+cd scripts/minicpm-ocr-jev+python3 - <<'EOF'+import base64, json, urllib.request+for name in ("01_text_putnam", "02_formula_putnam", "03_table_gb_standard"):+ c = json.load(open(f"examples/{name}/case.json"))+ role = c["reference_render_of"]+ text = next(x["text"] for x in c["candidates"] if x["role"] == role)+ b64 = lambda f: base64.b64encode(open(f"examples/{name}/{f}", "rb").read()).decode()+ body = {"items": [{"original_image": b64(c["block_image"]),+ "render_image": b64(c["reference_render"]), "ocr_text": text}]}+ req = urllib.request.Request("http://127.0.0.1:18501/v1/score",+ data=json.dumps(body).encode(), headers={"Content-Type": "application/json"})+ got = json.load(urllib.request.urlopen(req))["results"][0]["prob_1"]+ print(f"{name:24} got {got:.5f} reference {c['observed_prob_yes'][role]:.5f}")+EOF+```++All three scores within 0.02 of the reference is normal, on Linux and macOS alike. For the render+score service, change the endpoint to `/v1/rm/score_best` and the body to `image` plus `candidates` (see [3. Render+score service · Request](#request-1)); the service renders on its own — that variant is only compared against the reference scores on Linux, for the reason given at the top of that section.diff --git a/docs/ollama_deploy_jev_zh.md b/docs/ollama_deploy_jev_zh.mdindex 18cf5e2..7116e23 100644--- a/docs/ollama_deploy_jev_zh.md+++ b/docs/ollama_deploy_jev_zh.md@@ -6,7 +6,7 @@本文介绍SDK部署模式下,以 Ollama 作为前向引擎时,**不带渲染器服务**与**内置渲染器服务**的安装、启动、接口与请求格式。-Ollama 把 MiniCPM-OCR Jev 当作决策模型(decision model)来服务。与其他后端的两点不同:模型要先转成 GGUF 并注册给 Ollama;prompt 由引擎按烘在 GGUF 里的模板自己拼,不由 SDK 拼。+Ollama 把 MiniCPM-OCR Jev 当作决策模型(decision model)来服务。与其他后端的两点不同:模型要先转成 GGUF 并注册给 Ollama;prompt 由引擎按 GGUF 内置的模板自己拼,不由 SDK 拼。两种服务共用同一个前向引擎,区别只在渲染图从哪里来:@@ -29,12 +29,25 @@ Ollama 把 MiniCPM-OCR Jev 当作决策模型(decision model)来服务。与## 环境要求-- **GPU**:NVIDIA,显存 ≥8GB-- **驱动**:≥535-- **Python**:≥3.10-- **Ollama**:最新稳定版-- **llama.cpp**:最新稳定版(只用于转 GGUF)-- **固定版本**:`Pillow` 12.3.0、`playwright` 1.62.0(仅内置渲染器服务)+| | Linux + NVIDIA | macOS(Apple Silicon) |+| ------------ | --------------------------------------------- | --------------------- |+| 加速器 | NVIDIA,显存 ≥8GB | M 系列芯片,统一内存 ≥16GB |+| 驱动 | ≥535 | 不需要,Metal 由系统提供 |+| CUDA Toolkit | 不需要 | 不需要 |+| Python | ≥3.10 | ≥3.10,系统自带的是 3.9,须另装 |+| Ollama | 最新稳定版,其内置 runner 需含本模型支持 | 同左 |+| llama.cpp | ≥ v0.8.0,只用它的转换脚本,不需要编译 | 同左 |+| 固定版本 | `Pillow` 12.3.0、`playwright` 1.62.0(仅内置渲染器服务) | `Pillow` 12.3.0 |++**系统包**:++```bash+# Linux+sudo apt-get install -y python3 python3-venv python3-pip curl++# macOS+# 不需要装任何系统包,只要有一个 ≥3.10 的 Python+```---@@ -47,7 +60,7 @@ Ollama 把 MiniCPM-OCR Jev 当作决策模型(decision model)来服务。与curl -fsSL https://ollama.com/install.sh | sh# macOS-# brew install ollama+brew install ollama# Windows# 从 https://ollama.com/download/windows 下载安装@@ -55,7 +68,9 @@ curl -fsSL https://ollama.com/install.sh | sh### 注册模型-先把权重转成 GGUF,转法见 [llama.cpp 部署文档 · 转 GGUF](./llamacpp_deploy_jev_zh.md#转-gguf)。转出来的 GGUF 自带 `systemone` 对话模板与决策模型标识,Ollama 靠它们认出这是决策模型。+先把权重转成 GGUF,两步都在 llama.cpp 部署文档里:先按[准备源码与转换依赖](./llamacpp_deploy_jev_zh.md#准备源码与转换依赖)取源码、装转换依赖(**跳过它的「编译」节**,转换是纯 Python),再按[转 GGUF](./llamacpp_deploy_jev_zh.md#转-gguf)转出两份 GGUF。++转出来的 GGUF 自带 `systemone` 对话模板与决策模型标识,Ollama 靠它们认出这是决策模型。写一个 `Modelfile`,第一个 `FROM` 是语言模型,第二个是视觉编码器:@@ -67,11 +82,11 @@ FROM ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf注册并确认:```bash-ollama create ocr-jev -f Modelfile-ollama show ocr-jev # Capabilities: decision, vision+ollama create minicpm-ocr-jev -f Modelfile+ollama show minicpm-ocr-jev # Capabilities: decision, vision```-`ollama show` 的 Capabilities 要同时有 `decision` 与 `vision`,缺任意一个都说明 GGUF 转得不对。模型名 `ocr-jev` 后面要写进 SDK 的后端配置,改名则两处同改。+`ollama show` 的 Capabilities 要同时有 `decision` 与 `vision`,缺任意一个都说明 GGUF 转得不对。它读的是 GGUF 的元数据,所以两项都有也还不能说明引擎跑得起来 —— 那一关在[四、启动自检](#四启动自检)。模型名 `minicpm-ocr-jev` 后面要写进 SDK 的后端配置,改名则两处同改。### 启动@@ -88,12 +103,13 @@ ollama serve # 默认端口 11434### 安装```bash+# macOS 同样这么装,只是 /opt 要 sudo,换成 ~/venv-score 即可python3 -m venv /opt/venv-scoresource /opt/venv-score/bin/activatepip install "fastapi>=0.110" "uvicorn>=0.27" "httpx>=0.27" "pydantic>=2.6" "PyYAML>=6.0" "Pillow==12.3.0"```-**依赖版本参考**+**依赖版本参考**(这组版本在 Linux 与 macOS 上一致)```textpython 3.12.3@@ -153,8 +169,6 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '你只有候选文本,让服务渲染完再打分。precheck、render、forward 三个阶段都在这个进程里完成。-本服务在进程内直接调用打分层,**不需要另外起一个不带渲染器服务**,也不需要给它留端口。-### 安装```bash@@ -162,12 +176,16 @@ cd scripts/minicpm-ocr-jev/bash sdk/setup_render.sh /opt/venv-render```-它装 Node、CJK 字体、Chromium 与服务依赖。慢网下设两个镜像源:+它装 Node、CJK 字体、Chromium 与服务依赖。++> **这一节是 Linux 专属。** 脚本靠 `apt-get` 装 Node 与 CJK 字体,并把字体环境固定成参考部署那一套;macOS 上这几步都会跳过。而渲染出来的图是模型输入,字体栈换了分数就换,**macOS 上这个服务打出来的分数不能与发布值对照**。macOS 请用上一节的不带渲染器服务(渲染图由你提供),或者改用 Docker 镜像。++慢网下设两个镜像源:```bashcd scripts/minicpm-ocr-jev/-PIP_INDEX_URL=https://<mirror>/simple \-PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \+PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple \+PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright \bash sdk/setup_render.sh /opt/venv-render```@@ -230,7 +248,7 @@ curl -s http://127.0.0.1:18500/v1/rm/score_best -H 'Content-Type: application/js## 四、启动自检-prompt 由引擎按烘在 GGUF 里的模板拼,从服务这一侧读不到,所以 prompt 这一项**自检不作校验、如实报告**,服务照常启动。能校的是另一项:用一张 1×1 的图真打一次前向,确认引擎按决策模型返回了 2 个数而不是一串隐藏层输出。+prompt 由引擎按 GGUF 内置的模板拼,从服务这一侧读不到,所以 prompt 这一项**自检不作校验、如实报告**,服务照常启动。能校的是另一项:用一张 1×1 的图真打一次前向,确认引擎按决策模型返回了 2 个数而不是一串隐藏层输出。起服后查 `/healthz`,`status` 为 `ok` 即正常:@@ -239,7 +257,7 @@ curl -s http://127.0.0.1:18501/healthz``````json-{"status": "ok", "served_model": "ocr-jev",+{"status": "ok", "served_model": "minicpm-ocr-jev","prompt": {"template_md5": "9aab68e8ba8ab4da17ba9752bddb199c","source": "server_template","last_token": null, "expected_last_token": 271,@@ -249,4 +267,30 @@ curl -s http://127.0.0.1:18501/healthz只看 `status`:`ok` 就是自检通过、服务可用,`prompt` 下的其余字段是自检留下的明细,照上面的样子即为正常。`status` 不是 `ok` 时,`prompt.notes` 写明是哪一项没过。-`source` 为 `server_template`、`last_token` 为 `null`、`token_equality` 为 `skipped`,这三项在本后端下就是正常值,不是故障。由此带来的一个口径后果:这条腿分数的尺度,只能靠与已知后端对同一批输入比对来确立。+`source` 为 `server_template`、`last_token` 为 `null`、`token_equality` 为 `skipped`,这三项在本后端下就是正常值,不是故障。由此带来一个后果:本后端分数的尺度,只能靠与已知后端对同一批输入比对来确立。++本节也是判断 Ollama 内置 runner 认不认这个模型的那一关:runner 不支持时 `status` 不是 `ok`,`error` 里带上 `ollama serve` 的原话。`ollama show` 的 Capabilities 不负责这件事(见[注册模型](#注册模型))。++### 用自带用例验证++自检只确认服务起得来。要确认分数也对,用 `examples/` 下三个用例打一遍,与 `case.json` 里的参考分数 `observed_prob_yes` 对照:++```bash+cd scripts/minicpm-ocr-jev+python3 - <<'EOF'+import base64, json, urllib.request+for name in ("01_text_putnam", "02_formula_putnam", "03_table_gb_standard"):+ c = json.load(open(f"examples/{name}/case.json"))+ role = c["reference_render_of"]+ text = next(x["text"] for x in c["candidates"] if x["role"] == role)+ b64 = lambda f: base64.b64encode(open(f"examples/{name}/{f}", "rb").read()).decode()+ body = {"items": [{"original_image": b64(c["block_image"]),+ "render_image": b64(c["reference_render"]), "ocr_text": text}]}+ req = urllib.request.Request("http://127.0.0.1:18501/v1/score",+ data=json.dumps(body).encode(), headers={"Content-Type": "application/json"})+ got = json.load(urllib.request.urlopen(req))["results"][0]["prob_1"]+ print(f"{name:24} got {got:.5f} reference {c['observed_prob_yes'][role]:.5f}")+EOF+```++三行分数与参考值相差都在 0.02 以内即为正常,Linux 与 macOS 同此判据。内置渲染器服务把端点换成 `/v1/rm/score_best`、请求体换成 `image` + `candidates`(见[三、内置渲染器服务 · 请求](#请求-1)),服务会自己渲染 —— 这个变体只在 Linux 上拿来对参考分,原因见该节开头。diff --git a/docs/sglang_deploy_jev_en.md b/docs/sglang_deploy_jev_en.mdindex 1a9b292..d02863a 100644--- a/docs/sglang_deploy_jev_en.md+++ b/docs/sglang_deploy_jev_en.md@@ -29,17 +29,36 @@ The engine and the service must go into two separate virtual environments; do no- **GPU**: NVIDIA, ≥16GB VRAM- **Driver**: ≥535-- **CUDA toolkit**: must match the CUDA version PyTorch was built against (e.g. CUDA 13.0 for a cu130 build)- **Python**: ≥3.10- **SGLang**: latest stable release- **Pinned versions**: `Pillow` 12.3.0, `playwright` 1.62.0 (render+score service only)+**CUDA toolkit**: install a complete one system-wide, matching the CUDA version PyTorch was built against (e.g. CUDA 13.0 for a cu130 build). Put it in `/usr/local/cuda`, or point `CUDA_HOME` at it:++```bash+export CUDA_HOME=/path/to/cuda+export PATH=$CUDA_HOME/bin:$PATH+```++The `nvidia-*` packages pip installs into the virtual environment are not a substitute for it.++**System packages**: `gcc`, `g++` and `python3-dev` are runtime dependencies — do not remove them after installing.++```bash+sudo apt-get install -y python3 python3-venv python3-pip curl gcc g++ python3-dev+```++The engine environment pulls 8–9 GB of dependencies; on a slow network point pip at a nearby mirror first:++```bash+export PIP_INDEX_URL=https://<your-mirror>/simple+# in mainland China, for example: https://mirrors.ustc.edu.cn/pypi/simple+```+---## 1. Forward engine-Both services need an SGLang engine to connect to.-```bashpython3 -m venv /opt/venv-sglang && source /opt/venv-sglang/bin/activatepip install "sglang[all]"@@ -143,8 +162,6 @@ All three fields are required: `original_image` is the base64 of the original blYou only have candidate text and want the service to render before scoring. Precheck, render and forward all happen in this one process.-This service calls the scoring layer in-process: it does **not** need a separate score service running, and does not need a port reserved for one.-### Install```bash@@ -156,9 +173,12 @@ It installs Node, CJK fonts, Chromium and the service dependencies. On a slow ne```bashcd scripts/minicpm-ocr-jev/-PIP_INDEX_URL=https://<mirror>/simple \-PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \+PIP_INDEX_URL=https://<your-mirror>/simple \+PLAYWRIGHT_DOWNLOAD_HOST=https://<your-playwright-mirror> \bash sdk/setup_render.sh /opt/venv-render+# in mainland China, for example:+# PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple+# PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright```### Start@@ -240,3 +260,27 @@ curl -s http://127.0.0.1:18501/healthzLook at `status` only: `ok` means the self-check passed and the service is ready. The other fields under `prompt` are self-check details, and the shape above is what a healthy one looks like. When `status` is not `ok`, `prompt.notes` says which part failed.`served_model` is the weights path the engine was started with (SGLang identifies a model by path and serves one model per process). When the weights directory is not on this host, or `transformers` is not installed, `token_equality` reads `skipped` — a skip, not a failure, and `notes` says why.++### Verify with the bundled cases++The self-check only confirms the service starts. To confirm the scores are right as well, score the three cases under `examples/` and compare against the reference score `observed_prob_yes` in each `case.json`:++```bash+cd scripts/minicpm-ocr-jev+python3 - <<'EOF'+import base64, json, urllib.request+for name in ("01_text_putnam", "02_formula_putnam", "03_table_gb_standard"):+ c = json.load(open(f"examples/{name}/case.json"))+ role = c["reference_render_of"]+ text = next(x["text"] for x in c["candidates"] if x["role"] == role)+ b64 = lambda f: base64.b64encode(open(f"examples/{name}/{f}", "rb").read()).decode()+ body = {"items": [{"original_image": b64(c["block_image"]),+ "render_image": b64(c["reference_render"]), "ocr_text": text}]}+ req = urllib.request.Request("http://127.0.0.1:18501/v1/score",+ data=json.dumps(body).encode(), headers={"Content-Type": "application/json"})+ got = json.load(urllib.request.urlopen(req))["results"][0]["prob_1"]+ print(f"{name:24} got {got:.5f} reference {c['observed_prob_yes'][role]:.5f}")+EOF+```++All three scores within 0.02 of the reference is normal. For the render+score service, change the endpoint to `/v1/rm/score_best` and the body to `image` plus `candidates` (see [3. Render+score service · Request](#request-1)); the service renders on its own.diff --git a/docs/sglang_deploy_jev_zh.md b/docs/sglang_deploy_jev_zh.mdindex cf39aca..da52d25 100644--- a/docs/sglang_deploy_jev_zh.md+++ b/docs/sglang_deploy_jev_zh.md@@ -29,17 +29,35 @@- **GPU**:NVIDIA,显存 ≥16GB- **驱动**:≥535-- **CUDA toolkit**:版本需与 PyTorch 所用的 CUDA 版本一致(如 PyTorch 为 cu130,则装 CUDA 13.0)- **Python**:≥3.10- **SGLang**:最新稳定版- **固定版本**:`Pillow` 12.3.0、`playwright` 1.62.0(仅内置渲染器服务)+**CUDA toolkit**:要在系统里装一套完整的,版本与 PyTorch 所用的 CUDA 版本一致(如 PyTorch 为 cu130,则装 CUDA 13.0)。装在 `/usr/local/cuda`,或另设 `CUDA_HOME` 指向它:++```bash+export CUDA_HOME=/path/to/cuda+export PATH=$CUDA_HOME/bin:$PATH+```++虚拟环境里由 pip 装进来的 `nvidia-*` 包不能代替它。++**系统包**:`gcc`、`g++`、`python3-dev` 是 runtime 依赖,装完不要删除。++```bash+sudo apt-get install -y python3 python3-venv python3-pip curl gcc g++ python3-dev+```++引擎环境要装 8–9 GB 依赖,慢网下先给 pip 指一个就近镜像:++```bash+export PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple+```+---## 一、前向引擎-两种服务都要连一个 SGLang 引擎。-```bashpython3 -m venv /opt/venv-sglang && source /opt/venv-sglang/bin/activatepip install "sglang[all]"@@ -143,8 +161,6 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '你只有候选文本,让服务渲染完再打分。precheck、render、forward 三个阶段都在这个进程里完成。-本服务在进程内直接调用打分层,**不需要另外起一个不带渲染器服务**,也不需要给它留端口。-### 安装```bash@@ -156,8 +172,8 @@ bash sdk/setup_render.sh /opt/venv-render```bashcd scripts/minicpm-ocr-jev/-PIP_INDEX_URL=https://<mirror>/simple \-PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \+PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple \+PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright \bash sdk/setup_render.sh /opt/venv-render```@@ -240,3 +256,27 @@ curl -s http://127.0.0.1:18501/healthz只看 `status`:`ok` 就是自检通过、服务可用,`prompt` 下的其余字段是自检留下的明细,照上面的样子即为正常。`status` 不是 `ok` 时,`prompt.notes` 写明是哪一项没过。`served_model` 是引擎启动时的权重路径(SGLang 按路径标识模型,一个进程只服务一个模型)。本机没有权重目录或没装 `transformers` 时,`token_equality` 为 `skipped`,这是跳过不是失败,`notes` 会说明原因。++### 用自带用例验证++自检只确认服务起得来。要确认分数也对,用 `examples/` 下三个用例打一遍,与 `case.json` 里的参考分数 `observed_prob_yes` 对照:++```bash+cd scripts/minicpm-ocr-jev+python3 - <<'EOF'+import base64, json, urllib.request+for name in ("01_text_putnam", "02_formula_putnam", "03_table_gb_standard"):+ c = json.load(open(f"examples/{name}/case.json"))+ role = c["reference_render_of"]+ text = next(x["text"] for x in c["candidates"] if x["role"] == role)+ b64 = lambda f: base64.b64encode(open(f"examples/{name}/{f}", "rb").read()).decode()+ body = {"items": [{"original_image": b64(c["block_image"]),+ "render_image": b64(c["reference_render"]), "ocr_text": text}]}+ req = urllib.request.Request("http://127.0.0.1:18501/v1/score",+ data=json.dumps(body).encode(), headers={"Content-Type": "application/json"})+ got = json.load(urllib.request.urlopen(req))["results"][0]["prob_1"]+ print(f"{name:24} got {got:.5f} reference {c['observed_prob_yes'][role]:.5f}")+EOF+```++三行分数与参考值相差都在 0.02 以内即为正常。内置渲染器服务把端点换成 `/v1/rm/score_best`、请求体换成 `image` + `candidates`(见[三、内置渲染器服务 · 请求](#请求-1)),服务会自己渲染。diff --git a/docs/vllm_deploy_jev_en.md b/docs/vllm_deploy_jev_en.mdindex b5f2197..33c020f 100644--- a/docs/vllm_deploy_jev_en.md+++ b/docs/vllm_deploy_jev_en.md@@ -31,15 +31,26 @@ The engine and the service must go into two separate virtual environments; do no- **Driver**: ≥535- **Python**: ≥3.10- **vLLM**: 0.32.0-- **System packages**: `gcc`, `g++`, `python3-dev` (runtime dependencies — do not remove them after installing)+- **CUDA toolkit**: **not needed** — vLLM ships its own GPU runtime- **Pinned versions**: `Pillow` 12.3.0, `playwright` 1.62.0 (render+score service only)+**System packages**: `gcc`, `g++` and `python3-dev` are runtime dependencies — do not remove them after installing.++```bash+sudo apt-get install -y python3 python3-venv python3-pip curl gcc g++ python3-dev+```++The engine environment pulls 8–9 GB of dependencies; on a slow network point pip at a nearby mirror first:++```bash+export PIP_INDEX_URL=https://<your-mirror>/simple+# in mainland China, for example: https://mirrors.ustc.edu.cn/pypi/simple+```+---## 1. Forward engine-Both services need a vLLM engine to connect to.-Install and start it with the bundled scripts; the arguments are GPU index, port, and weights path, in that order:```bash@@ -140,8 +151,6 @@ All three fields are required: `original_image` is the base64 of the original blYou only have candidate text and want the service to render before scoring. Precheck, render and forward all happen in this one process.-This service calls the scoring layer in-process: it does **not** need a separate score service running, and does not need a port reserved for one.-### Install```bash@@ -153,9 +162,12 @@ It installs Node, CJK fonts, Chromium and the service dependencies. On a slow ne```bashcd scripts/minicpm-ocr-jev/-PIP_INDEX_URL=https://<mirror>/simple \-PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \+PIP_INDEX_URL=https://<your-mirror>/simple \+PLAYWRIGHT_DOWNLOAD_HOST=https://<your-playwright-mirror> \bash sdk/setup_render.sh /opt/venv-render+# in mainland China, for example:+# PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple+# PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright```### Start@@ -233,3 +245,27 @@ curl -s http://127.0.0.1:18501/healthz```Look at `status` only: `ok` means the self-check passed and the service is ready. The other fields under `prompt` are self-check details, and the shape above is what a healthy one looks like. When `status` is not `ok`, `prompt.notes` says which part failed.++### Verify with the bundled cases++The self-check only confirms the service starts. To confirm the scores are right as well, score the three cases under `examples/` and compare against the reference score `observed_prob_yes` in each `case.json`:++```bash+cd scripts/minicpm-ocr-jev+python3 - <<'EOF'+import base64, json, urllib.request+for name in ("01_text_putnam", "02_formula_putnam", "03_table_gb_standard"):+ c = json.load(open(f"examples/{name}/case.json"))+ role = c["reference_render_of"]+ text = next(x["text"] for x in c["candidates"] if x["role"] == role)+ b64 = lambda f: base64.b64encode(open(f"examples/{name}/{f}", "rb").read()).decode()+ body = {"items": [{"original_image": b64(c["block_image"]),+ "render_image": b64(c["reference_render"]), "ocr_text": text}]}+ req = urllib.request.Request("http://127.0.0.1:18501/v1/score",+ data=json.dumps(body).encode(), headers={"Content-Type": "application/json"})+ got = json.load(urllib.request.urlopen(req))["results"][0]["prob_1"]+ print(f"{name:24} got {got:.5f} reference {c['observed_prob_yes'][role]:.5f}")+EOF+```++All three scores within 0.02 of the reference is normal. For the render+score service, change the endpoint to `/v1/rm/score_best` and the body to `image` plus `candidates` (see [3. Render+score service · Request](#request-1)); the service renders on its own.diff --git a/docs/vllm_deploy_jev_zh.md b/docs/vllm_deploy_jev_zh.mdindex 5e7afd3..eff4274 100644--- a/docs/vllm_deploy_jev_zh.md+++ b/docs/vllm_deploy_jev_zh.md@@ -31,15 +31,25 @@- **驱动**:≥535- **Python**:≥3.10- **vLLM**:0.32.0-- **系统包**:`gcc`、`g++`、`python3-dev`(runtime 依赖,装完不要删除)+- **CUDA toolkit**:**不需要**,vLLM 自带 GPU 运行时- **固定版本**:`Pillow` 12.3.0、`playwright` 1.62.0(仅内置渲染器服务)+**系统包**:`gcc`、`g++`、`python3-dev` 是 runtime 依赖,装完不要删除。++```bash+sudo apt-get install -y python3 python3-venv python3-pip curl gcc g++ python3-dev+```++引擎环境要装 8–9 GB 依赖,慢网下先给 pip 指一个就近镜像:++```bash+export PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple+```+---## 一、前向引擎-两种服务都要连一个 vLLM 引擎。-用随附脚本安装并启动,参数依次为 GPU 号、端口、权重路径:```bash@@ -140,8 +150,6 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '你只有候选文本,让服务渲染完再打分。precheck、render、forward 三个阶段都在这个进程里完成。-本服务在进程内直接调用打分层,**不需要另外起一个不带渲染器服务**,也不需要给它留端口。-### 安装```bash@@ -153,8 +161,8 @@ bash sdk/setup_render.sh /opt/venv-render```bashcd scripts/minicpm-ocr-jev/-PIP_INDEX_URL=https://<mirror>/simple \-PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \+PIP_INDEX_URL=https://mirrors.ustc.edu.cn/pypi/simple \+PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright \bash sdk/setup_render.sh /opt/venv-render```@@ -233,3 +241,27 @@ curl -s http://127.0.0.1:18501/healthz```只看 `status`:`ok` 就是自检通过、服务可用,`prompt` 下的其余字段是自检留下的明细,照上面的样子即为正常。`status` 不是 `ok` 时,`prompt.notes` 写明是哪一项没过。++### 用自带用例验证++自检只确认服务起得来。要确认分数也对,用 `examples/` 下三个用例打一遍,与 `case.json` 里的参考分数 `observed_prob_yes` 对照:++```bash+cd scripts/minicpm-ocr-jev+python3 - <<'EOF'+import base64, json, urllib.request+for name in ("01_text_putnam", "02_formula_putnam", "03_table_gb_standard"):+ c = json.load(open(f"examples/{name}/case.json"))+ role = c["reference_render_of"]+ text = next(x["text"] for x in c["candidates"] if x["role"] == role)+ b64 = lambda f: base64.b64encode(open(f"examples/{name}/{f}", "rb").read()).decode()+ body = {"items": [{"original_image": b64(c["block_image"]),+ "render_image": b64(c["reference_render"]), "ocr_text": text}]}+ req = urllib.request.Request("http://127.0.0.1:18501/v1/score",+ data=json.dumps(body).encode(), headers={"Content-Type": "application/json"})+ got = json.load(urllib.request.urlopen(req))["results"][0]["prob_1"]+ print(f"{name:24} got {got:.5f} reference {c['observed_prob_yes'][role]:.5f}")+EOF+```++三行分数与参考值相差都在 0.02 以内即为正常。内置渲染器服务把端点换成 `/v1/rm/score_best`、请求体换成 `image` + `candidates`(见[三、内置渲染器服务 · 请求](#请求-1)),服务会自己渲染。diff --git a/scripts/minicpm-ocr-jev/sdk/backends/ollama.yaml b/scripts/minicpm-ocr-jev/sdk/backends/ollama.yamlindex d62a3cd..a37902a 100644--- a/scripts/minicpm-ocr-jev/sdk/backends/ollama.yaml+++ b/scripts/minicpm-ocr-jev/sdk/backends/ollama.yaml@@ -17,7 +17,7 @@ base_url: http://127.0.0.1:11434# routes by name. This must be the name `ollama create` registered -- change it# in both places or requests go to a model that does not exist. Startup fails# with a message saying so rather than defaulting to anything.-model: ocr-jev+model: minicpm-ocr-jev# Seconds to wait on one forward pass.timeout_sec: 120