Skip to content

Fast, accurate OCR with correctness assessment.

update skill_jev with docker method and simplify ollama and lamma.cpp sdk deployment with downloading GGUF format weight from HF

taitoushiyun814231c7d3e1
diff --git a/README.md b/README.md
index f6f41ed..da96dc9 100644
--- a/README.md
+++ b/README.md
@@ -139,7 +139,7 @@ Ask a coding agent to follow the MiniCPM-OCR 1.0 [skill](./docs/SKILL_en.md) to
Read and execute https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/SKILL_en.md
```
-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:
+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 — either from the Docker image or with the SDK, using 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
diff --git a/README_zh.md b/README_zh.md
index b501af3..ba8f0a7 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -137,7 +137,7 @@
Read and execute https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/SKILL.md
```
-让编码 Agent 按 MiniCPM-OCR Jev [skill](./docs/SKILL_jev.md) 完成打分服务的本地部署、启动和验证,支持 vLLM、SGLang、llama.cpp 和 Ollama 四个推理后端。将以下指令发送给 Agent:
+让编码 Agent 按 MiniCPM-OCR Jev [skill](./docs/SKILL_jev.md) 完成打分服务的本地部署、启动和验证:Docker 镜像与 SDK 两条路径都覆盖,SDK 支持 vLLM、SGLang、llama.cpp 和 Ollama 四个推理后端。将以下指令发送给 Agent:
```text
Read and execute https://github.com/OpenBMB/MiniCPM-OCR/blob/main/docs/SKILL_jev.md
diff --git a/docs/SKILL_jev.md b/docs/SKILL_jev.md
index eff0f67..c731002 100644
--- a/docs/SKILL_jev.md
+++ b/docs/SKILL_jev.md
@@ -1,17 +1,75 @@
---
-name: minicpm-ocr-jev-sdk
-description: 安装、部署和验证 MiniCPM-OCR Jev 打分服务(SDK 本地部署,vLLM / SGLang / llama.cpp / Ollama 四个推理后端)。在用户要装 Jev SDK、起打分服务、给 OCR 结果打一致性分数或在多个候选里选优、排查起服与打分报错时使用。
+name: minicpm-ocr-jev-deploy
+description: 安装、部署和验证 MiniCPM-OCR Jev 打分服务,两条路径——Docker 镜像,或 SDK 本地部署(vLLM / SGLang / llama.cpp / Ollama 四个推理后端)。在用户要起 Jev 打分服务、部署 Jev 镜像或 SDK、给 OCR 结果打一致性分数或在多个候选里选优、排查起服与打分报错时使用。
---
-# MiniCPM-OCR Jev SDK 本地部署
+# MiniCPM-OCR Jev 本地部署
-Jev 判断一段 OCR 文本与原图是否一致:送原图与候选文本,返回 0–1 的一致性分数。SDK 部署把渲染器与模型服务分开装在主机上——引擎做前向,服务层做打分,两者必须在不同的虚拟环境里。
+Jev 判断一段 OCR 文本与原图是否一致:送原图与候选文本,返回 0–1 的一致性分数。
-本文的命令与 `docs/{vllm,sglang,llamacpp,ollama}_deploy_jev_zh.md` 同源,每节都标了对应文档的小节;改任一方需同步。想用 Docker 而不是 SDK 的话走 `minicpm_ocr_jev_tutorial_zh.md` 的方式一,本 skill 不覆盖。
+部署有两条路径,用同一个模型、同一套打分逻辑:**Docker 镜像**一个容器里装齐引擎、打分服务与渲染环境;**SDK** 把渲染器与模型服务分开装在主机上——引擎做前向,服务层做打分,两者必须在不同的虚拟环境里。
+
+本文的命令与 `docs/minicpm_ocr_jev_tutorial_zh.md`、`docs/minicpm_ocr_jev_docker_api_zh.md`、`docs/{vllm,sglang,llamacpp,ollama}_deploy_jev_zh.md` 同源,每节都标了对应文档的小节;改任一方需同步。
## 1. 确定方案
-先问清两件事:**用哪个推理后端**、**渲染图由谁提供**。用户没有偏好时用 vLLM + 内置渲染器。
+### 1.1 先定走哪条路径
+
+| | Docker 镜像(1.2) | SDK(1.3 起) |
+|---|---|---|
+| 渲染环境 | 镜像内置固定版本的 Chromium 与 CJK 字体 | 自己装(6.2),或由调用方提供渲染图(6.1) |
+| 分数口径 | 与云端 API 同一套渲染环境,可直接与发布数字对照 | 排序稳定,绝对值可能差在小数点后第三位 |
+| 要装什么 | Docker + NVIDIA Container Toolkit | 两个虚拟环境:引擎 + 服务层 |
+| 推理后端 | 镜像内固定 vLLM | vLLM / SGLang / llama.cpp / Ollama 四选一 |
+| 平台 | 仅 Linux + NVIDIA | Linux + NVIDIA/macOS(见 1.3) |
+| 适合 | 要与发布数字对照、不想自己装渲染环境 | 没有 Docker、在 macOS 上、已有渲染图、或要指定后端 |
+
+机器上有 Docker 和 NVIDIA 卡、用户又没有偏好时走 Docker 镜像。**走 Docker 只需 1.2 + 7.3,外加取权重的第 3 节;第 2、4、5、6、8 节都是 SDK 路径的步骤。**
+
+### 1.2 Docker 镜像(对应 `minicpm_ocr_jev_tutorial_zh.md` 方式一)
+
+前置:Docker 与 NVIDIA Container Toolkit 已装(`docker run --rm --gpus all ubuntu nvidia-smi` 能打印出卡即算通)、驱动 ≥535、显存 ≥12 GB、权重 `<WEIGHTS>` 已按第 3 节取好。
+
+```bash
+cd scripts/minicpm-ocr-jev
+docker build -f serve/Dockerfile -t minicpm-ocr-jev-1-0:latest .
+
+docker run -d --name minicpm-ocr-jev --gpus '"device=<GPU>"' \
+ -p 127.0.0.1:8030:8030 \
+ -v <WEIGHTS>:/weights:ro \
+ minicpm-ocr-jev-1-0:latest 8030 /weights
+```
+
+慢网下构建时加 `--build-arg PIP_INDEX_URL=<镜像源>` 与 `--build-arg PLAYWRIGHT_DOWNLOAD_HOST=<镜像源>`(可用值见第 3 节)。
+
+通过标准:`curl -f http://127.0.0.1:8030/healthz` 的 `status` 为 `ok`。`loading` 是还在加载权重,此时打分返回 503,等它转成 `ok`。
+
+打分:
+
+```bash
+curl -s http://127.0.0.1:8030/v1/rm/score -H 'Content-Type: application/json' -d '{
+ "input_form": "ternary",
+ "items": [
+ {"case_id": "blk-001", "image": "<base64>",
+ "ocr_text": "待评分的 OCR 文本", "category": "text"}
+ ]
+}'
+```
+
+四个端点:`/healthz`、`/v1/rm/score`(逐块各打一分)、`/v1/rm/score_best`(单块 N 候选选优)、`/v1/rm/score_best_batch`(多块各自选优,块多时用它)。完整字段定义见 `minicpm_ocr_jev_docker_api_zh.md`,调用时要守的几条:
+
+- `input_form` 固定 `"ternary"`,`score_best_batch` 的每个 item 里还要再带一次,缺了返回 422。
+- `image` 传 PNG/JPEG 的 base64 正文,**不带** `data:image/png;base64,` 前缀;带了该条返回 `encode_error`。
+- `category` 三选一 `text` / `formula` / `table`,**必须与块真实类型一致**:公式块送成 `text` 会按字面渲染,不报错但分数失真。
+- 用分数前先看 `verdict`:`0.0` 与 `-1.0` 是打分失败的固定返回值,不是低分。
+- 已有渲染图时送 `items[].render_image`(`score_best*` 是 `render_images`),服务端就跳过渲染。
+- 单次请求候选总数受 `max_items` 限制(默认 64,超出返回 400);`threshold`(默认 0.5)只影响汇总里的 `throughput_rate`,不改任何一条的 `prob_yes`。
+
+装完按 [7.3](#73-docker-路径用自带用例打分) 用自带用例核分数——`/healthz` 返回 `ok` 只说明服务起来了。
+
+### 1.3 SDK:选后端与渲染形态
+
+走 SDK 再定两件事:**用哪个推理后端**、**渲染图由谁提供**。用户没有偏好时用 vLLM + 内置渲染器。
按渲染图来源分两种形态,用同一个模型、同一套打分代码:
@@ -30,15 +88,17 @@ Jev 判断一段 OCR 文本与原图是否一致:送原图与候选文本,
| 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 |
+| Ollama | 不需要 | 否 | 无(引擎在安装包里) | Linux + NVIDIA/macOS | 要求最轻,已有 Ollama |
-- llama.cpp 与 Ollama 都要先把权重转成 GGUF,转换环境(CPU 版 torch)4.8 GB,转完可删。
+- llama.cpp 与 Ollama 用 GGUF 权重,**官方已发布,默认直接下**(见 5.3),不必下 HF 原始权重、也不必装转换环境。只在要换转换参数、或权重是用户自己微调的时候才自己转,那时需要一个 4.8 GB 的转换环境(CPU 版 torch),转完可删。
- 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. 安装前检查
+本节与第 4、5、6、8 节都只适用于 SDK 路径,Docker 路径的前置写在 1.2。
+
```bash
# Linux + NVIDIA
nvidia-smi # 驱动 ≥535
@@ -59,7 +119,7 @@ df -h .
| 占位符 | 含义 |
|---|---|
-| `<WEIGHTS>` | Jev 权重目录的绝对路径;用户没有现成副本时按第 3 节下载 |
+| `<WEIGHTS>` | Jev 权重目录的绝对路径;用户没有现成副本时按第 3 节下载。**Docker 路径与 SDK 的 vLLM、SGLang 要它**,SDK 的 llama.cpp 与 Ollama 默认直接下 GGUF(5.3) |
| `<GPU>` | 用哪张卡(先按上面的命令确认它空闲);macOS 上不适用 |
以下命令都在仓库的 `scripts/minicpm-ocr-jev/` 下执行,虚拟环境建在 `/opt/venv-*`;macOS 上往 `/opt` 写要 sudo,建在 home 目录下即可(`~/venv-*`),后面各处路径跟着换。
@@ -73,7 +133,7 @@ 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>`:
+权重=[MiniCPM-OCR-Jev](https://huggingface.co/openbmb/MiniCPM-OCR-Jev)。**vLLM 与 SGLang 要这份 HF 权重**;llama.cpp 与 Ollama 用 GGUF,默认按 5.3 直接下,本步可跳过。用户已有副本时也跳过,把它的绝对路径当 `<WEIGHTS>`:
```bash
python3 -m venv /opt/venv-dl && /opt/venv-dl/bin/pip install -U "huggingface_hub[cli]"
@@ -184,16 +244,11 @@ python -m sglang.launch_server \
### 5.3 llama.cpp(对应 `llamacpp_deploy_jev_zh.md` 一)
+取源码并编译。先做[第 4 节](#4-探测上游支持动手装之前先做)的 grep 探针,再编译:
+
```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
@@ -203,7 +258,7 @@ cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j --target llama-server
```
-configure 日志里出现 `Including METAL backend`(mac)或 `Including CUDA backend`(Linux)才算后端挂上了。
+configure 日志里要出现 `Including METAL backend`(mac)或 `Including CUDA backend`(Linux),这一行说明目标后端已启用。
**仅 Linux**:CUDA toolkit 装在 `/usr/local/cuda` 之外时,先把它的库注册进 `ldconfig`,否则链接 `llama-server` 时会报几十个 `undefined reference to [email protected]`:
@@ -211,9 +266,23 @@ configure 日志里出现 `Including METAL backend`(mac)或 `Including CUDA
echo /path/to/cuda/lib64 | sudo tee /etc/ld.so.conf.d/cuda.conf && sudo ldconfig
```
-转 GGUF(语言模型与视觉编码器各一份,**两份都要从改过 `architectures` 的目录转**):
+**取 GGUF——默认走这条**:官方仓库已发布,语言模型与 `mmproj` 各下一份:
```bash
+HF_ENDPOINT=https://hf-mirror.com hf download openbmb/MiniCPM-OCR-Jev-gguf \
+ --include "MiniCPM-OCR-Jev-F16.gguf" "mmproj-model-f16.gguf" \
+ --local-dir ./models
+```
+
+- `F16` 是未量化的完整版本(3.78 GB)。显存或内存吃紧时把语言模型换成 `Q8_0`(2.01 GB)或 `Q4_K_M`(1.27 GB)——官方卡把前者标为接近无损、后者标为建议的最小档;`mmproj` 只有一个版本。
+- 走这条就**不需要** `<WEIGHTS>`,也不需要转换环境。ModelScope 上有同一个仓库 `OpenBMB/MiniCPM-OCR-Jev-gguf`。
+
+自己转只在两种情况下做:要换转换参数,或权重是用户自己微调的。那时另外装转换依赖(必须单独 venv,Debian/Ubuntu 等会按 PEP 668 拒绝装进系统 Python),语言模型与视觉编码器各转一份,**两份都要从改过 `architectures` 的目录转**:
+
+```bash
+python3 -m venv /opt/venv-convert && source /opt/venv-convert/bin/activate
+pip install -r requirements/requirements-convert_hf_to_gguf.txt
+
mkdir -p ./models/MiniCPM-OCR-Jev-gguf
for f in <WEIGHTS>/*; do
[ "$(basename "$f")" = config.json ] || ln -sf "$f" ./models/MiniCPM-OCR-Jev-gguf/
@@ -231,20 +300,20 @@ 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` 从转换目录转才会带上与训练一致的图片缩放下限,否则小图分数偏。
+(上面那段 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 \
+ -m ./models/MiniCPM-OCR-Jev-F16.gguf \
+ --mmproj ./models/mmproj-model-f16.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-探测上游支持动手装之前先做)。
+通过标准:起服日志出现 `decision model type: openbmb-minicpm-ocr-jev` 与 `listening on`;`curl http://127.0.0.1:18499/health` 返回 `{"status":"ok"}`。两个平台同此标准。日志里**没有**那行 `decision model type` 就是这个构建不认模型,回[第 4 节](#4-探测上游支持动手装之前先做)。自己转的话还要核一条:转出 3.6 GB + 641 MB 两份 GGUF。
### 5.4 Ollama(对应 `ollama_deploy_jev_zh.md` 一)
-四个后端里要求最轻的一条:不装 CUDA toolkit,也不编译任何东西。但**要先按 5.3 把 GGUF 转出来**(只需 clone + 装转换依赖,跳过编译)。
+四个后端里要求最轻的一条:引擎在 Ollama 安装包里,不装 CUDA toolkit,也不编译任何东西,连 llama.cpp 都不用取。**GGUF 按 5.3 那条 `hf download` 直接下**(自己转的话同 5.3,再把下面两个 `FROM` 换成转出来的文件名)。
```bash
# Linux
@@ -253,8 +322,8 @@ curl -fsSL https://ollama.com/install.sh | sh
brew install ollama
cat > Modelfile <<'EOF'
-FROM ./models/MiniCPM-OCR-Jev-bf16.gguf
-FROM ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf
+FROM ./models/MiniCPM-OCR-Jev-F16.gguf
+FROM ./models/mmproj-model-f16.gguf
EOF
ollama serve & # 默认 11434
@@ -310,6 +379,8 @@ PATH=/opt/venv-score/bin:$PATH bash sdk/start_score.sh 18501 http://127.0.0.1:18
## 7. 验证
+7.1 与 7.2 是 SDK 路径(打服务层的 18501);Docker 路径走 [7.3](#73-docker-路径用自带用例打分)。
+
### 7.1 起服自检
```bash
@@ -347,12 +418,39 @@ for name in ("01_text_putnam", "02_formula_putnam", "03_table_gb_standard"):
EOF
```
-通过标准:三行分数与参考值相差都在 0.02 以内。**这是判断"装对了"的唯一客观标准**——HTTP 200 不是,`/healthz` 也不是。
+通过标准:三行分数与参考值相差都在 0.02 以内。**这是判断「装对了」的唯一客观标准**——HTTP 200 不是,`/healthz` 也不是。
内置渲染器服务换成 `/v1/rm/score_best`、请求体给 `image` + `category` + `candidates`,服务自己渲染;两个候选都打,`best_index` 应指向 `ground_truth` 那个。
打分前必看 `verdict`(镜像接口)或 `error`(`/v1/score`):`0.0` 与 `-1.0` 是打分失败的固定返回值,不是低分。
+### 7.3 Docker 路径:用自带用例打分
+
+同样在 `scripts/minicpm-ocr-jev/` 下跑,端口是 1.2 里映射的 8030:
+
+```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 = {"input_form": "ternary",
+ "items": [{"case_id": name, "image": b64(c["block_image"]),
+ "render_image": b64(c["reference_render"]),
+ "ocr_text": text, "category": c["category"]}]}
+ req = urllib.request.Request("http://127.0.0.1:8030/v1/rm/score",
+ data=json.dumps(body).encode(), headers={"Content-Type": "application/json"})
+ r = json.load(urllib.request.urlopen(req))["results"][0]
+ print(f"{name:24} {r['verdict']:8} got {r['prob_yes']:.5f} reference {c['observed_prob_yes'][role]:.5f}")
+EOF
+```
+
+通过标准:三行 `verdict` 都是 `scored`,分数与参考值相差都在 0.02 以内。与 7.2 是同一口径,只是端点、字段名与端口不同(`/v1/rm/score`、`prob_yes`、8030)。
+
+上面把 `reference_render` 一起送了进去,走的是「渲染图由调用方提供」那条。删掉 `render_image` 那行、让镜像自己渲染,分数同样应落在 0.02 以内——镜像内置的就是参考渲染环境。块内选优改打 `/v1/rm/score_best`:请求体给 `image` + `category` + `candidates`,两个候选都打,`best_index` 应指向 `ground_truth` 那个。
+
## 8. 上游未就位时的临时路径
```
@@ -389,12 +487,22 @@ 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` 等共享库里。只换二进制仍然跑得起来、仍然报同样的错,据此会得出"换了也不行"的相反结论。
+⚠ **只换那个二进制无效**:原装 `llama-server` 只有 15 KB,模型支持在 `libllama-server-impl.so` 等共享库里。只换二进制仍然跑得起来、仍然报同样的错,据此会得出「换了也不行」的相反结论。
⚠ 这个换法**跨过了 Ollama 自己的兼容补丁**,为什么能跨过未查清;Ollama 升级后要重新验证。换完重起 `ollama serve` 与服务层,自检应为 `ok`。
## 9. 报错处理
+### Docker 路径
+
+| 现象 | 处理 |
+|---|---|
+| `could not select device driver "nvidia"` | NVIDIA Container Toolkit 没装或装完没重起 docker;先让 1.2 的那条 `--gpus all` 探针过 |
+| `/healthz` 一直是 `loading`,打分返回 503 | 还在加载权重,等;久了读 `docker logs minicpm-ocr-jev` 找真实异常 |
+| 422 | `input_form` 不是 `"ternary"`,或 `score_best_batch` 漏了 item 里的那一份 |
+| `verdict` 为 `encode_error` | 图片 base64 带了 `data:image/...;base64,` 前缀,或字节本身有问题 |
+| 400、提到 `max_items` | 单次请求候选总数超了默认的 64,拆批重发 |
+
### 安装
| 现象 | 处理 |
@@ -436,16 +544,18 @@ ln -sfn $L/libggml-cuda.so $O/cuda_v13/libggml-cuda.so
| 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 后可用 |
+| Docker 镜像 | 由 `serve/Dockerfile` 自建,引擎、打分服务与渲染环境都在镜像里;镜像内各件的实际版本以 `/healthz` 的 `scorer` 与 `render` 字段为准 |
| 服务层 | 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 |
+| GGUF | 官方仓 `MiniCPM-OCR-Jev-gguf`:`MiniCPM-OCR-Jev-F16.gguf` 3.78 GB + `mmproj-model-f16.gguf` 671 MB;与自己转的 bf16 打分等价(三个用例分差 ≤5e-5,2026-10-29 在 mac 上用 llama.cpp 与 Ollama 各实测一遍) |
| 硬件 | 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 节那几个数。
+- 说清走的是哪条路径(Docker 镜像 / SDK)与端口。两条路径的渲染环境不一样,绝对分不通用;能直接与发布数字对照的只有 Docker 路径。
+- 5090 与 M5 都只是验证用的机器,不要说必须用某一款。门槛是第 2 节那几个数(Docker 路径见 1.2)。
- 只汇报实际跑过的检查。没跑 7.2 就不要说分数对;`/healthz` 返回 `ok` 只能说服务起来了。
- 走了第 8 节的临时路径时必须明说,并说清它与文档路径的差别。
- 四个后端的分数不要互相当作独立验证,Ollama 与 llama.cpp 尤其——它们跑的是同一个二进制。
-- 分数只能当排序量用。不要替用户解释某个绝对分代表什么质量水平。
+- 分数不带阈值、不带标签,也没有校准到绝对质量刻度:同一批输入里比高低才有意义,单个绝对分换算不出某种质量水平——报分数时把这条边界一并说清。
diff --git a/docs/SKILL_jev_en.md b/docs/SKILL_jev_en.md
index 2900201..ccf55aa 100644
--- a/docs/SKILL_jev_en.md
+++ b/docs/SKILL_jev_en.md
@@ -1,17 +1,75 @@
---
-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.
+name: minicpm-ocr-jev-deploy
+description: Install, deploy and verify the MiniCPM-OCR Jev scoring service by either of two paths — the Docker image, or the SDK local deployment (four inference backends: vLLM / SGLang / llama.cpp / Ollama). Use when the user wants to start a Jev scoring service, deploy the Jev image or SDK, score OCR output for consistency or pick the best of several candidates, or troubleshoot startup and scoring errors.
---
-# MiniCPM-OCR Jev SDK local deployment
+# MiniCPM-OCR Jev 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.
+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 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.
+There are two deployment paths, using the same model and the same scoring logic: the **Docker image** carries the engine, the scoring service and the render environment in one container; the **SDK** 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/minicpm_ocr_jev_tutorial_en.md`, `docs/minicpm_ocr_jev_docker_api_en.md` and `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.
## 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.
+### 1.1 First settle which path
+
+| | Docker image (1.2) | SDK (1.3 onwards) |
+|---|---|---|
+| Render environment | Pinned Chromium and CJK fonts, built into the image | Installed by you (6.2), or the caller provides the render image (6.1) |
+| What the scores mean | Same render environment as the cloud API, so they can be compared against the published numbers directly | Ranking is stable; absolute values may differ in the third decimal |
+| What to install | Docker + NVIDIA Container Toolkit | Two virtual environments: engine + service layer |
+| Inference backend | vLLM, fixed inside the image | One of vLLM / SGLang / llama.cpp / Ollama |
+| Platforms | Linux + NVIDIA only | Linux + NVIDIA / macOS (see 1.3) |
+| Suited to | Comparing against the published numbers, not installing a render environment yourself | No Docker, macOS, render images already in hand, or a specific backend wanted |
+
+When the machine has Docker and an NVIDIA GPU and the user has no preference, take the Docker image. **The Docker path needs only 1.2 plus 7.3, and section 3 for the weights; sections 2, 4, 5, 6 and 8 are all SDK steps.**
+
+### 1.2 Docker image (mirrors path one in `minicpm_ocr_jev_tutorial_en.md`)
+
+Prerequisites: Docker and the NVIDIA Container Toolkit installed (`docker run --rm --gpus all ubuntu nvidia-smi` printing the GPU is enough), driver ≥535, VRAM ≥12 GB, and the weights `<WEIGHTS>` already fetched as in section 3.
+
+```bash
+cd scripts/minicpm-ocr-jev
+docker build -f serve/Dockerfile -t minicpm-ocr-jev-1-0:latest .
+
+docker run -d --name minicpm-ocr-jev --gpus '"device=<GPU>"' \
+ -p 127.0.0.1:8030:8030 \
+ -v <WEIGHTS>:/weights:ro \
+ minicpm-ocr-jev-1-0:latest 8030 /weights
+```
+
+On a slow network, add `--build-arg PIP_INDEX_URL=<mirror>` and `--build-arg PLAYWRIGHT_DOWNLOAD_HOST=<mirror>` to the build (section 3 has usable values).
+
+Pass criteria: `curl -f http://127.0.0.1:8030/healthz` reports `status` as `ok`. `loading` means the weights are still being loaded and scoring returns 503; wait for it to turn `ok`.
+
+Scoring:
+
+```bash
+curl -s http://127.0.0.1:8030/v1/rm/score -H 'Content-Type: application/json' -d '{
+ "input_form": "ternary",
+ "items": [
+ {"case_id": "blk-001", "image": "<base64>",
+ "ocr_text": "the OCR text to score", "category": "text"}
+ ]
+}'
+```
+
+Four endpoints: `/healthz`, `/v1/rm/score` (one score per block), `/v1/rm/score_best` (best of N candidates for one block) and `/v1/rm/score_best_batch` (best-of-N for many blocks, which is the one to use when there are many). The full field definitions are in `minicpm_ocr_jev_docker_api_en.md`; the rules to keep to when calling:
+
+- `input_form` is fixed at `"ternary"`, and `score_best_batch` needs it again inside every item — 422 without it.
+- `image` takes the base64 body of a PNG or JPEG **without** the `data:image/png;base64,` prefix; with the prefix that item comes back as `encode_error`.
+- `category` is one of `text` / `formula` / `table` and **has to match what the block really is**: a formula block sent as `text` is rendered literally, which does not error but does distort the score.
+- Check `verdict` before reading a score: `0.0` and `-1.0` are the fixed return values for a failed scoring, not low scores.
+- When render images are already in hand, send `items[].render_image` (`render_images` for `score_best*`) and the service skips rendering.
+- The number of candidates in one request is capped by `max_items` (64 by default; 400 above that), and `threshold` (0.5 by default) only affects `throughput_rate` in the summary, never any `prob_yes`.
+
+Once it is up, check the scores with the bundled cases as in [7.3](#73-docker-path-score-the-bundled-cases) — `/healthz` returning `ok` only says the service came up.
+
+### 1.3 SDK: picking a backend and a service shape
+
+On the SDK path, settle two more 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:
@@ -30,15 +88,17 @@ The four backends differ a lot in what they cost to set up; pick by the user's c
| 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 |
+| Ollama | Not needed | No | None (the engine ships with Ollama) | 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.
+- llama.cpp and Ollama use GGUF weights, which are **published officially and downloaded directly by default** (see 5.3) — no HF weights and no conversion environment. Convert them yourself only when the user wants different conversion settings or the weights are their own fine-tune; that needs a 4.8 GB conversion environment (CPU torch), which 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
+This section, like sections 4, 5, 6 and 8, applies to the SDK path only; the Docker path's prerequisites are in 1.2.
+
```bash
# Linux + NVIDIA
nvidia-smi # driver ≥535
@@ -59,7 +119,7 @@ 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 |
+| `<WEIGHTS>` | Absolute path of the Jev weights directory; download it as in section 3 when the user has no copy. **Needed by the Docker path and by SDK vLLM and SGLang** — SDK llama.cpp and Ollama download the GGUF directly by default (5.3) |
| `<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.
@@ -73,7 +133,7 @@ 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>`:
+The weights are [MiniCPM-OCR-Jev](https://huggingface.co/openbmb/MiniCPM-OCR-Jev). **vLLM and SGLang need these HF weights**; llama.cpp and Ollama use GGUF, downloaded directly as in 5.3, so they can skip this step. Skip it as well 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]"
@@ -185,16 +245,11 @@ Pass criteria: the log reaches `The server is fired up and ready to roll!`; `cur
### 5.3 llama.cpp (mirrors `llamacpp_deploy_jev_en.md` §1)
+Fetch the source and build it. Run the grep probe from [section 4](#4-probe-upstream-support-do-this-before-installing-anything) before building:
+
```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
@@ -204,7 +259,7 @@ 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).
+The configure log has to say `Including METAL backend` (mac) or `Including CUDA backend` (Linux); that line is what confirms the intended backend is enabled.
**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]`:
@@ -212,9 +267,23 @@ The backend is only attached if the configure log says `Including METAL backend`
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`**):
+**Getting the GGUF — this is the default path**: both files are published officially, one for the language model and one for the `mmproj`:
```bash
+HF_ENDPOINT=https://hf-mirror.com hf download openbmb/MiniCPM-OCR-Jev-gguf \
+ --include "MiniCPM-OCR-Jev-F16.gguf" "mmproj-model-f16.gguf" \
+ --local-dir ./models
+```
+
+- `F16` is the unquantized build (3.78 GB). When VRAM or memory is tight, swap the language model for `Q8_0` (2.01 GB) or `Q4_K_M` (1.27 GB) — the model card labels the first near-lossless and the second the smallest recommended build; there is only one `mmproj` build.
+- This path needs **no** `<WEIGHTS>` and no conversion environment. The same repository is on ModelScope as `OpenBMB/MiniCPM-OCR-Jev-gguf`.
+
+Converting it yourself is for two cases only: the user wants different conversion settings, or the weights are their own fine-tune. That needs the conversion dependencies installed separately (in their own venv — Debian/Ubuntu and others refuse to install into the system Python under PEP 668), and the language model and the vision encoder converted separately, **both from the directory with the patched `architectures`**:
+
+```bash
+python3 -m venv /opt/venv-convert && source /opt/venv-convert/bin/activate
+pip install -r requirements/requirements-convert_hf_to_gguf.txt
+
mkdir -p ./models/MiniCPM-OCR-Jev-gguf
for f in <WEIGHTS>/*; do
[ "$(basename "$f")" = config.json ] || ln -sf "$f" ./models/MiniCPM-OCR-Jev-gguf/
@@ -232,20 +301,20 @@ 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.
+(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. Self-converted files are named differently from the official pair, so change the start command below to match.
```bash
./build/bin/llama-server \
- -m ./models/MiniCPM-OCR-Jev-bf16.gguf \
- --mmproj ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf \
+ -m ./models/MiniCPM-OCR-Jev-F16.gguf \
+ --mmproj ./models/mmproj-model-f16.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).
+Pass criteria: 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). When converting yourself, also check one more thing: the conversion produces two GGUF files of 3.6 GB and 641 MB.
### 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).
+The lightest of the four: the engine ships inside the Ollama package, there is no CUDA toolkit, nothing to compile, and llama.cpp is not needed at all. **Get the GGUF with the same `hf download` as in 5.3** (or convert it as in 5.3, and then change the two `FROM` lines below to the files you produced).
```bash
# Linux
@@ -254,8 +323,8 @@ curl -fsSL https://ollama.com/install.sh | sh
brew install ollama
cat > Modelfile <<'EOF'
-FROM ./models/MiniCPM-OCR-Jev-bf16.gguf
-FROM ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf
+FROM ./models/MiniCPM-OCR-Jev-F16.gguf
+FROM ./models/mmproj-model-f16.gguf
EOF
ollama serve & # 11434 by default
@@ -314,6 +383,8 @@ Replace `sglang.yaml` with `llamacpp.yaml` / `ollama.yaml`. **Without that varia
## 7. Verification
+7.1 and 7.2 are the SDK path (they call the service layer on 18501); for the Docker path go to [7.3](#73-docker-path-score-the-bundled-cases).
+
### 7.1 Startup self-check
```bash
@@ -357,6 +428,33 @@ For the render+score service, switch to `/v1/rm/score_best` and give the body `i
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.
+### 7.3 Docker path: score the bundled cases
+
+Run this from `scripts/minicpm-ocr-jev/` as well, against the 8030 mapped in 1.2:
+
+```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 = {"input_form": "ternary",
+ "items": [{"case_id": name, "image": b64(c["block_image"]),
+ "render_image": b64(c["reference_render"]),
+ "ocr_text": text, "category": c["category"]}]}
+ req = urllib.request.Request("http://127.0.0.1:8030/v1/rm/score",
+ data=json.dumps(body).encode(), headers={"Content-Type": "application/json"})
+ r = json.load(urllib.request.urlopen(req))["results"][0]
+ print(f"{name:24} {r['verdict']:8} got {r['prob_yes']:.5f} reference {c['observed_prob_yes'][role]:.5f}")
+EOF
+```
+
+Pass criteria: all three `verdict`s are `scored` and all three scores are within 0.02 of the reference. This is the same test as 7.2, only the endpoint, the field name and the port differ (`/v1/rm/score`, `prob_yes`, 8030).
+
+The call above sends `reference_render` along with the request, which is the "caller provides the render image" shape. Drop the `render_image` line to let the image render for itself and the scores should still land within 0.02 — the render environment built into the image is the reference one. For best-of-N within a block, call `/v1/rm/score_best` instead with `image` plus `category` plus `candidates`; both candidates get scored and `best_index` should point at the `ground_truth` one.
+
## 8. Temporary path while upstream support is missing
```
@@ -399,6 +497,16 @@ ln -sfn $L/libggml-cuda.so $O/cuda_v13/libggml-cuda.so
## 9. Error handling
+### Docker path
+
+| Symptom | What to do |
+|---|---|
+| `could not select device driver "nvidia"` | The NVIDIA Container Toolkit is missing, or docker was not restarted after installing it; get the `--gpus all` probe in 1.2 to pass first |
+| `/healthz` stays at `loading` and scoring returns 503 | The weights are still loading; wait, and read `docker logs minicpm-ocr-jev` for the real exception if it drags on |
+| 422 | `input_form` is not `"ternary"`, or `score_best_batch` is missing the copy inside an item |
+| `verdict` is `encode_error` | The base64 carries a `data:image/...;base64,` prefix, or the bytes themselves are bad |
+| 400 mentioning `max_items` | One request carried more candidates than the default 64; split the batch |
+
### Installation
| Symptom | What to do |
@@ -440,16 +548,18 @@ ln -sfn $L/libggml-cuda.so $O/cuda_v13/libggml-cuda.so
| 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 |
+| Docker image | Built from `serve/Dockerfile`, with the engine, the scoring service and the render environment all inside it; for the versions actually in the image, read the `scorer` and `render` fields of `/healthz` |
| 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 |
+| GGUF | Official `MiniCPM-OCR-Jev-gguf` repository: `MiniCPM-OCR-Jev-F16.gguf` 3.78 GB + `mmproj-model-f16.gguf` 671 MB; equivalent in scoring to a self-converted bf16 pair (three cases, scores within 5e-5, measured on a mac through both llama.cpp and Ollama on 2026-10-29) |
| 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.
+- Say which path was taken (Docker image or SDK) and on which port. The two paths have different render environments, so their absolute scores are not interchangeable, and only the Docker path's can be compared against the published numbers directly.
+- 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 (1.2 for the Docker path).
- 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.
+- The scores carry no threshold and no label, and they are not calibrated to an absolute quality scale: comparing them within one set of inputs is what is meaningful, and a single absolute score does not translate into a level of quality. State that boundary alongside the numbers.
diff --git a/docs/llamacpp_deploy_jev_en.md b/docs/llamacpp_deploy_jev_en.md
index e3f1562..e0894de 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**.
-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.
+This backend differs from the others in two ways: the model comes in GGUF format, published officially and ready to download, 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:
@@ -20,7 +20,7 @@ Both services share one forward engine. The only difference is where the render
## Deployment steps
-1. Build the engine → convert to GGUF → start the forward engine (both services need it)
+1. Build the engine → get the GGUF → start the forward engine (both services need it)
2. Pick one:
- **Score service** → install the service environment → start the service
- **Render+score service** → install the render environment → start the service
@@ -62,22 +62,14 @@ brew install cmake
## 1. Forward engine
-### Source and conversion dependencies
+### Source
-Two things, both needed: fetch the source (used for the build and for the GGUF conversion), and install the Python dependencies the conversion needs.
+The build needs the source tree:
```bash
git clone https://github.com/ggml-org/llama.cpp.git && cd llama.cpp
-
-# 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/activate
-pip install -r requirements/requirements-convert_hf_to_gguf.txt
```
-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`).
-
### Build
```bash
@@ -92,42 +84,31 @@ cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j --target llama-server
```
-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.
+The configure log has to say `Including CUDA backend` (Linux) or `Including METAL backend` (macOS); that line is what confirms the intended backend is enabled.
-### Convert to GGUF
+### Get the GGUF
-Convert the language model and the vision encoder (`mmproj`) separately. The converter identifies the model by `architectures` in `config.json`, which has to be `MiniCPMOCRForSequenceClassification`. The original weights directory stays untouched: create a separate conversion directory, symlink every other file into it, put an edited copy of `config.json` there, and run both conversions from it:
+Two files are needed: one for the language model, one for the vision encoder (`mmproj`). Both are published in the official [MiniCPM-OCR-Jev-gguf](https://huggingface.co/openbmb/MiniCPM-OCR-Jev-gguf) repository, so just download them:
```bash
cd llama.cpp
-source /opt/venv-convert/bin/activate
-mkdir -p ./models/MiniCPM-OCR-Jev-gguf
-for f in ./models/MiniCPM-OCR-Jev/*; do
- [ "$(basename "$f")" = config.json ] || ln -sf "$PWD/$f" ./models/MiniCPM-OCR-Jev-gguf/
-done
-python - <<'EOF'
-import json
-c = json.load(open("./models/MiniCPM-OCR-Jev/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
+HF_ENDPOINT=https://hf-mirror.com hf download openbmb/MiniCPM-OCR-Jev-gguf \
+ --include "MiniCPM-OCR-Jev-F16.gguf" "mmproj-model-f16.gguf" \
+ --local-dir ./models
```
-Convert the `mmproj` from the conversion directory too: that is what gives it the same lower bound on image size as in training, so a block image below it is upscaled before encoding. Without it, small images score off.
+- The `hf` command comes from `huggingface_hub`; install it into any virtual environment with `pip install -U "huggingface_hub[cli]"`.
+- `F16` is the unquantized build (3.78 GB). When VRAM or memory is tight, swap the language model in `--include` for a quantized build: `Q8_0` (2.01 GB) or `Q4_K_M` (1.27 GB) — the model card labels the first near-lossless and the second the smallest recommended build. There is only one `mmproj` build; always use `mmproj-model-f16.gguf`.
+- The same repository is on ModelScope as `OpenBMB/MiniCPM-OCR-Jev-gguf`.
+- The GGUF carries the `systemone` chat template and the decision-model marker, which is how the engine recognises it as a scoring model — no template arguments are needed at startup.
### Start
```bash
cd llama.cpp
./build/bin/llama-server \
- -m ./models/MiniCPM-OCR-Jev-bf16.gguf \
- --mmproj ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf \
+ -m ./models/MiniCPM-OCR-Jev-F16.gguf \
+ --mmproj ./models/mmproj-model-f16.gguf \
-ngl 99 \
-c 32768 \
--port 18499
@@ -138,6 +119,8 @@ cd llama.cpp
- `-c 32768`: context length, shared by the parallel slots.
- `-np N`: serve N requests in parallel.
+The startup log has to show `decision model type: openbmb-minicpm-ocr-jev` and `listening on`, which means the engine recognised the model; `curl http://127.0.0.1:18499/health` then returns `{"status":"ok"}`.
+
Each request is a single forward pass and generates no tokens. Every request carries exactly two images — the original first, then the render. The model has no LM head, so the text-generation endpoints are unavailable.
---
@@ -306,7 +289,7 @@ curl -s http://127.0.0.1:18501/healthz
```
```json
-{"status": "ok", "served_model": "./models/MiniCPM-OCR-Jev-bf16.gguf",
+{"status": "ok", "served_model": "./models/MiniCPM-OCR-Jev-F16.gguf",
"prompt": {"template_md5": "9aab68e8ba8ab4da17ba9752bddb199c",
"source": "server_template",
"last_token": null, "expected_last_token": 271,
diff --git a/docs/llamacpp_deploy_jev_zh.md b/docs/llamacpp_deploy_jev_zh.md
index 29c79fe..31ec5df 100644
--- a/docs/llamacpp_deploy_jev_zh.md
+++ b/docs/llamacpp_deploy_jev_zh.md
@@ -6,7 +6,7 @@
本文介绍SDK部署模式下,以 llama.cpp 的 `llama-server` 作为前向引擎时,**不带渲染器服务**与**内置渲染器服务**的安装、启动、接口与请求格式。
-本后端与其他后端有两点不同:模型要先转成 GGUF 格式;prompt 由引擎按 GGUF 内置的模板自己拼,不由 SDK 拼。
+本后端与其他后端有两点不同:模型用 GGUF 格式,官方已发布,直接下载即可;prompt 由引擎按 GGUF 内置的模板自己拼,不由 SDK 拼。
两种服务共用同一个前向引擎,区别只在渲染图从哪里来:
@@ -20,7 +20,7 @@
## 部署流程
-1. 编引擎 → 转 GGUF → 起前向引擎(两种服务都要)
+1. 编引擎 → 取 GGUF → 起前向引擎(两种服务都要)
2. 二选一:
- **不带渲染器服务** → 装服务环境 → 起服务
- **内置渲染器服务** → 装渲染环境 → 起服务
@@ -62,22 +62,14 @@ brew install cmake
## 一、前向引擎
-### 准备源码与转换依赖
+### 准备源码
-两件事都要:取源码(编译与转 GGUF 都用它),装转 GGUF 的 Python 依赖。
+编译需要源码树:
```bash
git clone https://github.com/ggml-org/llama.cpp.git && cd llama.cpp
-
-# 虚拟环境放哪都行,下面各处的 /opt/venv-* 同理
-# macOS:往 /opt 写要 sudo,放 home 目录即可,例如 ~/venv-convert
-python3 -m venv /opt/venv-convert
-source /opt/venv-convert/bin/activate
-pip install -r requirements/requirements-convert_hf_to_gguf.txt
```
-转换依赖装进单独的虚拟环境:Debian/Ubuntu 等系统会拒绝往系统 Python 里装。慢网下加 `-i https://mirrors.ustc.edu.cn/pypi/simple`。
-
### 编译
```bash
@@ -92,42 +84,31 @@ cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j --target llama-server
```
-只转 GGUF 不起引擎的话(例如用 Ollama 做前向),这一步可以跳过 —— 转换是纯 Python,不需要编译产物。
+配置日志里要出现 `Including CUDA backend`(Linux)或 `Including METAL backend`(macOS),这一行说明目标后端已启用。
-### 转 GGUF
+### 取 GGUF
-语言模型与视觉编码器(`mmproj`)各转一份。转换器按 `config.json` 里的 `architectures` 认模型,需要它是 `MiniCPMOCRForSequenceClassification`。原权重目录不改:另建一个转换用目录,其余文件软链过去,只放一份改过的 `config.json`,两份都从这个目录转:
+两份都要:语言模型一份,视觉编码器(`mmproj`)一份。官方仓库 [MiniCPM-OCR-Jev-gguf](https://huggingface.co/openbmb/MiniCPM-OCR-Jev-gguf) 已发布,直接下载即可:
```bash
cd llama.cpp
-source /opt/venv-convert/bin/activate
-mkdir -p ./models/MiniCPM-OCR-Jev-gguf
-for f in ./models/MiniCPM-OCR-Jev/*; do
- [ "$(basename "$f")" = config.json ] || ln -sf "$PWD/$f" ./models/MiniCPM-OCR-Jev-gguf/
-done
-python - <<'EOF'
-import json
-c = json.load(open("./models/MiniCPM-OCR-Jev/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
+HF_ENDPOINT=https://hf-mirror.com hf download openbmb/MiniCPM-OCR-Jev-gguf \
+ --include "MiniCPM-OCR-Jev-F16.gguf" "mmproj-model-f16.gguf" \
+ --local-dir ./models
```
-`mmproj` 也要从转换用目录转:这样它才带上与训练一致的图片缩放下限,小于下限的块图会先放大再编码;否则小图分数会偏。
+- `hf` 命令来自 `huggingface_hub`,没有的话装进任一虚拟环境:`pip install -U "huggingface_hub[cli]"`。
+- `F16` 是未量化的完整版本(3.78 GB)。显存或内存吃紧时,把 `--include` 里的语言模型换成量化版本:`Q8_0`(2.01 GB)或 `Q4_K_M`(1.27 GB)——官方卡把前者标为接近无损、后者标为建议的最小档。`mmproj` 只有一个版本,始终用 `mmproj-model-f16.gguf`。
+- ModelScope 上有同一个仓库:`OpenBMB/MiniCPM-OCR-Jev-gguf`。
+- GGUF 自带 `systemone` 对话模板与决策模型标识,引擎靠它们认出这是打分模型,所以起服时不需要任何模板参数。
### 启动
```bash
cd llama.cpp
./build/bin/llama-server \
- -m ./models/MiniCPM-OCR-Jev-bf16.gguf \
- --mmproj ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf \
+ -m ./models/MiniCPM-OCR-Jev-F16.gguf \
+ --mmproj ./models/mmproj-model-f16.gguf \
-ngl 99 \
-c 32768 \
--port 18499
@@ -138,6 +119,8 @@ cd llama.cpp
- `-c 32768`:上下文长度,由并行槽位共享。
- `-np N`:并行处理 N 个请求。
+起服日志里要出现 `decision model type: openbmb-minicpm-ocr-jev` 与 `listening on`,说明引擎认出了这个模型;此时 `curl http://127.0.0.1:18499/health` 返回 `{"status":"ok"}`。
+
每个请求是一次前向,不生成任何 token。每个请求固定两张图:先原图、后渲染图;模型没有 LM head,文本生成类端点不可用。
---
@@ -303,7 +286,7 @@ curl -s http://127.0.0.1:18501/healthz
```
```json
-{"status": "ok", "served_model": "./models/MiniCPM-OCR-Jev-bf16.gguf",
+{"status": "ok", "served_model": "./models/MiniCPM-OCR-Jev-F16.gguf",
"prompt": {"template_md5": "9aab68e8ba8ab4da17ba9752bddb199c",
"source": "server_template",
"last_token": null, "expected_last_token": 271,
diff --git a/docs/ollama_deploy_jev_en.md b/docs/ollama_deploy_jev_en.md
index 637c60d..7ce9043 100644
--- a/docs/ollama_deploy_jev_en.md
+++ b/docs/ollama_deploy_jev_en.md
@@ -6,7 +6,7 @@
This document covers the SDK deployment path with Ollama as the forward engine: how to install, start, and call the **score service** and the **render+score service**.
-Ollama serves MiniCPM-OCR Jev as a decision model. Two things set it apart from the other backends: the model has to be converted to GGUF and registered with Ollama first, and the prompt is assembled by the engine from a template baked into the GGUF rather than by the SDK.
+Ollama serves MiniCPM-OCR Jev as a decision model. Two things set it apart from the other backends: the model is registered with Ollama in GGUF format, published officially and ready to download, 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:
@@ -20,7 +20,7 @@ Both services share one forward engine. The only difference is where the render
## Deployment steps
-1. Install Ollama → convert to GGUF and register the model → start the forward engine (both services need it)
+1. Install Ollama → get the GGUF and register the model → start the forward engine (both services need it)
2. Pick one:
- **Score service** → install the service environment → start the service
- **Render+score service** → install the render environment → start the service
@@ -36,7 +36,6 @@ The engine and the service must go into two separate virtual environments; do no
| 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**:
@@ -66,17 +65,30 @@ brew install ollama
# Download from https://ollama.com/download/windows
```
-### Register the model
+### Get the GGUF
+
+Two files are needed: one for the language model, one for the vision encoder (`mmproj`). Both are published in the official [MiniCPM-OCR-Jev-gguf](https://huggingface.co/openbmb/MiniCPM-OCR-Jev-gguf) repository, so just download them — there is no need to install llama.cpp or to set up a conversion environment:
-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.
+```bash
+HF_ENDPOINT=https://hf-mirror.com hf download openbmb/MiniCPM-OCR-Jev-gguf \
+ --include "MiniCPM-OCR-Jev-F16.gguf" "mmproj-model-f16.gguf" \
+ --local-dir ./models
+```
+
+- The `hf` command comes from `huggingface_hub`; install it into any virtual environment with `pip install -U "huggingface_hub[cli]"`.
+- `F16` is the unquantized build (3.78 GB). When VRAM or memory is tight, swap the language model in `--include` for a quantized build: `Q8_0` (2.01 GB) or `Q4_K_M` (1.27 GB) — the model card labels the first near-lossless and the second the smallest recommended build. There is only one `mmproj` build; always use `mmproj-model-f16.gguf`.
+- The same repository is on ModelScope as `OpenBMB/MiniCPM-OCR-Jev-gguf`.
+- If you swap in a quantized build, change the first line of the `Modelfile` below to the file you downloaded.
+
+### Register the model
-The resulting GGUF carries the `systemone` chat template and the decision-model marker, which is how Ollama recognises it as a decision model.
+The 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:
```
-FROM ./models/MiniCPM-OCR-Jev-bf16.gguf
-FROM ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf
+FROM ./models/MiniCPM-OCR-Jev-F16.gguf
+FROM ./models/mmproj-model-f16.gguf
```
Register it and confirm:
diff --git a/docs/ollama_deploy_jev_zh.md b/docs/ollama_deploy_jev_zh.md
index 7116e23..87cdb24 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 拼。
两种服务共用同一个前向引擎,区别只在渲染图从哪里来:
@@ -20,7 +20,7 @@ Ollama 把 MiniCPM-OCR Jev 当作决策模型(decision model)来服务。与
## 部署流程
-1. 装 Ollama → 转 GGUF 并注册模型 → 起前向引擎(两种服务都要)
+1. 装 Ollama → 取 GGUF 并注册模型 → 起前向引擎(两种服务都要)
2. 二选一:
- **不带渲染器服务** → 装服务环境 → 起服务
- **内置渲染器服务** → 装渲染环境 → 起服务
@@ -36,7 +36,6 @@ Ollama 把 MiniCPM-OCR Jev 当作决策模型(decision model)来服务。与
| 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 |
**系统包**:
@@ -66,17 +65,30 @@ brew install ollama
# 从 https://ollama.com/download/windows 下载安装
```
-### 注册模型
+### 取 GGUF
+
+两份都要:语言模型一份,视觉编码器(`mmproj`)一份。官方仓库 [MiniCPM-OCR-Jev-gguf](https://huggingface.co/openbmb/MiniCPM-OCR-Jev-gguf) 已发布,直接下载即可,不必安装 llama.cpp,也不必准备转换环境:
-先把权重转成 GGUF,两步都在 llama.cpp 部署文档里:先按[准备源码与转换依赖](./llamacpp_deploy_jev_zh.md#准备源码与转换依赖)取源码、装转换依赖(**跳过它的「编译」节**,转换是纯 Python),再按[转 GGUF](./llamacpp_deploy_jev_zh.md#转-gguf)转出两份 GGUF。
+```bash
+HF_ENDPOINT=https://hf-mirror.com hf download openbmb/MiniCPM-OCR-Jev-gguf \
+ --include "MiniCPM-OCR-Jev-F16.gguf" "mmproj-model-f16.gguf" \
+ --local-dir ./models
+```
+
+- `hf` 命令来自 `huggingface_hub`,没有的话装进任一虚拟环境:`pip install -U "huggingface_hub[cli]"`。
+- `F16` 是未量化的完整版本(3.78 GB)。显存或内存吃紧时,把 `--include` 里的语言模型换成量化版本:`Q8_0`(2.01 GB)或 `Q4_K_M`(1.27 GB)——官方卡把前者标为接近无损、后者标为建议的最小档。`mmproj` 只有一个版本,始终用 `mmproj-model-f16.gguf`。
+- ModelScope 上有同一个仓库:`OpenBMB/MiniCPM-OCR-Jev-gguf`。
+- 换成量化版本时,下面 `Modelfile` 的第一行要改成你下载的那一份。
+
+### 注册模型
-转出来的 GGUF 自带 `systemone` 对话模板与决策模型标识,Ollama 靠它们认出这是决策模型。
+GGUF 自带 `systemone` 对话模板与决策模型标识,Ollama 靠它们认出这是决策模型。
写一个 `Modelfile`,第一个 `FROM` 是语言模型,第二个是视觉编码器:
```
-FROM ./models/MiniCPM-OCR-Jev-bf16.gguf
-FROM ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf
+FROM ./models/MiniCPM-OCR-Jev-F16.gguf
+FROM ./models/mmproj-model-f16.gguf
```
注册并确认: