Skip to content

Fast, accurate OCR with correctness assessment.

private latest jev depoly for PR v2

LuMingconge5398669a290
diff --git a/docs/llamacpp_deploy_jev_en.md b/docs/llamacpp_deploy_jev_en.md
index d374cb0..40ad92a 100644
--- a/docs/llamacpp_deploy_jev_en.md
+++ b/docs/llamacpp_deploy_jev_en.md
@@ -25,7 +25,7 @@ Both services share one forward engine. The only difference is where the render
- **Score service** → install the service environment → start the service
- **Render+score service** → install the render environment → start the service
-The engine and the service must go into two separate virtual environments; do not merge them. All commands below run from `scripts/minicpm-ocr-jev/`.
+The engine and the service must go into two separate virtual environments; do not merge them.
## Requirements
@@ -66,21 +66,34 @@ These are used only during conversion and have nothing to do with the two servic
### Convert to GGUF
-Convert the language model and the vision encoder (`mmproj`) separately. The weights directory must contain `minicpm_ocr_jev.json`, which is how the converter recognises a MiniCPM-OCR Jev checkpoint:
+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:
```bash
-echo '{}' > ./models/MiniCPM-OCR-Jev/minicpm_ocr_jev.json
-
-python convert_hf_to_gguf.py ./models/MiniCPM-OCR-Jev \
+cd llama.cpp
+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 --mmproj \
+python convert_hf_to_gguf.py ./models/MiniCPM-OCR-Jev-gguf --mmproj \
--outtype bf16 --outfile ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf
```
+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.
+
### Start
```bash
+cd llama.cpp
./build/bin/llama-server \
-m ./models/MiniCPM-OCR-Jev-bf16.gguf \
--mmproj ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf \
@@ -127,6 +140,7 @@ Pillow 12.3.0
`JEV_BACKEND_CONFIG` points at the llama.cpp backend config; the arguments are the service port and the engine address, in that order:
```bash
+cd scripts/minicpm-ocr-jev/
JEV_BACKEND_CONFIG=sdk/backends/llamacpp.yaml \
PATH=/opt/venv-score/bin:$PATH bash sdk/start_score.sh 18501 http://127.0.0.1:18499
```
@@ -154,7 +168,7 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '
{"results": [{"prob_1": 0.00227, "error": null}]}
```
-All three fields are required: `original_image` is the base64 of the original block image, `render_image` is the base64 of that candidate rendered back into an image, and `ocr_text` is the candidate text itself. The base64 carries **no** `data:image/png;base64,` prefix, unlike the image API.
+All three fields are required: `original_image` is the base64 of the original block image, `render_image` is the base64 of that candidate rendered back into an image, and `ocr_text` is the candidate text itself. The base64 carries **no** `data:image/png;base64,` prefix, the same as the image API.
### Fields and limits
@@ -174,12 +188,14 @@ This service calls the scoring layer in-process: it does **not** need a separate
### Install
```bash
+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:
```bash
+cd scripts/minicpm-ocr-jev/
PIP_INDEX_URL=https://<mirror>/simple \
PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
bash sdk/setup_render.sh /opt/venv-render
@@ -190,6 +206,7 @@ PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
The arguments are the service port and the engine address, in that order:
```bash
+cd scripts/minicpm-ocr-jev/
JEV_BACKEND_CONFIG=sdk/backends/llamacpp.yaml \
PATH=/opt/venv-render/bin:$PATH bash sdk/start_render_score.sh 18500 http://127.0.0.1:18499
```
@@ -252,7 +269,7 @@ curl -s http://127.0.0.1:18501/healthz
```
```json
-{"status": "ok", "served_model": "MiniCPM-OCR-Jev-bf16",
+{"status": "ok", "served_model": "./models/MiniCPM-OCR-Jev-bf16.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 69b606d..baccb56 100644
--- a/docs/llamacpp_deploy_jev_zh.md
+++ b/docs/llamacpp_deploy_jev_zh.md
@@ -25,7 +25,7 @@ llama.cpp 是 C++ 实现的轻量推理后端。与其他后端的两点不同
- **不带渲染器服务** → 装服务环境 → 起服务
- **内置渲染器服务** → 装渲染环境 → 起服务
-引擎与服务必须装在两个虚拟环境里,不要合并。以下命令都在 `scripts/minicpm-ocr-jev/` 目录下执行。
+引擎与服务必须装在两个虚拟环境里,不要合并。
## 环境要求
@@ -66,21 +66,34 @@ protobuf >=4.21.0,<5.0.0
### 转 GGUF
-语言模型与视觉编码器(`mmproj`)各转一份。权重目录里必须有 `minicpm_ocr_jev.json`,转换器靠它认出这是 MiniCPM-OCR Jev:
+语言模型与视觉编码器(`mmproj`)各转一份。转换器按 `config.json` 里的 `architectures` 认模型,需要它是 `MiniCPMOCRForSequenceClassification`。原权重目录不改:另建一个转换用目录,其余文件软链过去,只放一份改过的 `config.json`,两份都从这个目录转:
```bash
-echo '{}' > ./models/MiniCPM-OCR-Jev/minicpm_ocr_jev.json
-
-python convert_hf_to_gguf.py ./models/MiniCPM-OCR-Jev \
+cd llama.cpp
+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 --mmproj \
+python convert_hf_to_gguf.py ./models/MiniCPM-OCR-Jev-gguf --mmproj \
--outtype bf16 --outfile ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf
```
+`mmproj` 也要从转换用目录转:这样它才带上与训练一致的图片缩放下限,小于下限的块图会先放大再编码;否则小图分数会偏。
+
### 启动
```bash
+cd llama.cpp
./build/bin/llama-server \
-m ./models/MiniCPM-OCR-Jev-bf16.gguf \
--mmproj ./models/mmproj-MiniCPM-OCR-Jev-bf16.gguf \
@@ -127,6 +140,7 @@ Pillow 12.3.0
`JEV_BACKEND_CONFIG` 指向 llama.cpp 的后端配置,参数依次为服务端口、引擎地址:
```bash
+cd scripts/minicpm-ocr-jev/
JEV_BACKEND_CONFIG=sdk/backends/llamacpp.yaml \
PATH=/opt/venv-score/bin:$PATH bash sdk/start_score.sh 18501 http://127.0.0.1:18499
```
@@ -154,7 +168,7 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '
{"results": [{"prob_1": 0.00227, "error": null}]}
```
-三个字段都是必填:`original_image` 是原始块图的 base64,`render_image` 是该候选渲染回图片后的 base64,`ocr_text` 是候选文本本身。base64 **不带** `data:image/png;base64,` 前缀,与镜像接口不同。
+三个字段都是必填:`original_image` 是原始块图的 base64,`render_image` 是该候选渲染回图片后的 base64,`ocr_text` 是候选文本本身。base64 **不带** `data:image/png;base64,` 前缀,与镜像接口一致。
### 字段与限额
@@ -174,12 +188,14 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '
### 安装
```bash
+cd scripts/minicpm-ocr-jev/
bash sdk/setup_render.sh /opt/venv-render
```
它装 Node、CJK 字体、Chromium 与服务依赖。慢网下设两个镜像源:
```bash
+cd scripts/minicpm-ocr-jev/
PIP_INDEX_URL=https://<mirror>/simple \
PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
bash sdk/setup_render.sh /opt/venv-render
@@ -190,6 +206,7 @@ PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
参数依次为服务端口、引擎地址:
```bash
+cd scripts/minicpm-ocr-jev/
JEV_BACKEND_CONFIG=sdk/backends/llamacpp.yaml \
PATH=/opt/venv-render/bin:$PATH bash sdk/start_render_score.sh 18500 http://127.0.0.1:18499
```
@@ -252,7 +269,7 @@ curl -s http://127.0.0.1:18501/healthz
```
```json
-{"status": "ok", "served_model": "MiniCPM-OCR-Jev-bf16",
+{"status": "ok", "served_model": "./models/MiniCPM-OCR-Jev-bf16.gguf",
"prompt": {"template_md5": "9aab68e8ba8ab4da17ba9752bddb199c",
"source": "server_template",
"last_token": null, "expected_last_token": 271,
diff --git a/docs/minicpm_ocr_jev_docker_api_en.md b/docs/minicpm_ocr_jev_docker_api_en.md
index 852ce9a..fd0d8ea 100644
--- a/docs/minicpm_ocr_jev_docker_api_en.md
+++ b/docs/minicpm_ocr_jev_docker_api_en.md
@@ -10,11 +10,11 @@ This is the interface reference for the Docker image of [MiniCPM-OCR Jev Local D
### `input_form`
-Every scoring request carries `input_form` at the top level of the body. It is currently fixed to `"ternary"` (original image + render image + text). Any other value is rejected with 422.
+Every scoring request carries `input_form` at the top level of the body. It is currently fixed to `"ternary"` (original image + render image + text). Any other value is rejected with 422. `score_best_batch` needs it once more inside every item; without it the request is rejected with 422.
### `image` / `render_image` / `render_images`
-All image fields accept a data URL: `data:image/png;base64,<base64>` or `data:image/jpeg;base64,<base64>`. The MIME type in the prefix must match the real format.
+All image fields take the base64 body of the image file (PNG or JPEG) with **no** prefix such as `data:image/png;base64,`. With a prefix, that item returns `encode_error`.
### `category`
@@ -70,9 +70,9 @@ One score per block, one candidate per block. Suited to quality screening, routi
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": "data:image/png;base64,<base64>",
+ {"case_id": "blk-001", "image": "<base64>",
"ocr_text": "the OCR text to be scored", "category": "text"},
- {"case_id": "blk-002", "image": "data:image/png;base64,<base64>",
+ {"case_id": "blk-002", "image": "<base64>",
"ocr_text": "\\frac{1}{2}", "category": "formula"}
]
}'
@@ -122,7 +122,7 @@ Picks the best of N candidates for one block. Suited to single-block tests and l
```bash
curl -s http://127.0.0.1:8030/v1/rm/score_best -H 'Content-Type: application/json' -d '{
"input_form": "ternary",
- "image": "data:image/png;base64,<base64>",
+ "image": "<base64>",
"category": "text",
"candidates": ["candidate A", "candidate B", "candidate C"]
}'
@@ -162,15 +162,15 @@ Several blocks each pick their own best, in a single HTTP request. **Recommended
curl -s http://127.0.0.1:8030/v1/rm/score_best_batch -H 'Content-Type: application/json' -d '{
"input_form": "ternary",
"items": [
- {"case_id": "blk-001", "image": "data:image/png;base64,<base64>",
+ {"input_form": "ternary", "case_id": "blk-001", "image": "<base64>",
"category": "text", "candidates": ["text candidate A", "text candidate B"]},
- {"case_id": "blk-002", "image": "data:image/png;base64,<base64>",
+ {"input_form": "ternary", "case_id": "blk-002", "image": "<base64>",
"category": "formula", "candidates": ["\\frac{1}{2}", "1/2"]}
]
}'
```
-The fields inside `items[]` are the same as a single-block `score_best` request, except that `case_id` is required so the blocks can be told apart. `render_images` is likewise given per block.
+The fields inside `items[]` are the same as a single-block `score_best` request, `input_form` included — it goes both at the top level and in every item — except that `case_id` is required so the blocks can be told apart. `render_images` is likewise given per block.
```json
{
@@ -206,9 +206,9 @@ The fields inside `items[]` are the same as a single-block `score_best` request,
| Field | Where it appears | Meaning |
|---|---|---|
-| `input_form` | top level of the request | fixed to `"ternary"` |
+| `input_form` | top level of the request; also `items[]` in batch | fixed to `"ternary"` |
| `case_id` | `items[]` | the caller's own block identifier, echoed back unchanged |
-| `image` | `items[]` | the original block image, as a data URL |
+| `image` | `items[]` | the original block image, base64 with no `data:` prefix |
| `ocr_text` | `items[]` (score) | the single text to be scored |
| `candidates` | top level (score_best) / `items[]` (batch) | the array of candidate texts |
| `category` | everywhere | `text` / `formula` / `table` |
diff --git a/docs/minicpm_ocr_jev_docker_api_zh.md b/docs/minicpm_ocr_jev_docker_api_zh.md
index e20320f..26c4213 100644
--- a/docs/minicpm_ocr_jev_docker_api_zh.md
+++ b/docs/minicpm_ocr_jev_docker_api_zh.md
@@ -10,11 +10,11 @@
### `input_form`
-所有打分端点的请求体顶层都带 `input_form`,目前固定为 `"ternary"`(原图 + 渲染图 + 文本三元输入)。其他值会被 422 拒绝。
+所有打分端点的请求体顶层都带 `input_form`,目前固定为 `"ternary"`(原图 + 渲染图 + 文本三元输入)。其他值会被 422 拒绝。`score_best_batch` 的每个 item 里还要再带一次,缺了返回 422。
### `image` / `render_image` / `render_images`
-图片字段都接受 data URL:`data:image/png;base64,<base64>` 或 `data:image/jpeg;base64,<base64>`,前缀 MIME 必须与真实格式一致。
+图片字段都传图片文件(PNG 或 JPEG)的 base64 正文,**不带** `data:image/png;base64,` 这类前缀;带了前缀,该条返回 `encode_error`。
### `category`
@@ -70,9 +70,9 @@ curl -s http://127.0.0.1:8030/healthz | jq
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": "data:image/png;base64,<base64>",
+ {"case_id": "blk-001", "image": "<base64>",
"ocr_text": "待评分的 OCR 文本", "category": "text"},
- {"case_id": "blk-002", "image": "data:image/png;base64,<base64>",
+ {"case_id": "blk-002", "image": "<base64>",
"ocr_text": "\\frac{1}{2}", "category": "formula"}
]
}'
@@ -122,7 +122,7 @@ curl -s http://127.0.0.1:8030/v1/rm/score -H 'Content-Type: application/json' -d
```bash
curl -s http://127.0.0.1:8030/v1/rm/score_best -H 'Content-Type: application/json' -d '{
"input_form": "ternary",
- "image": "data:image/png;base64,<base64>",
+ "image": "<base64>",
"category": "text",
"candidates": ["候选 A", "候选 B", "候选 C"]
}'
@@ -162,15 +162,15 @@ curl -s http://127.0.0.1:8030/v1/rm/score_best -H 'Content-Type: application/jso
curl -s http://127.0.0.1:8030/v1/rm/score_best_batch -H 'Content-Type: application/json' -d '{
"input_form": "ternary",
"items": [
- {"case_id": "blk-001", "image": "data:image/png;base64,<base64>",
+ {"input_form": "ternary", "case_id": "blk-001", "image": "<base64>",
"category": "text", "candidates": ["文本候选 A", "文本候选 B"]},
- {"case_id": "blk-002", "image": "data:image/png;base64,<base64>",
+ {"input_form": "ternary", "case_id": "blk-002", "image": "<base64>",
"category": "formula", "candidates": ["\\frac{1}{2}", "1/2"]}
]
}'
```
-`items[]` 的字段与 `score_best` 单块请求一致;`case_id` 必填以区分块。`render_images` 同样按块各自提供。
+`items[]` 的字段与 `score_best` 单块请求一致,`input_form` 也在其中,顶层与每个 item 都要带;`case_id` 必填以区分块。`render_images` 同样按块各自提供。
```json
{
@@ -206,9 +206,9 @@ curl -s http://127.0.0.1:8030/v1/rm/score_best_batch -H 'Content-Type: applicati
| 字段 | 出现位置 | 含义 |
|---|---|---|
-| `input_form` | 请求顶层 | 固定 `"ternary"` |
+| `input_form` | 请求顶层;batch 的 `items[]` 也要 | 固定 `"ternary"` |
| `case_id` | `items[]` | 调用方自己的块标识,原样回传 |
-| `image` | `items[]` | 块原图,data URL |
+| `image` | `items[]` | 块原图,base64,不带 `data:` 前缀 |
| `ocr_text` | `items[]`(score) | 待评分的单条文本 |
| `candidates` | 顶层(score_best)/ `items[]`(batch) | 候选文本数组 |
| `category` | 各处 | `text` / `formula` / `table` |
diff --git a/docs/minicpm_ocr_jev_en.md b/docs/minicpm_ocr_jev_en.md
index 1edeaf4..d9f3276 100644
--- a/docs/minicpm_ocr_jev_en.md
+++ b/docs/minicpm_ocr_jev_en.md
@@ -4,7 +4,7 @@
[← Back to the homepage](../README.md) · [MiniCPM-OCR 1.0](./minicpm_ocr_1dot0_en.md)
-MiniCPM-OCR Jev is a **2B OCR correctness decision model** for text, formula, and table regions. Given an image and its corresponding OCR result, it returns a **quality score from 0 to 1** to help select reliable results and locate content that needs review. It works with different parsing models to assess OCR results at the region level and can select among several candidates for the same region.
+MiniCPM-OCR Jev is a **2B OCR quality assessment model** for text, formula, and table regions. It assigns a score between 0 and 1 to existing OCR candidates, helping route results to human review or select the best of several candidates. This page covers the model highlights, architecture, inputs and outputs, and usage; see the [MiniCPM-OCR Jev benchmark table on the homepage](../README.md#jev-benchmark) for the full model comparison.
## Model Highlights
@@ -15,8 +15,6 @@ MiniCPM-OCR Jev is a **2B OCR correctness decision model** for text, formula, an
MiniCPM-OCR Jev is **trained from Qwen3.5-2B**. It retains the architecture of the vision encoder and language backbone, replacing the language model output head `lm_head` with a **binary classification head** to learn whether an OCR candidate is correct.
-<!-- The base model and binary classification task are documented in finetune_jev_en.md. The description of the vision encoder and language backbone architecture follows the original model introduction. Retaining the architecture does not mean these parameters are frozen during training; see the fine-tuning guide for training settings. -->
-
### Inputs and outputs
| Item | Description |
@@ -26,7 +24,7 @@ MiniCPM-OCR Jev is **trained from Qwen3.5-2B**. It retains the architecture of t
| Candidate content | OCR text and an image rendered from that text |
| Output | A quality score between 0 and 1; a higher score indicates that the model is more likely to judge the candidate correct |
-Internally, the model uses a matched original region image, candidate text, and rendered image. When calling the Docker image or the SDK service with a built-in renderer, provide the original region image, candidate text, and the correct region `category` (`text`, `formula`, or `table`); the service handles rendering. The SDK service without a renderer requires the caller to supply the rendered image. See the [deployment guide](./minicpm_ocr_jev_tutorial_en.md) for request fields and image encoding formats. [Usage examples](./minicpm_ocr_jev_api_en.md) for the free cloud API are coming soon.
+Internally, the model uses a matched original region image, candidate text, and rendered image. When calling the [cloud API](./minicpm_ocr_jev_api_en.md), the Docker image, or the SDK service with a built-in renderer, provide the original region image, candidate text, and the correct region `category` (`text`, `formula`, or `table`); the service handles rendering. The SDK service without a renderer requires the caller to supply the rendered image. See the [deployment guide](./minicpm_ocr_jev_tutorial_en.md) for request fields and image encoding formats.
## Use cases
@@ -34,15 +32,13 @@ Internally, the model uses a matched original region image, candidate text, and
Score the parsed result for each region and choose a threshold using samples from your application. Results above the threshold proceed automatically; the rest go to human review. A higher threshold typically reduces the number of results that pass automatically, so monitor both the accuracy of automatically accepted results and the volume of human review.
-The figure below shows accuracy at different review-free rates for legal documents, financial receipts, and complex documents, helping assess how accuracy changes as the volume of human review decreases.
-
-<p align="center"><a href="../assets/minicpm-ocr/review-free-en.png"><img src="../assets/minicpm-ocr/review-free-en.png" alt="Accuracy versus review-free ratio for legal documents, financial receipts, and complex documents at different review-free ratios." width="100%"></a></p>
+![Accuracy versus review-free ratio for legal documents, financial receipts, and complex documents at different review-free ratios.](../assets/minicpm-ocr/review-free-en.png)
### Selecting across models to improve parsing quality
-Use the same layout segmentation to have several OCR models parse each region. MiniCPM-OCR Jev scores the candidates for the same region, replaces low-scoring blocks with higher-scoring results from other models, and combines them in reading order, improving overall parsing quality.
+Use the same layout segmentation to have several OCR models parse each region. MiniCPM-OCR Jev scores the candidates for the same region, selects the highest-scoring candidate, and combines the selected results in reading order. If all candidates fall below the application threshold, the region can still be sent for human review.
-<p align="center"><a href="../assets/minicpm-ocr/multi-models-improvements-en.png"><img src="../assets/minicpm-ocr/multi-models-improvements-en.png" alt="Parsing quality gains from MiniCPM-OCR Jev scoring and selection: Overall gains for MiniCPM-OCR 1.0, Xiaomi OCR, and PaddleOCR-VL 1.6 relative to each parser used alone." width="100%"></a></p>
+![Parsing quality gains from MiniCPM-OCR Jev scoring and selection: Overall gains for MiniCPM-OCR 1.0, Xiaomi OCR, and PaddleOCR-VL 1.6 relative to each parser used alone.](../assets/minicpm-ocr/multi-models-improvements-en.png)
Candidates for the same region must use the same crop and content boundaries. MiniCPM-OCR Jev selects from existing candidates, so the final quality depends on their coverage and correctness.
@@ -50,80 +46,61 @@ Candidates for the same region must use the same crop and content boundaries. Mi
The figure below compares the original image with candidates 1 and 2, showing how MiniCPM-OCR Jev scores text, formula, and table candidates.
-<p align="center"><a href="../assets/minicpm-ocr/jev-case-en.png"><img src="../assets/minicpm-ocr/jev-case-en.png" alt="Three examples for text, formulas, and tables. Each compares the original image with candidates 1 and 2 and shows their MiniCPM-OCR Jev scores." width="100%"></a></p>
-
-## Evaluation
-
-[JevOCRBench](https://huggingface.co/datasets/openbmb/JevOCRBench) evaluates OCR correctness decisions at the block level. Each sample contains an original region image, candidate OCR text, and a rendering of that text, with a human-annotated correct/incorrect label. The metric is **AUROC** (reported as AUROC ×100 on this page), which measures the ability to distinguish correct from incorrect candidates; higher is better.
-
-The table below reports overall and per-category AUROC (×100) on JevOCRBench, with the complete model comparison for text, formulas, and tables.
-
-<p align="center"><a href="../assets/minicpm-ocr/jev-benchmark-score-table.png"><img src="../assets/minicpm-ocr/jev-benchmark-score-table.png" alt="Overall, text, formula, and table AUROC results on JevOCRBench, highlighting MiniCPM-OCR Jev." width="100%"></a></p>
-
-### Validated parsers
-
-The cross-parser experiment uses the same **200 samples** randomly drawn from JevOCRBench. Four OCR models parse the samples independently; each result is manually labelled correct or incorrect and then scored by MiniCPM-OCR Jev.
-
-| OCR model | MiniCPM-OCR 1.0 | GLM-OCR | PaddleOCR-VL-1.6 | Xiaomi-OCR-0 |
-| :--- | ---: | ---: | ---: | ---: |
-| AUROC (×100) | 92.7 | 91.9 | 93.4 | 93.1 |
-
-In this experiment, AUROC (×100) ranges from **91.9 to 93.4**, with a maximum difference of **1.5 points**. These results describe performance on the samples and parser combinations above. Validate separately on your target data when using other parsers or new document types.
-
-<a id="calibration"></a>
-
-## Choosing a review threshold
-
-AUROC measures how well scores distinguish correct from incorrect results; it does not directly determine the accuracy of automatically accepted results. For deployment, choose a threshold using human-labelled samples from your application:
-
-1. Collect samples that cover your actual document types and OCR errors, and label each region's candidate correct or incorrect.
-2. Score the candidates with MiniCPM-OCR Jev and measure the **automatic acceptance rate** and **accuracy of accepted results** at several thresholds.
-3. Choose a threshold based on the error level your application can tolerate, then verify it on independent samples. Revalidate when the parser or document distribution changes.
-
-To interpret scores as probabilities of correctness, also check whether score ranges match the observed proportion of correct results. The existing AUROC results do not establish a universal default threshold.
+![Three examples for text, formulas, and tables. Each compares the original image with candidates 1 and 2 and shows their MiniCPM-OCR Jev scores.](../assets/minicpm-ocr/jev-case-en.png)
## Model weights
-MiniCPM-OCR Jev provides BF16 weights and GGUF, AWQ, and GPTQ quantized versions, available from the following links:
-
-| Version | Hugging Face | ModelScope |
-| :--- | :--- | :--- |
-| BF16 | [MiniCPM-OCR-1.0-Jev](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev) | [MiniCPM-OCR-Jev](https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev) |
-| GGUF | [MiniCPM-OCR-1.0-Jev-gguf](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev-gguf) | [MiniCPM-OCR-Jev-gguf](https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-gguf) |
-| AWQ | [MiniCPM-OCR-1.0-Jev-AWQ](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev-AWQ) | [MiniCPM-OCR-Jev-AWQ](https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-AWQ) |
-| GPTQ | [MiniCPM-OCR-1.0-Jev-GPTQ](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev-GPTQ) | [MiniCPM-OCR-Jev-GPTQ](https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-GPTQ) |
-
-The FlagOS-adapted BF16 versions for multiple chips are listed under [Model downloads](./flagos_deploy_en.md#model-downloads).
+See [Model weights on the homepage](../README.md#model-weights) for the official weights. The FlagOS-adapted BF16 versions for multiple chips are listed under [Model downloads](./flagos_deploy_en.md#model-downloads).
## Inference
| Deployment method | Guide |
| :--- | :--- |
-| Free cloud API | [Usage examples](./minicpm_ocr_jev_api_en.md) (coming soon) |
+| Cloud API | [Single-candidate scoring, best-of-N for one block, and batched best-of-N](./minicpm_ocr_jev_api_en.md) |
| Docker / SDK local deployment | [Environment setup, rendering options, and service startup](./minicpm_ocr_jev_tutorial_en.md) |
| vLLM backend | [Service configuration with and without a built-in renderer](./vllm_deploy_jev_en.md) |
| FlagOS | [Torch-FL deployment guide for multiple chips](./flagos_deploy_en.md) |
-When using results from Docker or a service with a built-in renderer, check `verdict` before using the score. Only `scored` means model scoring completed. Fixed return values for precheck, rendering, or forward-pass failures must not be treated as low model scores.
+When using results from the cloud API, Docker, or a service with a built-in renderer, check `verdict` before using the score. Only `scored` means model scoring completed. Fixed return values for precheck, rendering, or forward-pass failures must not be treated as low model scores.
-## Pipeline integration
+## Parsing pipeline integration
When placing MiniCPM-OCR Jev after MiniCPM-OCR 1.0 or another parser, organize the data and results as follows:
1. Preserve the page and region identifiers, original region images, region categories, and candidate OCR text while parsing documents.
-2. Submit the original image, category, and candidate text through the API of the Docker image or a service with a built-in renderer, which renders and scores the candidate. If rendered images are already available, use a service without a renderer.
+2. Submit the original image, category, and candidate text through the API or a service with a built-in renderer, which renders and scores the candidate. If rendered images are already available, use a service without a renderer.
3. Check the return status and associate valid scores with their original candidates. Apply your chosen threshold to route results to automatic acceptance or human review; for multiple models, compare candidate scores within each region.
4. Output the selected results in the original reading order and retain regions awaiting review so reviewers can refer back to the source.
-Use `score` for single-candidate scoring, `score_best` to select among several candidates for one block, and `score_best_batch` for batched selection across multiple blocks. See the [Docker image API reference](./minicpm_ocr_jev_docker_api_en.md) for request fields, response handling, and usage examples.
+Use `score` for single-candidate scoring, `score_best` to select among several candidates for one block, and `score_best_batch` for batched selection across multiple blocks. See the [API documentation](./minicpm_ocr_jev_api_en.md) for request fields, response handling, and Python examples.
## Fine-tuning
To adapt the model to specific document types or parsers, prepare original region images, candidate text, corresponding rendered images, and human correct/incorrect labels, and reserve independent validation data. The [ms-swift fine-tuning guide](./finetune_jev_en.md) covers training and inference environments, the data format, binary classification head configuration, training commands, and JevOCRBench evaluation. A [Chinese version](./finetune_jev_zh.md) is also available.
-## FAQ and Troubleshooting
+## Evaluation
+
+[JevOCRBench](https://huggingface.co/datasets/openbmb/JevOCRBench) evaluates OCR quality assessment at the block level. Each sample contains an original region image, candidate OCR text, and a rendering of that text, with a human-annotated correct/incorrect label. The metric is **AUROC** (reported as AUROC ×100 on this page), which measures the ability to distinguish correct from incorrect candidates; higher is better.
+
+See the [JevOCRBench results table on the homepage](../README.md#jev-benchmark) for the full comparison of Overall, Text, Formula, and Table scores.
+
+### Validated parsers
+
+The cross-parser experiment uses the same **200 samples** randomly drawn from JevOCRBench. Four OCR models parse the samples independently; each result is manually labelled correct or incorrect and then scored by MiniCPM-OCR Jev.
+
+| OCR model | MiniCPM-OCR 1.0 | GLM-OCR | PaddleOCR-VL-1.6 | Xiaomi-OCR-0 |
+| :--- | ---: | ---: | ---: | ---: |
+| AUROC (×100) | 92.7 | 91.9 | 93.4 | 93.1 |
+
+In this experiment, AUROC (×100) ranges from **91.9 to 93.4**, with a maximum difference of **1.5 points**. These results describe performance on the samples and parser combinations above. Validate separately on your target data when using other parsers or new document types.
-See the [FAQ](./faq_en.md) for common questions about installation, model downloads, GPU memory, input formats, and unexpected outputs.
+> AUROC measures how well scores distinguish correct from incorrect results; it does not directly determine the accuracy of automatically accepted results. For deployment, choose a threshold using human-labelled samples from your application:
+>
+> 1. Collect samples that cover your actual document types and OCR errors, and label each region's candidate correct or incorrect.
+> 2. Score the candidates with MiniCPM-OCR Jev and measure the **automatic acceptance rate** and **accuracy of accepted results** at several thresholds.
+> 3. Choose a threshold based on the error level your application can tolerate, then verify it on independent samples. Revalidate when the parser or document distribution changes.
+>
+> To interpret scores as probabilities of correctness, also check whether score ranges match the observed proportion of correct results. The existing AUROC results do not establish a universal default threshold.
## License
diff --git a/docs/minicpm_ocr_jev_tutorial_en.md b/docs/minicpm_ocr_jev_tutorial_en.md
index dd41f6e..397359d 100644
--- a/docs/minicpm_ocr_jev_tutorial_en.md
+++ b/docs/minicpm_ocr_jev_tutorial_en.md
@@ -62,7 +62,7 @@ Once the service is ready you can score. A single scoring request looks like thi
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": "data:image/png;base64,<base64>",
+ {"case_id": "blk-001", "image": "<base64>",
"ocr_text": "the OCR text to be scored", "category": "text"}
]
}'
@@ -78,7 +78,7 @@ curl -s http://127.0.0.1:8030/v1/rm/score -H 'Content-Type: application/json' -d
}
```
-`image` takes a `data:image/png;base64,` or `data:image/jpeg;base64,` prefix followed by the base64 body. `category` must match the real type of the block (`text` / `formula` / `table`); getting it wrong raises no error but skews the score. **Always read** `verdict` **before using a score** — `0.0` and `-1.0` are the fixed values returned when scoring failed, not low scores.
+`image` takes the base64 body of the image file (PNG or JPEG) with **no** prefix such as `data:image/png;base64,`. `category` must match the real type of the block (`text` / `formula` / `table`); getting it wrong raises no error but skews the score. **Always read** `verdict` **before using a score** — `0.0` and `-1.0` are the fixed values returned when scoring failed, not low scores.
For the other endpoints (`/v1/rm/score_best`, `/v1/rm/score_best_batch`) and the full field definitions, see the [Docker image API reference](./minicpm_ocr_jev_docker_api_en.md).
diff --git a/docs/minicpm_ocr_jev_tutorial_zh.md b/docs/minicpm_ocr_jev_tutorial_zh.md
index 72b51e4..ccdb124 100644
--- a/docs/minicpm_ocr_jev_tutorial_zh.md
+++ b/docs/minicpm_ocr_jev_tutorial_zh.md
@@ -62,7 +62,7 @@ curl -f http://127.0.0.1:8030/healthz
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": "data:image/png;base64,<base64>",
+ {"case_id": "blk-001", "image": "<base64>",
"ocr_text": "待评分的 OCR 文本", "category": "text"}
]
}'
@@ -78,7 +78,7 @@ curl -s http://127.0.0.1:8030/v1/rm/score -H 'Content-Type: application/json' -d
}
```
-`image` 传 `data:image/png;base64,` 或 `data:image/jpeg;base64,` 前缀加 base64 正文。`category` 必须与块真实类型一致(`text` / `formula` / `table`),填错不报错但分数会偏。**用分数前必须先看** `verdict`——`0.0` 与 `-1.0` 是打分失败时的固定返回值,不是低分。
+`image` 传图片文件(PNG 或 JPEG)的 base64 正文,**不带** `data:image/png;base64,` 这类前缀。`category` 必须与块真实类型一致(`text` / `formula` / `table`),填错不报错但分数会偏。**用分数前必须先看** `verdict`——`0.0` 与 `-1.0` 是打分失败时的固定返回值,不是低分。
更多端点(`/v1/rm/score_best`、`/v1/rm/score_best_batch`)与完整字段定义见 [Docker 镜像 API 参考](./minicpm_ocr_jev_docker_api_zh.md)。
diff --git a/docs/minicpm_ocr_jev_zh.md b/docs/minicpm_ocr_jev_zh.md
index 02f451f..c36e83d 100644
--- a/docs/minicpm_ocr_jev_zh.md
+++ b/docs/minicpm_ocr_jev_zh.md
@@ -4,7 +4,7 @@
[← 返回首页](../README_zh.md) · [MiniCPM-OCR 1.0](./minicpm_ocr_1dot0_zh.md)
-MiniCPM-OCR Jev 是面向文本、公式和表格区域的 **2B OCR 正确性判别决策模型**。输入图像及对应的 OCR 结果,即可获得 **0–1 的质量评分**,用于筛选可靠结果、定位待复核内容。它可搭配不同解析模型,对 OCR 结果进行区域级判断,也可从同一区域的多个候选结果中择优。
+MiniCPM-OCR Jev 是面向文本、公式和表格区域的 **2B OCR 质量判别模型**。它对已有 OCR 候选结果给出 0–1 评分,可用于安排人工复核或从多个候选结果中择优。本页介绍模型亮点、模型结构、输入输出和具体用法;完整模型对比见 [首页 MiniCPM-OCR Jev 评测表](../README_zh.md#jev-benchmark)。
## 模型亮点
@@ -15,34 +15,36 @@ MiniCPM-OCR Jev 是面向文本、公式和表格区域的 **2B OCR 正确性判
MiniCPM-OCR Jev **基于 Qwen3.5-2B 训练**,保留其视觉编码器和语言骨干的架构,将语言模型输出头 `lm_head` 替换为**二分类头**,学习判断 OCR 候选结果是否正确。
-<!-- 基座与二分类任务据 finetune_jev_zh.md;视觉编码器和语言骨干架构的说明沿用原模型介绍。“保留架构”不意味着训练时冻结这些参数,训练设置以相应教程为准。 -->
+
### 输入与输出
-| 项目 | 内容 |
-| :--- | :--- |
-| 判别单位 | 一个文本、公式或表格区域及其候选 OCR 结果 |
-| 区域原图 | 从文档中裁切的对应区域,保留其视觉内容 |
-| 候选内容 | OCR 识别文本,以及由该文本生成的渲染图 |
-| 输出 | 0–1 质量评分,分数越高表示模型越倾向于判为正确 |
-模型内部使用一一对应的区域原图、候选文本和渲染图。调用 Docker 镜像或内置渲染器的 SDK 服务时,只需提供区域原图、候选文本和正确的区域类别 `category`(`text`、`formula` 或 `table`),渲染由服务完成;不带渲染器的 SDK 服务则需要调用方提供渲染图。请求字段与图像编码格式见对应的 [部署教程](./minicpm_ocr_jev_tutorial_zh.md)。免费云端 API 的 [调用示例](./minicpm_ocr_jev_api_zh.md) 即将提供。
+| 项目 | 内容 |
+| ---- | ------------------------- |
+| 判别单位 | 一个文本、公式或表格区域及其候选 OCR 结果 |
+| 区域原图 | 从文档中裁切的对应区域,保留其视觉内容 |
+| 候选内容 | OCR 识别文本,以及由该文本生成的渲染图 |
+| 输出 | 0–1 质量评分,分数越高表示模型越倾向于判为正确 |
+
+
+模型内部使用一一对应的区域原图、候选文本和渲染图。调用 [云端 API](./minicpm_ocr_jev_api_zh.md)、Docker 镜像或内置渲染器的 SDK 服务时,只需提供区域原图、候选文本和正确的区域类别 `category`(`text`、`formula` 或 `table`),渲染由服务完成;不带渲染器的 SDK 服务则需要调用方提供渲染图。请求字段与图像编码格式见对应的 [部署教程](./minicpm_ocr_jev_tutorial_zh.md)。
## 使用场景
+
+
### 自动筛选,减少人工复核
对每个区域的解析结果评分,根据业务样本选择阈值:高于阈值的结果自动进入后续流程,其他结果交由人工复核。提高阈值通常会减少自动通过的数量,需同时关注自动通过结果的准确率和人工复核量。
-下图展示法律文书、财务票据和复杂文档在不同免检比例下的准确率,用于评估减少人工复核量时的准确率变化。
-
-<p align="center"><a href="../assets/minicpm-ocr/review-free-zh.png"><img src="../assets/minicpm-ocr/review-free-zh.png" alt="免检准确率与免检比例曲线:法律文书、财务票据和复杂文档在不同免检比例下的准确率。" width="100%"></a></p>
+![免检准确率与免检比例曲线:法律文书、财务票据和复杂文档在不同免检比例下的准确率。](../assets/minicpm-ocr/review-free-zh.png)
### 多模型择优,提升解析质量
-基于同一份版面分割结果,让多个 OCR 模型分别解析各区域。MiniCPM-OCR Jev 对同一区域的候选结果评分,把其中低分的块替换成其他模型的高分结果,再按阅读顺序组合输出,带来整体的解析质量提升。
+基于同一份版面分割结果,让多个 OCR 模型分别解析各区域。MiniCPM-OCR Jev 对同一区域的候选结果评分,选择得分最高的候选,再按阅读顺序组合输出。若所有候选均低于业务阈值,该区域仍可进入人工复核流程。
-<p align="center"><a href="../assets/minicpm-ocr/multi-models-improvements-zh.png"><img src="../assets/minicpm-ocr/multi-models-improvements-zh.png" alt="MiniCPM-OCR Jev 评分筛选带来的解析质量提升:MiniCPM-OCR 1.0、Xiaomi OCR 与 PaddleOCR-VL 1.6 相对各自单独解析的 Overall 增益。" width="100%"></a></p>
+![MiniCPM-OCR Jev 评分筛选带来的解析质量提升:MiniCPM-OCR 1.0、Xiaomi OCR 与 PaddleOCR-VL 1.6 相对各自单独解析的 Overall 增益。](../assets/minicpm-ocr/multi-models-improvements-zh.png)
同一区域的候选需要使用一致的裁片和内容范围。MiniCPM-OCR Jev 从已有候选中择优,最终质量取决于候选结果的覆盖与正确性。
@@ -50,80 +52,65 @@ MiniCPM-OCR Jev **基于 Qwen3.5-2B 训练**,保留其视觉编码器和语言
下图对照原图、候选结果 1 和候选结果 2,展示 MiniCPM-OCR Jev 对文本、公式和表格候选结果的打分。
-<p align="center"><a href="../assets/minicpm-ocr/jev-case-zh.png"><img src="../assets/minicpm-ocr/jev-case-zh.png" alt="文本、公式、表格三组示例:每组为原图、候选结果 1 与候选结果 2,并标出 MiniCPM-OCR Jev 分数。" width="100%"></a></p>
-
-## 评测
-
-[JevOCRBench](https://huggingface.co/datasets/openbmb/JevOCRBench) 面向 OCR 的块级正确性判别,每条样本包括区域原图、OCR 候选文本及其渲染图,真值为人工标注的正确/错误。评测使用 **AUROC**(本文按 AUROC ×100 展示),衡量模型区分正确与错误候选的能力,分数越高越好。
-
-下表展示 JevOCRBench 的整体与分类型 AUROC(×100),包含文本、公式和表格的完整模型对比。
+![文本、公式、表格三组示例:每组为原图、候选结果 1 与候选结果 2,并标出 MiniCPM-OCR Jev 分数。](../assets/minicpm-ocr/jev-case-zh.png)
-<p align="center"><a href="../assets/minicpm-ocr/jev-benchmark-score-table.png"><img src="../assets/minicpm-ocr/jev-benchmark-score-table.png" alt="JevOCRBench 各模型在整体、文本、公式和表格上的 AUROC 对比,突出 MiniCPM-OCR Jev。" width="100%"></a></p>
-
-### 已验证的解析器
-
-跨 OCR 模型实验使用从 JevOCRBench 随机抽取的同一批 **200 个样本**,由四种模型分别解析,逐条人工标注正误后,再由 MiniCPM-OCR Jev 评分。
+## 模型权重
-| OCR 模型 | MiniCPM-OCR 1.0 | GLM-OCR | PaddleOCR-VL-1.6 | Xiaomi-OCR-0 |
-| :--- | ---: | ---: | ---: | ---: |
-| AUROC(×100) | 92.7 | 91.9 | 93.4 | 93.1 |
+正式权重入口统一见 [首页模型权重](../README_zh.md#model-weights);FlagOS 适配的 BF16 多芯片版本见 [下载列表](./flagos_deploy_zh.md#model-downloads)。
-这组实验中,AUROC(×100)为 **91.9–93.4**,最大差值为 **1.5 分**。结果反映上述样本和解析器组合上的判别表现;接入其他解析器或新的文档类型时,应使用目标数据另行验证。
+## 推理
-<a id="校准"></a>
-## 选择复核阈值
+| 接入方式 | 使用说明 |
+| ----------------- | -------------------------------------------------- |
+| 云端 API | [单候选打分、单块选优与批量选优](./minicpm_ocr_jev_api_zh.md) |
+| Docker / SDK 本地部署 | [环境准备、渲染方式与服务启动](./minicpm_ocr_jev_tutorial_zh.md) |
+| vLLM 后端 | [不带渲染器与内置渲染器的服务配置](./vllm_deploy_jev_zh.md) |
+| FlagOS | [Torch-FL 多芯片部署指南](./flagos_deploy_zh.md) |
-AUROC 衡量分数对正确和错误结果的区分能力,不能直接给出自动通过后的准确率。部署时应在有人工标签的业务样本上选择阈值:
-1. 收集包含实际文档类型和 OCR 错误的样本,为每个区域候选标注正误。
-2. 用 MiniCPM-OCR Jev 评分,对多个阈值分别统计**自动通过比例**与**通过结果准确率**。
-3. 按业务可接受的错误水平选择阈值,并在独立样本上复查效果;解析器或文档分布改变后重新验证。
+使用云端 API、Docker 或内置渲染器服务的返回结果时,先检查 `verdict` 再使用评分;只有 `scored` 表示完成模型打分,预检失败、渲染失败或前向失败时的固定返回值不能直接当作模型低分。
-若要把分数解释为正确概率,还需检查分数区间与实际正确比例是否一致。现有 AUROC 结果不足以确定通用的默认阈值。
+## 解析流水线接入
-## 模型权重
+接在 MiniCPM-OCR 1.0 或其他解析器后时,可按以下顺序组织数据与结果:
-MiniCPM-OCR Jev 提供 BF16 与 GGUF、AWQ、GPTQ 量化版本,可从以下入口下载:
+1. 解析文档时保留页面和区域标识、区域原图、区域类别及 OCR 候选文本。
+2. 通过 API 或内置渲染器服务提交原图、类别和候选文本,由服务渲染并评分;已有渲染图时也可使用不带渲染器的服务。
+3. 检查返回状态并将有效评分与原候选关联,按所选阈值分配自动通过或人工复核;多模型场景按区域比较候选分数。
+4. 按原阅读顺序输出选定结果,并保留待复核区域,便于回看原文。
-| 版本 | Hugging Face | ModelScope |
-| :--- | :--- | :--- |
-| BF16 | [MiniCPM-OCR-1.0-Jev](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev) | [MiniCPM-OCR-Jev](https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev) |
-| GGUF | [MiniCPM-OCR-1.0-Jev-gguf](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev-gguf) | [MiniCPM-OCR-Jev-gguf](https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-gguf) |
-| AWQ | [MiniCPM-OCR-1.0-Jev-AWQ](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev-AWQ) | [MiniCPM-OCR-Jev-AWQ](https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-AWQ) |
-| GPTQ | [MiniCPM-OCR-1.0-Jev-GPTQ](https://huggingface.co/openbmb/MiniCPM-OCR-1.0-Jev-GPTQ) | [MiniCPM-OCR-Jev-GPTQ](https://modelscope.cn/models/OpenBMB/MiniCPM-OCR-Jev-GPTQ) |
+单候选打分使用 `score`,单块多候选选优使用 `score_best`,多块批量选优使用 `score_best_batch`。请求字段、响应读取和 Python 示例见 [API 文档](./minicpm_ocr_jev_api_zh.md)。
-FlagOS 适配的 BF16 多芯片版本见 [下载列表](./flagos_deploy_zh.md#model-downloads)。
+## 二次微调
-## 推理
+面向特定文档类型或解析器适配时,可准备区域原图、候选文本、对应渲染图和人工正误标签,并留出独立验证数据。[ms-swift 微调教程](./finetune_jev_zh.md) 提供训练与推理环境、数据格式、二分类头配置、训练命令和 JevOCRBench 评测流程;英文说明见 [Fine-tuning](./finetune_jev_en.md)。
-| 接入方式 | 使用说明 |
-| :--- | :--- |
-| 免费云端 API | [调用示例](./minicpm_ocr_jev_api_zh.md)(即将提供) |
-| Docker / SDK 本地部署 | [环境准备、渲染方式与服务启动](./minicpm_ocr_jev_tutorial_zh.md) |
-| vLLM 后端 | [不带渲染器与内置渲染器的服务配置](./vllm_deploy_jev_zh.md) |
-| FlagOS | [Torch-FL 多芯片部署指南](./flagos_deploy_zh.md) |
+## 评测
-使用 Docker 或内置渲染器服务的返回结果时,先检查 `verdict` 再使用评分;只有 `scored` 表示完成模型打分,预检失败、渲染失败或前向失败时的固定返回值不能直接当作模型低分。
+[JevOCRBench](https://huggingface.co/datasets/openbmb/JevOCRBench) 面向 OCR 的块级质量判别,每条样本包括区域原图、OCR 候选文本及其渲染图,真值为人工标注的正确/错误。评测使用 **AUROC**(本文按 AUROC ×100 展示),衡量模型区分正确与错误候选的能力,分数越高越好。
-## 流水线接入
+整体、文本、公式与表格的完整模型对比统一见 [首页 JevOCRBench 实验表格](../README_zh.md#jev-benchmark)。
-接在 MiniCPM-OCR 1.0 或其他解析器后时,可按以下顺序组织数据与结果:
+### 已验证的解析器
-1. 解析文档时保留页面和区域标识、区域原图、区域类别及 OCR 候选文本。
-2. 通过 Docker 或内置渲染器服务的 API 提交原图、类别和候选文本,由服务渲染并评分;已有渲染图时也可使用不带渲染器的服务。
-3. 检查返回状态并将有效评分与原候选关联,按所选阈值分配自动通过或人工复核;多模型场景按区域比较候选分数。
-4. 按原阅读顺序输出选定结果,并保留待复核区域,便于回看原文。
+跨 OCR 模型实验使用从 JevOCRBench 随机抽取的同一批 **200 个样本**,由四种模型分别解析,逐条人工标注正误后,再由 MiniCPM-OCR Jev 评分。
-单候选打分使用 `score`,单块多候选选优使用 `score_best`,多块批量选优使用 `score_best_batch`。请求字段、响应读取和调用示例见 [Docker 镜像 API 参考](./minicpm_ocr_jev_docker_api_zh.md)。
-## 二次微调
+| OCR 模型 | MiniCPM-OCR 1.0 | GLM-OCR | PaddleOCR-VL-1.6 | Xiaomi-OCR-0 |
+| ----------- | --------------- | ------- | ---------------- | ------------ |
+| AUROC(×100) | 92.7 | 91.9 | 93.4 | 93.1 |
-面向特定文档类型或解析器适配时,可准备区域原图、候选文本、对应渲染图和人工正误标签,并留出独立验证数据。[ms-swift 微调教程](./finetune_jev_zh.md) 提供训练与推理环境、数据格式、二分类头配置、训练命令和 JevOCRBench 评测流程;英文说明见 [Fine-tuning](./finetune_jev_en.md)。
-## 常见问题与排查
+这组实验中,AUROC(×100)为 **91.9–93.4**,最大差值为 **1.5 分**。结果反映上述样本和解析器组合上的判别表现;接入其他解析器或新的文档类型时,应使用目标数据另行验证。
-安装、模型下载、显存、输入格式与输出异常等常见问题见 [FAQ](./faq_zh.md)。
+> AUROC 衡量分数对正确和错误结果的区分能力,不能直接给出自动通过后的准确率。部署时应在有人工标签的业务样本上选择阈值:
+>
+> 1. 收集包含实际文档类型和 OCR 错误的样本,为每个区域候选标注正误。
+> 2. 用 MiniCPM-OCR Jev 评分,对多个阈值分别统计**自动通过比例**与**通过结果准确率**。
+> 3. 按业务可接受的错误水平选择阈值,并在独立样本上复查效果;解析器或文档分布改变后重新验证。
+>
+> 若要把分数解释为正确概率,还需检查分数区间与实际正确比例是否一致。现有 AUROC 结果不足以确定通用的默认阈值。
## 许可
diff --git a/docs/ollama_deploy_jev_en.md b/docs/ollama_deploy_jev_en.md
index 57f7b30..a58e414 100644
--- a/docs/ollama_deploy_jev_en.md
+++ b/docs/ollama_deploy_jev_en.md
@@ -25,7 +25,7 @@ Both services share one forward engine. The only difference is where the render
- **Score service** → install the service environment → start the service
- **Render+score service** → install the render environment → start the service
-The engine and the service must go into two separate virtual environments; do not merge them. All commands below run from `scripts/minicpm-ocr-jev/`.
+The engine and the service must go into two separate virtual environments; do not merge them.
## Requirements
@@ -47,7 +47,7 @@ The engine and the service must go into two separate virtual environments; do no
curl -fsSL https://ollama.com/install.sh | sh
# macOS
-brew install ollama
+# brew install ollama
# Windows
# Download from https://ollama.com/download/windows
@@ -79,8 +79,6 @@ The Capabilities line from `ollama show` must list both `decision` and `vision`;
ollama serve # default port 11434
```
-Each request is a single forward pass, generates no tokens, and carries exactly two images — the original first, then the render. The bf16 weights take about 4.4GB of VRAM. The model has no LM head, so the text-generation endpoints are unavailable.
-
---
## 2. Score service
@@ -112,6 +110,7 @@ Pillow 12.3.0
`JEV_BACKEND_CONFIG` points at the Ollama backend config; the arguments are the service port and the engine address, in that order:
```bash
+cd scripts/minicpm-ocr-jev/
JEV_BACKEND_CONFIG=sdk/backends/ollama.yaml \
PATH=/opt/venv-score/bin:$PATH bash sdk/start_score.sh 18501 http://127.0.0.1:11434
```
@@ -139,7 +138,7 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '
{"results": [{"prob_1": 0.00227, "error": null}]}
```
-All three fields are required: `original_image` is the base64 of the original block image, `render_image` is the base64 of that candidate rendered back into an image, and `ocr_text` is the candidate text itself. The base64 carries **no** `data:image/png;base64,` prefix, unlike the image API.
+All three fields are required: `original_image` is the base64 of the original block image, `render_image` is the base64 of that candidate rendered back into an image, and `ocr_text` is the candidate text itself. The base64 carries **no** `data:image/png;base64,` prefix, the same as the image API.
### Fields and limits
@@ -159,12 +158,14 @@ This service calls the scoring layer in-process: it does **not** need a separate
### Install
```bash
+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:
```bash
+cd scripts/minicpm-ocr-jev/
PIP_INDEX_URL=https://<mirror>/simple \
PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
bash sdk/setup_render.sh /opt/venv-render
@@ -175,6 +176,7 @@ PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
The arguments are the service port and the engine address, in that order:
```bash
+cd scripts/minicpm-ocr-jev/
JEV_BACKEND_CONFIG=sdk/backends/ollama.yaml \
PATH=/opt/venv-render/bin:$PATH bash sdk/start_render_score.sh 18500 http://127.0.0.1:11434
```
diff --git a/docs/ollama_deploy_jev_zh.md b/docs/ollama_deploy_jev_zh.md
index fefd893..18cf5e2 100644
--- a/docs/ollama_deploy_jev_zh.md
+++ b/docs/ollama_deploy_jev_zh.md
@@ -25,7 +25,7 @@ Ollama 把 MiniCPM-OCR Jev 当作决策模型(decision model)来服务。与
- **不带渲染器服务** → 装服务环境 → 起服务
- **内置渲染器服务** → 装渲染环境 → 起服务
-引擎与服务必须装在两个虚拟环境里,不要合并。以下命令都在 `scripts/minicpm-ocr-jev/` 目录下执行。
+引擎与服务必须装在两个虚拟环境里,不要合并。
## 环境要求
@@ -47,7 +47,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 下载安装
@@ -79,8 +79,6 @@ ollama show ocr-jev # Capabilities: decision, vision
ollama serve # 默认端口 11434
```
-每个请求是一次前向,不生成任何 token,固定两张图:先原图、后渲染图。bf16 权重约占 4.4GB 显存。模型没有 LM head,文本生成类端点不可用。
-
---
## 二、不带渲染器服务
@@ -112,6 +110,7 @@ Pillow 12.3.0
`JEV_BACKEND_CONFIG` 指向 Ollama 的后端配置,参数依次为服务端口、引擎地址:
```bash
+cd scripts/minicpm-ocr-jev/
JEV_BACKEND_CONFIG=sdk/backends/ollama.yaml \
PATH=/opt/venv-score/bin:$PATH bash sdk/start_score.sh 18501 http://127.0.0.1:11434
```
@@ -139,7 +138,7 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '
{"results": [{"prob_1": 0.00227, "error": null}]}
```
-三个字段都是必填:`original_image` 是原始块图的 base64,`render_image` 是该候选渲染回图片后的 base64,`ocr_text` 是候选文本本身。base64 **不带** `data:image/png;base64,` 前缀,与镜像接口不同。
+三个字段都是必填:`original_image` 是原始块图的 base64,`render_image` 是该候选渲染回图片后的 base64,`ocr_text` 是候选文本本身。base64 **不带** `data:image/png;base64,` 前缀,与镜像接口一致。
### 字段与限额
@@ -159,12 +158,14 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '
### 安装
```bash
+cd scripts/minicpm-ocr-jev/
bash sdk/setup_render.sh /opt/venv-render
```
它装 Node、CJK 字体、Chromium 与服务依赖。慢网下设两个镜像源:
```bash
+cd scripts/minicpm-ocr-jev/
PIP_INDEX_URL=https://<mirror>/simple \
PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
bash sdk/setup_render.sh /opt/venv-render
@@ -175,6 +176,7 @@ PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
参数依次为服务端口、引擎地址:
```bash
+cd scripts/minicpm-ocr-jev/
JEV_BACKEND_CONFIG=sdk/backends/ollama.yaml \
PATH=/opt/venv-render/bin:$PATH bash sdk/start_render_score.sh 18500 http://127.0.0.1:11434
```
diff --git a/docs/sglang_deploy_jev_en.md b/docs/sglang_deploy_jev_en.md
index 4c18e59..1a9b292 100644
--- a/docs/sglang_deploy_jev_en.md
+++ b/docs/sglang_deploy_jev_en.md
@@ -23,12 +23,13 @@ Both services share one forward engine. The only difference is where the render
- **Score service** → install the service environment → start the service
- **Render+score service** → install the render environment → start the service
-The engine and the service must go into two separate virtual environments; do not merge them. All commands below run from `scripts/minicpm-ocr-jev/`.
+The engine and the service must go into two separate virtual environments; do not merge them.
## Requirements
-- **GPU**: NVIDIA, ≥8GB VRAM
+- **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)
@@ -47,6 +48,7 @@ pip install "sglang[all]"
Start it:
```bash
+cd scripts/minicpm-ocr-jev/
python -m sglang.launch_server \
--model-path ./models/MiniCPM-OCR-Jev \
--is-embedding \
@@ -55,8 +57,8 @@ python -m sglang.launch_server \
```
- `--is-embedding`: routes requests through the pooling path instead of generation. Without it there is no `/classify` to call.
-- `--json-model-override-args`: needed while the checkpoint's `config.json` lists the generative class `Qwen3_5ForConditionalGeneration` — overriding it to the classification class is what makes the server return the value head's two logits; without it SGLang loads the generative class and returns a 2048-dim hidden state. This is a load-time override; the checkpoint on disk is not touched. If `config.json` already lists `Qwen3_5VLForSequenceClassification`, the flag can be dropped.
-- The number of classes comes from `config.json`: `len(id2label)` if present, otherwise `num_labels`. One of the two must be there.
+- `--json-model-override-args`: needed while the checkpoint's `config.json` lists the generative class `Qwen3_5ForConditionalGeneration` — overriding it to the classification class is what makes the server return the value head's two logits; without it there is no score head, and the `--is-embedding` pooling path returns a 2048-dim (`hidden_size`) hidden state instead. This is a load-time override; the checkpoint on disk is not touched. If `config.json` already lists `Qwen3_5VLForSequenceClassification`, the flag can be dropped.
+- The number of classes comes from `config.json`: `len(id2label)` if present, otherwise `num_labels`; when neither is present it falls back to 2 classes.
- Do not add `--chat-template`: SGLang applies no template, and the SDK sends the finished prompt string as it is.
Once it is up, check that the engine is ready:
@@ -98,6 +100,7 @@ Pillow 12.3.0
`JEV_BACKEND_CONFIG` points at the SGLang backend config; the arguments are the service port and the engine address, in that order:
```bash
+cd scripts/minicpm-ocr-jev/
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
```
@@ -125,7 +128,7 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '
{"results": [{"prob_1": 0.00227, "error": null}]}
```
-All three fields are required: `original_image` is the base64 of the original block image, `render_image` is the base64 of that candidate rendered back into an image, and `ocr_text` is the candidate text itself. The base64 carries **no** `data:image/png;base64,` prefix, unlike the image API.
+All three fields are required: `original_image` is the base64 of the original block image, `render_image` is the base64 of that candidate rendered back into an image, and `ocr_text` is the candidate text itself. The base64 carries **no** `data:image/png;base64,` prefix, the same as the image API.
### Fields and limits
@@ -145,12 +148,14 @@ This service calls the scoring layer in-process: it does **not** need a separate
### Install
```bash
+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:
```bash
+cd scripts/minicpm-ocr-jev/
PIP_INDEX_URL=https://<mirror>/simple \
PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
bash sdk/setup_render.sh /opt/venv-render
@@ -161,6 +166,7 @@ PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
The arguments are the service port and the engine address, in that order:
```bash
+cd scripts/minicpm-ocr-jev/
JEV_BACKEND_CONFIG=sdk/backends/sglang.yaml \
PATH=/opt/venv-render/bin:$PATH bash sdk/start_render_score.sh 18500 http://127.0.0.1:18499
```
diff --git a/docs/sglang_deploy_jev_zh.md b/docs/sglang_deploy_jev_zh.md
index d2b93bd..cf39aca 100644
--- a/docs/sglang_deploy_jev_zh.md
+++ b/docs/sglang_deploy_jev_zh.md
@@ -23,12 +23,13 @@
- **不带渲染器服务** → 装服务环境 → 起服务
- **内置渲染器服务** → 装渲染环境 → 起服务
-引擎与服务必须装在两个虚拟环境里,不要合并。以下命令都在 `scripts/minicpm-ocr-jev/` 目录下执行。
+引擎与服务必须装在两个虚拟环境里,不要合并。
## 环境要求
-- **GPU**:NVIDIA,显存 ≥8GB
+- **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(仅内置渲染器服务)
@@ -47,6 +48,7 @@ pip install "sglang[all]"
启动:
```bash
+cd scripts/minicpm-ocr-jev/
python -m sglang.launch_server \
--model-path ./models/MiniCPM-OCR-Jev \
--is-embedding \
@@ -55,8 +57,8 @@ python -m sglang.launch_server \
```
- `--is-embedding`:走池化路径而不是文本生成。不加则没有 `/classify` 可调。
-- `--json-model-override-args`:权重的 `config.json` 写的是生成类 `Qwen3_5ForConditionalGeneration` 时需要它,覆盖成分类类才会返回 value head 的两个 logit;不加则加载生成类、返回 2048 维 hidden state。这是加载期覆盖,不改动磁盘上的权重文件。`config.json` 本身已写 `Qwen3_5VLForSequenceClassification` 时,这一项可以省略。
-- 类别数取自 `config.json`:有 `id2label` 则用 `len(id2label)`,否则用 `num_labels`,两者必须有其一。
+- `--json-model-override-args`:权重的 `config.json` 写的是生成类 `Qwen3_5ForConditionalGeneration` 时需要它,覆盖成分类类才会返回 value head 的两个 logit;不加则没有 score 头,`--is-embedding` 的池化路径直接返回 2048 维(`hidden_size`)hidden state。这是加载期覆盖,不改动磁盘上的权重文件。`config.json` 本身已写 `Qwen3_5VLForSequenceClassification` 时,这一项可以省略。
+- 类别数取自 `config.json`:有 `id2label` 则用 `len(id2label)`,否则用 `num_labels`,两者都没有时按 2 类处理。
- 不要加 `--chat-template`:SGLang 不套模板,SDK 直接把拼好的整串 prompt 发过去。
起服后确认引擎就绪:
@@ -98,6 +100,7 @@ Pillow 12.3.0
`JEV_BACKEND_CONFIG` 指向 SGLang 的后端配置,参数依次为服务端口、引擎地址:
```bash
+cd scripts/minicpm-ocr-jev/
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
```
@@ -125,7 +128,7 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '
{"results": [{"prob_1": 0.00227, "error": null}]}
```
-三个字段都是必填:`original_image` 是原始块图的 base64,`render_image` 是该候选渲染回图片后的 base64,`ocr_text` 是候选文本本身。base64 **不带** `data:image/png;base64,` 前缀,与镜像接口不同。
+三个字段都是必填:`original_image` 是原始块图的 base64,`render_image` 是该候选渲染回图片后的 base64,`ocr_text` 是候选文本本身。base64 **不带** `data:image/png;base64,` 前缀,与镜像接口一致。
### 字段与限额
@@ -145,12 +148,14 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '
### 安装
```bash
+cd scripts/minicpm-ocr-jev/
bash sdk/setup_render.sh /opt/venv-render
```
它装 Node、CJK 字体、Chromium 与服务依赖。慢网下设两个镜像源:
```bash
+cd scripts/minicpm-ocr-jev/
PIP_INDEX_URL=https://<mirror>/simple \
PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
bash sdk/setup_render.sh /opt/venv-render
@@ -161,6 +166,7 @@ PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
参数依次为服务端口、引擎地址:
```bash
+cd scripts/minicpm-ocr-jev/
JEV_BACKEND_CONFIG=sdk/backends/sglang.yaml \
PATH=/opt/venv-render/bin:$PATH bash sdk/start_render_score.sh 18500 http://127.0.0.1:18499
```
diff --git a/docs/vllm_deploy_jev_en.md b/docs/vllm_deploy_jev_en.md
index 0c32ee7..b5f2197 100644
--- a/docs/vllm_deploy_jev_en.md
+++ b/docs/vllm_deploy_jev_en.md
@@ -23,7 +23,7 @@ Both services share one forward engine. The only difference is where the render
- **Score service** → install the service environment → start the service
- **Render+score service** → install the render environment → start the service
-The engine and the service must go into two separate virtual environments; do not merge them. All commands below run from `scripts/minicpm-ocr-jev/`.
+The engine and the service must go into two separate virtual environments; do not merge them.
## Requirements
@@ -43,6 +43,7 @@ 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
+cd scripts/minicpm-ocr-jev/
bash serve/setup_backend.sh /opt/venv-vllm
PATH=/opt/venv-vllm/bin:$PATH bash sdk/start_engine.sh 0 18499 /path/to/weights
```
@@ -99,6 +100,7 @@ Pillow 12.3.0
The arguments are the service port and the engine address, in that order:
```bash
+cd scripts/minicpm-ocr-jev/
PATH=/opt/venv-score/bin:$PATH bash sdk/start_score.sh 18501 http://127.0.0.1:18499
```
@@ -123,7 +125,7 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '
{"results": [{"prob_1": 0.00227, "error": null}]}
```
-All three fields are required: `original_image` is the base64 of the original block image, `render_image` is the base64 of that candidate rendered back into an image, and `ocr_text` is the candidate text itself. The base64 carries **no** `data:image/png;base64,` prefix, unlike the image API.
+All three fields are required: `original_image` is the base64 of the original block image, `render_image` is the base64 of that candidate rendered back into an image, and `ocr_text` is the candidate text itself. The base64 carries **no** `data:image/png;base64,` prefix, the same as the image API.
### Fields and limits
@@ -143,12 +145,14 @@ This service calls the scoring layer in-process: it does **not** need a separate
### Install
```bash
+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:
```bash
+cd scripts/minicpm-ocr-jev/
PIP_INDEX_URL=https://<mirror>/simple \
PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
bash sdk/setup_render.sh /opt/venv-render
@@ -159,6 +163,7 @@ PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
The arguments are the service port and the engine address, in that order:
```bash
+cd scripts/minicpm-ocr-jev/
PATH=/opt/venv-render/bin:$PATH bash sdk/start_render_score.sh 18500 http://127.0.0.1:18499
```
diff --git a/docs/vllm_deploy_jev_zh.md b/docs/vllm_deploy_jev_zh.md
index 7d677de..5e7afd3 100644
--- a/docs/vllm_deploy_jev_zh.md
+++ b/docs/vllm_deploy_jev_zh.md
@@ -23,7 +23,7 @@
- **不带渲染器服务** → 装服务环境 → 起服务
- **内置渲染器服务** → 装渲染环境 → 起服务
-引擎与服务必须装在两个虚拟环境里,不要合并。以下命令都在 `scripts/minicpm-ocr-jev/` 目录下执行。
+引擎与服务必须装在两个虚拟环境里,不要合并。
## 环境要求
@@ -43,6 +43,7 @@
用随附脚本安装并启动,参数依次为 GPU 号、端口、权重路径:
```bash
+cd scripts/minicpm-ocr-jev/
bash serve/setup_backend.sh /opt/venv-vllm
PATH=/opt/venv-vllm/bin:$PATH bash sdk/start_engine.sh 0 18499 /path/to/weights
```
@@ -99,6 +100,7 @@ Pillow 12.3.0
参数依次为服务端口、引擎地址:
```bash
+cd scripts/minicpm-ocr-jev/
PATH=/opt/venv-score/bin:$PATH bash sdk/start_score.sh 18501 http://127.0.0.1:18499
```
@@ -123,7 +125,7 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '
{"results": [{"prob_1": 0.00227, "error": null}]}
```
-三个字段都是必填:`original_image` 是原始块图的 base64,`render_image` 是该候选渲染回图片后的 base64,`ocr_text` 是候选文本本身。base64 **不带** `data:image/png;base64,` 前缀,与镜像接口不同。
+三个字段都是必填:`original_image` 是原始块图的 base64,`render_image` 是该候选渲染回图片后的 base64,`ocr_text` 是候选文本本身。base64 **不带** `data:image/png;base64,` 前缀,与镜像接口一致。
### 字段与限额
@@ -143,12 +145,14 @@ curl -s http://127.0.0.1:18501/v1/score -H 'Content-Type: application/json' -d '
### 安装
```bash
+cd scripts/minicpm-ocr-jev/
bash sdk/setup_render.sh /opt/venv-render
```
它装 Node、CJK 字体、Chromium 与服务依赖。慢网下设两个镜像源:
```bash
+cd scripts/minicpm-ocr-jev/
PIP_INDEX_URL=https://<mirror>/simple \
PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
bash sdk/setup_render.sh /opt/venv-render
@@ -159,6 +163,7 @@ PLAYWRIGHT_DOWNLOAD_HOST=https://<mirror>/playwright \
参数依次为服务端口、引擎地址:
```bash
+cd scripts/minicpm-ocr-jev/
PATH=/opt/venv-render/bin:$PATH bash sdk/start_render_score.sh 18500 http://127.0.0.1:18499
```
diff --git a/scripts/minicpm-ocr-jev/sdk/app.py b/scripts/minicpm-ocr-jev/sdk/app.py
index a30723d..cd4fdcc 100644
--- a/scripts/minicpm-ocr-jev/sdk/app.py
+++ b/scripts/minicpm-ocr-jev/sdk/app.py
@@ -69,10 +69,15 @@ ALLOW_UNVERIFIED = os.environ.get("JEV_ALLOW_UNVERIFIED") == "1"
INPUT_FORMS = ("ternary",)
-#: Scores for candidates that never reached the model. 0.0 rather than null: a
-#: candidate whose LaTeX will not parse is not a plausible transcription, and a
-#: caller ranking candidates wants it to lose rather than to be absent.
-SENTINEL = 0.0
+#: prob_yes for items that never reached the model -- the same two values as the
+#: Docker image's serve/app.py, because callers switch between the two without
+#: touching their code:
+#: 0.0 -- the candidate was judged unusable (bad LaTeX, render failed).
+#: -1.0 -- we never found out (bad input bytes, backend error).
+#: Both lose every argmax and fail every threshold, and the summary counts only
+#: `scored` items, so neither value moves a mean or a rate.
+SENTINEL = {"precheck_reject": 0.0, "render_error": 0.0,
+ "missing_original_image": 0.0, "encode_error": -1.0, "forward_error": -1.0}
STATE: dict[str, Any] = {"scorer": None, "pool": None, "selfcheck": None}
@@ -299,7 +304,7 @@ async def _run(items: list[ScoreItem], thr: float,
except ValueError as exc:
failed[item.case_id] = ScoreResultItem(
case_id=item.case_id, category=item.category,
- verdict="encode_error", prob_yes=SENTINEL,
+ verdict="encode_error", prob_yes=SENTINEL["encode_error"],
detail=f"image is not valid base64: {exc}")
continue
path = work / f"{uuid.uuid4().hex}.png"
@@ -319,15 +324,16 @@ async def _run(items: list[ScoreItem], thr: float,
except ValueError as exc:
failed[item.case_id] = ScoreResultItem(
case_id=item.case_id, category=item.category,
- verdict="encode_error", prob_yes=SENTINEL,
+ verdict="encode_error", prob_yes=SENTINEL["encode_error"],
detail=f"render_image is not valid base64: {exc}")
continue
result = renders.get(item.case_id)
if result is None or not result.ok or not result.render_image_path:
+ reason = (result.reason if result else "render_error") or "render_error"
failed[item.case_id] = ScoreResultItem(
- case_id=item.case_id, category=item.category,
- verdict=(result.reason if result else "render_error") or "render_error",
- prob_yes=SENTINEL, detail=(result.detail if result else "") or "")
+ case_id=item.case_id, category=item.category, verdict=reason,
+ prob_yes=SENTINEL.get(reason, 0.0),
+ detail=(result.detail if result else "") or "")
continue
render_path = Path(result.render_image_path)
if not render_path.is_file():
@@ -336,7 +342,7 @@ async def _run(items: list[ScoreItem], thr: float,
# inside the image loader, where the cause is unrecognisable.
failed[item.case_id] = ScoreResultItem(
case_id=item.case_id, category=item.category,
- verdict="render_error", prob_yes=SENTINEL,
+ verdict="render_error", prob_yes=SENTINEL["render_error"],
detail=f"render reported ok but {render_path} is missing")
continue
scorable.append((item, render_path.read_bytes()))
@@ -358,7 +364,8 @@ async def _run(items: list[ScoreItem], thr: float,
raise outcome
scored[item.case_id] = ScoreResultItem(
case_id=item.case_id, category=item.category,
- verdict="forward_error", prob_yes=SENTINEL, detail=str(outcome))
+ verdict="forward_error", prob_yes=SENTINEL["forward_error"],
+ detail=str(outcome))
else:
scored[item.case_id] = ScoreResultItem(
case_id=item.case_id, category=item.category, verdict="scored",
@@ -432,9 +439,12 @@ async def healthz() -> JSONResponse:
"template_md5": PROMPT_TEMPLATE_MD5},
"prompt_selfcheck": {
"passed": check.passed if check else None,
+ # Who assembled the prompt, which decides which checks below could run.
+ "source": check.prompt_source if check else None,
"last_token": check.last_token if check else None,
"token_equality": check.token_equality if check else None,
"scoring_request": check.scoring_request if check else None,
+ "forward_shape": check.forward_shape if check else None,
},
"threshold_default": THRESHOLD,
}
@@ -443,10 +453,12 @@ async def healthz() -> JSONResponse:
@app.post("/v1/rm/score", response_model=ScoreResponse)
async def score(req: ScoreRequest) -> ScoreResponse:
+ # 400 for both, as the Docker image answers; the SDK's own /v1/score keeps
+ # its 413 -- that endpoint has no counterpart in the image.
if not req.items:
- raise HTTPException(422, "items must not be empty")
+ raise HTTPException(400, "items must not be empty")
if len(req.items) > MAX_ITEMS:
- raise HTTPException(413, f"at most {MAX_ITEMS} items per request, got {len(req.items)}")
+ raise HTTPException(400, f"at most {MAX_ITEMS} items per request, got {len(req.items)}")
seen = {i.case_id for i in req.items}
if len(seen) != len(req.items):
raise HTTPException(422, "case_id must be unique within a request")
@@ -515,7 +527,11 @@ async def score_best_batch(req: ScoreBestBatchRequest) -> ScoreBestBatchResponse
if len(items) > MAX_ITEMS:
raise HTTPException(400, f"at most {MAX_ITEMS} candidates per request, got {len(items)}")
- thr = THRESHOLD if req.threshold is None else req.threshold
+ # No per-request threshold here: ScoreBestBatchRequest carries none, and the
+ # Docker image's endpoint of the same name does not take one either. The
+ # fields of the two must stay identical -- callers switch between image and
+ # SDK without touching their payloads.
+ thr = THRESHOLD
stage_sec: dict[str, float] = {}
results = await _run(items, thr, stage_sec)
return ScoreBestBatchResponse(
diff --git a/scripts/minicpm-ocr-jev/sdk/jev_score/__init__.py b/scripts/minicpm-ocr-jev/sdk/jev_score/__init__.py
index c93de72..0a1bf83 100644
--- a/scripts/minicpm-ocr-jev/sdk/jev_score/__init__.py
+++ b/scripts/minicpm-ocr-jev/sdk/jev_score/__init__.py
@@ -14,7 +14,12 @@ renders; the threshold belongs to whoever is using the number.
"""
from .backends import Backend, BackendError, load_backend
from .prompt import INSTRUCTION, PROMPT_TEMPLATE_MD5, PromptParts, build_parts
-from .scorer import ScoreInput, Scorer, softmax_prob_1
+from .scorer import (
+ ScoreInput,
+ Scorer,
+ prob_1_from_probabilities,
+ softmax_prob_1,
+)
from .selfcheck import EXPECTED_LAST_TOKEN, SelfCheckFailed, SelfCheckResult, run_selfcheck
__all__ = [
@@ -30,6 +35,7 @@ __all__ = [
"SelfCheckResult",
"build_parts",
"load_backend",
+ "prob_1_from_probabilities",
"run_selfcheck",
"softmax_prob_1",
]
diff --git a/scripts/minicpm-ocr-jev/sdk/jev_score/backends/base.py b/scripts/minicpm-ocr-jev/sdk/jev_score/backends/base.py
index ba9fb64..3b02299 100644
--- a/scripts/minicpm-ocr-jev/sdk/jev_score/backends/base.py
+++ b/scripts/minicpm-ocr-jev/sdk/jev_score/backends/base.py
@@ -8,15 +8,30 @@ different again. They also disagree about where the two class logits come back
So the adapter boundary is drawn at the narrowest place where they still agree:
- give me this candidate's prompt and its two images -> give me two raw logits
-
-Everything above the line (softmax, probabilities, the HTTP shell) is written
-once. Everything below it is per engine.
-
-`logits`, not probabilities, is the contract on purpose. An engine that applies
-its own activation returns numbers that look right, rank right, and are not the
-published scale; asking for raw logits and doing the softmax ourselves is the
-only version of this that cannot drift quietly.
+ give me this candidate's prompt and its two images -> give me the two class
+ scores, in class order [0, 1]
+
+Everything above the line (the HTTP shell, the probability) is written once.
+Everything below it is per engine.
+
+Two families of engine, and `output_kind` says which one an adapter is:
+
+ "logits" vLLM, SGLang -- two raw logits, this layer applies the softmax
+ "probabilities" llama.cpp, Ollama -- the engine already applied it
+
+Raw logits are preferred wherever an engine will hand them over, for the reason
+the second family makes concrete: an engine that applies its own activation
+returns numbers that look right, rank right, and need not be on the published
+scale. `/v1/systemone` is accepted into the contract because its softmax is the
+same one -- temperature 1 over the same two class scores -- not because the
+distinction stopped mattering.
+
+What that costs, and what replaces it: an adapter claiming "logits" cannot be
+mistaken for one claiming "probabilities", because the softmax of a probability
+pair is not a probability pair. So `scorer.py` checks the claim instead of
+trusting it -- two numbers declared as probabilities must lie in [0, 1] and sum
+to 1. That catches the one confusion this extension introduces, which is an
+adapter that mislabels which family it belongs to.
"""
from __future__ import annotations
@@ -35,13 +50,20 @@ class BackendError(RuntimeError):
class Backend(Protocol):
"""One forward-pass engine."""
+ #: "logits" or "probabilities" -- which of the two families `forward` returns.
+ #: Read with a default of "logits", so an adapter written before this existed
+ #: keeps its old meaning rather than silently changing scale.
+ output_kind: str
+
async def forward(
self,
parts: PromptParts,
original_data_url: str,
render_data_url: str,
) -> list[float]:
- """Two raw class logits for one candidate, in class order [0, 1].
+ """The two class scores for one candidate, in class order [0, 1].
+
+ Raw logits or probabilities according to `output_kind`.
Raises `BackendError` if the engine is unreachable, is still loading, or
returns anything other than exactly two numbers.
diff --git a/scripts/minicpm-ocr-jev/sdk/jev_score/backends/vllm_backend.py b/scripts/minicpm-ocr-jev/sdk/jev_score/backends/vllm_backend.py
index 9cea081..7025533 100644
--- a/scripts/minicpm-ocr-jev/sdk/jev_score/backends/vllm_backend.py
+++ b/scripts/minicpm-ocr-jev/sdk/jev_score/backends/vllm_backend.py
@@ -37,6 +37,16 @@ __all__ = ["VLLMBackend"]
class VLLMBackend:
"""Talks to one `vllm serve` process over HTTP."""
+ #: Who assembles the prompt. The engine does, from the model's own template,
+ #: so `selfcheck.py` has to interrogate it rather than check our own output.
+ prompt_source = "engine"
+
+ #: `/classify` returns the value head's two raw logits -- the request asks for
+ #: them with `use_activation: false` -- and `scorer.py` applies the softmax.
+ #: Spelled out rather than left to the default, so the two families stay
+ #: visible side by side in `sdk/backends/`.
+ output_kind = "logits"
+
#: What the three request keys above are worth, in one place, so that the
#: forward and tokenize paths cannot drift apart. `selfcheck` only proves the
#: prompt is right if it asks the same question the scorer will ask.
diff --git a/scripts/minicpm-ocr-jev/sdk/jev_score/server.py b/scripts/minicpm-ocr-jev/sdk/jev_score/server.py
index b37d745..6845c58 100644
--- a/scripts/minicpm-ocr-jev/sdk/jev_score/server.py
+++ b/scripts/minicpm-ocr-jev/sdk/jev_score/server.py
@@ -115,9 +115,14 @@ def create_app() -> FastAPI:
"served_model": served,
"prompt": {
"template_md5": PROMPT_TEMPLATE_MD5,
+ # Who assembled it, which decides which of the checks below could
+ # run at all: an engine that templates for us is interrogated, one
+ # that does not is checked on our side instead.
+ "source": check.prompt_source if check else None,
"last_token": check.last_token if check else None,
"expected_last_token": check.expected_last_token if check else None,
"token_equality": check.token_equality if check else None,
+ "forward_shape": check.forward_shape if check else None,
"notes": check.notes if check else [],
},
}