Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

change skill

jinzhenj90770107e528
diff --git a/README.md b/README.md
index f55f7856..cd57f237 100644
--- a/README.md
+++ b/README.md
@@ -123,7 +123,7 @@ mineru read "doc:ab12cd3/tier:standard/page:18" --json
## Installation And Setup
-This skill requires MinerU `>=4.0.0a3`. Before using any workflow, check whether the CLI is installed:
+This skill requires MinerU `>=4.0.0a6`. Before using any workflow, check whether the CLI is installed:
```bash
command -v mineru
@@ -287,12 +287,12 @@ mineru telemetry flush
MinerU has four tiers:
-| Tier | Chinese name | Quality and speed | Local requirements | Local model download | Use for |
-|---|---|---|---|---|---|
-| `flash` | 极速解析 | Lowest quality; fastest | No special hardware | None | Discovery, preview, and indexing; never default final reading quality |
-| `basic` | 基础解析 | Basic quality; moderate speed | At least 16 GB total memory; CPU works, GPU can accelerate | About 2 GB | Private local reading or lower-resource local parsing |
-| `standard` | 标准解析 | Standard high quality; similar speed to `basic` on suitable hardware | At least 16 GB total memory plus a supported accelerator | About 4 GB | Default for normal active reading and complex documents |
-| `advanced` | 高级解析 | Standard quality on ordinary documents and better quality on difficult documents; slowest | Same as Standard, with greater compute use | About 4 GB | Difficult documents and maximum-quality work when the user accepts a longer wait |
+| Tier | Chinese name | Quality and speed | Use for |
+|---|---|---|---|
+| `flash` | 极速解析 | Lowest quality; fastest | Discovery, preview, and indexing; never default final reading quality |
+| `basic` | 基础解析 | Basic quality; moderate speed | Private local reading or lower-resource local parsing |
+| `standard` | 标准解析 | Standard high quality; similar speed to `basic` on suitable hardware | Default for normal active reading and complex documents |
+| `advanced` | 高级解析 | Standard quality on ordinary documents and better quality on difficult documents; slowest | Difficult documents and maximum-quality work when the user accepts a longer wait |
Default tier behavior:
@@ -322,6 +322,48 @@ mineru parse "paper.pdf" --tier advanced
mineru parse "paper.pdf" --tier flash
```
+## Model Stacks
+
+MinerU use neural network models for local `basic`, `standard`, and `advanced` parsing.
+To better support different hardwares, MinerU provide two model stacks: `light` and `full`.
+
+| Stack | Model engines | Install |
+|---|---|---|
+| `light` | ONNX + llama.cpp | Already in `mineru` base module |
+| `full` | PyTorch + vLLM/lmdeploy/mlx | Requires `mineru[full]` extra |
+
+Stack controls resource use and download size:
+
+| Tier | Stack | Model download | RAM (min) | Accelerator |
+|---|---|---|---|---|
+| `basic` | `light` | ~0.8 GB | 4 GB | None (CPU works) |
+| `basic` | `full` | ~2 GB | 16 GB | GPU/MPS recommended |
+| `standard` / `advanced` | `light` | ~2 GB | 8 GB | CPU works, Vulkan recommended |
+| `standard` / `advanced` | `full` | ~4 GB | 16 GB | GPU/MPS required, 8 GB+ VRAM |
+
+The default setting is `auto`: CPU uses `light`, while GPU, MPS, and other accelerators with `mineru[full]` installed use `full`.
+To select a stack explicitly for the current environment, set:
+
+```bash
+export MINERU_MODEL_STACK=light # or full, or auto
+```
+
+To persist the selection, set it in `config.yaml`:
+
+```yaml
+model:
+ stack: light
+```
+
+Stop and restart the MinerU server after changing the stack because running processes do not reload startup configuration.
+
+Download and verify models for a specific stack:
+
+```bash
+mineru-kit models download --tier <tier> --stack <stack>
+mineru-kit models verify --tier <tier> --stack <stack>
+```
+
## Server Rules
Most `mineru` commands use the local MinerU background service. If a command fails with `server_not_running`, start it:
@@ -357,7 +399,7 @@ Agent rules:
Use a local parse server when the user wants `basic`, `standard`, or `advanced` quality without sending the document to remote parsing.
-### Assess Local Hardware
+### Inspect Local Hardware
When no local quality tier is available, inspect the current machine before presenting the recovery choices. `mineru server status --json` shows which tiers are currently configured and available. An empty local `supported_tiers` list may simply mean that the local parse server is disabled or not configured, so inspect the hardware before deciding whether local quality tiers can run.
@@ -368,61 +410,68 @@ Use available read-only system commands to inspect the OS, architecture, total m
- Windows PowerShell: `(Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory`, `Get-CimInstance Win32_Processor`, and `nvidia-smi` when available.
- Other accelerators: use an already-installed vendor tool if available; do not install software merely to inspect hardware.
-Classify each local quality tier as `hardware-supported`, `hardware-unsupported`, or `hardware-unknown`. These labels describe hardware suitability only, not whether the required dependencies and models are installed or the tier is currently available:
-
-- `basic`: `hardware-supported` with at least 16 GB total memory. A CPU is sufficient, but warn that CPU-only parsing may be slow and GPU acceleration can materially reduce parsing time.
-- `standard` and `advanced`: `hardware-supported` with at least 16 GB total memory and either a Volta-or-newer NVIDIA GPU with at least 8 GB available VRAM or Apple Silicon with at least 16 GB unified memory.
-- For `standard` and `advanced`, an `npu`, `gcu`, `musa`, `mlu`, or `sdaa` qualifies as `hardware-supported` only when MinerU compatibility with the exact device and runtime can be verified; otherwise report `hardware-unknown`.
-- Report `hardware-unsupported` when a requirement is clearly not met. If a required property cannot be verified, report `hardware-unknown`.
-
-Before asking the user to choose a tier, summarize the detected hardware and identify each local tier's hardware status. Recommend local `standard` when `hardware-supported`, otherwise local `basic` when `hardware-supported`, otherwise offer remote `standard` when privacy rules allow or explicit `flash`. Mention `advanced` only when the user wants maximum quality and accepts the extra time. Do not install dependencies, download models, change config, or restart services without approval.
+### Choose Local Stack
-### Configure Managed Local Parsing
+The `light` stack is suitable for most hardwares, including CPU-only machines, Apple Silicon, and low-end iGPU/GPU machines.
-Change local parse-server config or restart the server only when the user asks for or approves local high-quality parsing.
+Install and use `full` stack only when you have enough RAM and powerful GPU/accelerator, accept extra installation disk space, and want a higher throughput. Hardware requirements:
+- At least 16 GB total memory.
+- A Volta-or-newer NVIDIA GPU with at least 8 GB available VRAM, or an `npu`, `gcu`, `musa`, `mlu`, or `sdaa` accelerator.
+- Consumes ~5GB more disk space.
-Managed local parsing requires optional runtime dependencies. Install the required extra with the same installation tool and environment that installed the current `mineru` command.
+To use the `full` stack, install the `mineru[full]` extra.
The following examples assume the current install tool is `uv tool`. If `mineru` was installed with another tool or environment, use the equivalent command for that actual tool/environment.
-Installing extras with `uv tool install --force --prerelease allow` can replace the active `mineru` environment. Stop the MinerU server first, confirm `running=false`, and start it again after installing dependencies and models.
-
-Managed local parsing has two startup tiers: `basic` and `standard`. A Standard server provides `basic`, `standard`, and `advanced` request tiers. Advanced uses the same Standard dependencies, model set, and hardware setup; it differs only by spending more inference compute when the request selects `--tier advanced`.
-
-Enable managed local parsing for `basic`:
+Installing extras with `uv tool install --force --prerelease allow` can replace the active `mineru` environment. Stop the MinerU server first, confirm `running=false`, and start it again after installing dependencies.
```bash
mineru server stop
mineru server status --json
-uv tool install --force --prerelease allow "mineru[basic]"
-mineru-kit models download --tier basic
-mineru-kit models verify --tier basic
+uv tool install --force --prerelease allow "mineru[full]"
mineru server start
-mineru config set parse_server.local.managed_tier basic
-mineru config set parse_server.local.mode managed
mineru server status --json
```
-Enable managed local parsing for both `standard` and `advanced` requests:
+### Choose Local Tier
+
+Managed local parsing has two startup tiers: `basic` and `standard`. A Standard server provides `basic`, `standard`, and `advanced` request tiers. Advanced uses the same Standard dependencies, model set, and hardware setup; it differs only by spending more inference compute when the request selects `--tier advanced`.
+
+- `basic` tier with `light` stack, requires at least 4GB total memory.
+- `standard` tier with `light` stack, requires at least 8GB total memory, recommended for GPU/Metal.
+- `basic` tier with `full` stack, recommended for `npu`, `gcu`, `musa`, `mlu`, or `sdaa`.
+- `standard` tier with `full` stack, recommended for high-end nvidia GPU.
+
+### Recommend and Ask
+
+After hardware was inspected, you already know the suitable stack and tier for current machine. Before asking the user to choose a tier/stack, summarize the detected hardware and identify each tier's hardware status.
+
+You should recommend a tier for user when the machine meets such requirements, otherwise offer remote `standard` when privacy rules allow, or use explicit `flash`.
+
+Mention `advanced` only when the user wants maximum quality and accepts the extra time. Do not install dependencies, download models, change config, or restart services without approval.
+
+### Configure Managed Parse Server
+
+First, download the models for the target startup tier (`basic`, or `standard`).
+Replace `<tier>` with `basic` or `standard`.
+
+```bash
+mineru-kit models download --tier <tier> --stack <stack>
+mineru-kit models verify --tier <tier> --stack <stack>
+```
+
+Then, enable managed local parse server for the startup tier.
```bash
-mineru server stop
-mineru server status --json
-uv tool install --force --prerelease allow "mineru[standard]"
-mineru-kit models download --tier standard
-mineru-kit models verify --tier standard
-mineru server start
-mineru config set parse_server.local.managed_tier standard
+mineru config set parse_server.local.managed_tier <tier>
mineru config set parse_server.local.mode managed
mineru server status --json
```
Rules:
-- Determine how the current `mineru` command was installed, then install the extra through that same tool/environment.
-- Stop the MinerU server and confirm `running=false` before replacing its environment, especially on Windows.
+- Change local parse-server config or restart the server only when the user asks for or approves.
- Download and verify models for the startup tier (`basic` or `standard`) before enabling managed mode.
-- Start the MinerU server only after the extra and models are ready.
- Set `parse_server.local.managed_tier` before `parse_server.local.mode=managed`.
- Poll `mineru server status --json` and use managed parsing only after the target tier is healthy.
- If local quality parsing cannot start, do not add `--remote` automatically; ask the user first.
diff --git a/docs/next/cli/mineru-e2e-test-cases.md b/docs/next/cli/mineru-e2e-test-cases.md
index 2da3a161..764d671a 100644
--- a/docs/next/cli/mineru-e2e-test-cases.md
+++ b/docs/next/cli/mineru-e2e-test-cases.md
@@ -58,9 +58,10 @@
- `$MINERU_E2E_FIXTURE_DIR/no-read.pdf`,权限不可读文件;若平台无法稳定制造权限场景,可标记相关用例 BLOCKED。
- `$MINERU_E2E_FIXTURE_DIR/output-dir/`,用于输出文件测试的目录。
- 测试环境允许启动本地 doclib server。
-- 测试环境必须安装 `standard` extra,以覆盖本地 `basic`、`standard`、`advanced` quality parse-server;默认 tier 相关用例应验证本地 quality tier 可用,不再按缺少本地 quality tier 的预期失败分支判定。
-- MinerU 的公开 tier 只有 `flash`、`basic`、`standard`、`advanced`;默认 quality tier 选择顺序为 `standard`、`advanced`、`basic`,已缓存结果的读取顺序为 `advanced`、`standard`、`basic`、`flash`。
-- 显式指定 quality tier 的 remote 请求应按 remote 成功、remote 失败后同 tier local fallback、remote 与 local 均不可用三个分支判定;不得 fallback 到 `flash`。未指定 tier 时需要先从 remote 能力中按 `standard`、`advanced`、`basic` 选择默认值,无法选择时返回 `quality_tier_unavailable`。
+- 测试环境必须安装 `full` extra,并满足 README 中 `full` stack 的硬件要求,以同时覆盖 `light` 和 `full` model stack 下的本地 `basic`、`standard`、`advanced` quality parse-server;默认 tier 相关用例应验证本地 quality tier 可用,不再按缺少本地 quality tier 的预期失败分支判定。
+- 全量主流程固定使用 `light` stack;`full` stack 作为硬性 profile,必须额外覆盖本地 PDF Basic、Standard、Advanced。不得使用 `auto` 执行这些用例,以免硬件探测导致测试环境不确定。
+- MinerU 的公开 tier 只有 `flash`、`basic`、`standard`、`advanced`;默认 quality tier 选择顺序为 `standard`、`basic`,`advanced` 只在显式请求时使用;已缓存结果的读取顺序为 `advanced`、`standard`、`basic`、`flash`。
+- 显式指定 quality tier 的 remote 请求应按 remote 成功、remote 失败后同 tier local fallback、remote 与 local 均不可用三个分支判定;不得 fallback 到 `flash`。未指定 tier 时需要先从 remote 能力中按 `standard`、`basic` 选择默认值,无法选择时返回 `quality_tier_unavailable`;仅暴露 `advanced` 不构成可用的默认 quality tier。
- PARSE-013A1 是 remote Standard 硬性测试,remote parse-server 不可用或不支持 Standard 均记录为失败。
### 2.1 测试 HOME 与隔离配置
@@ -71,13 +72,16 @@
~/mineru-e2e-test
```
-进入测试目录后,只需设置 `MINERU_HOME`,即可让默认配置文件(`$MINERU_HOME/config.yaml`)、DB、日志、endpoint discovery 文件、UDS socket(启用 UDS 时)和数据目录都落在测试目录中:
+进入测试目录后,设置 `MINERU_HOME` 隔离运行数据,并将全量主流程固定为 `light` stack:
```bash
cd ~/mineru-e2e-test
export MINERU_HOME=`pwd`
+export MINERU_MODEL_STACK=light
```
+`MINERU_HOME` 使默认配置文件(`$MINERU_HOME/config.yaml`)、DB、日志、endpoint discovery 文件、UDS socket(启用 UDS 时)和数据目录都落在测试目录中。`MINERU_MODEL_STACK=light` 必须由 doclib server 及其 managed parse-server 继承。
+
### 2.2 安装方法
在测试 HOME 中创建独立虚拟环境并安装当前仓库:
@@ -88,12 +92,12 @@ rm -rf .venv
uv venv .venv
source .venv/bin/activate
cd ~/MinerU-Repo
-uv pip install ".[standard]"
+uv pip install ".[full]"
cd ~/mineru-e2e-test
mineru --help
```
-当前仓库以 `standard` extra 覆盖 Standard 和 Advanced 的共同 runtime 依赖,并通过其包含的 `basic` extra 覆盖 Basic。
+基础安装已包含 `light` stack 所需的 ONNX 和 llama.cpp runtime;`full` extra 额外安装 PyTorch、vLLM/lmdeploy/mlx 等完整 runtime。由于本 E2E 将 `full` profile 作为硬性测试,安装阶段统一使用 `.[full]`。
安装完成后,`mineru` 应由 `pyproject.toml` 的脚本入口直接提供,不需要配置 shell alias。
@@ -108,16 +112,46 @@ mineru --help
```bash
cd ~/mineru-e2e-test
source .venv/bin/activate
-mineru-kit models download --tier standard
-mineru-kit models verify --tier standard
+mineru-kit models download --tier standard --stack light
+mineru-kit models verify --tier standard --stack light
+mineru-kit models download --tier standard --stack full
+mineru-kit models verify --tier standard --stack full
```
说明:
-- Standard 模型集覆盖 Advanced,并包含 Basic 所需模型。
+- 每个 stack 的 Standard 模型集覆盖该 stack 的 Advanced 请求,并包含 Basic 所需模型。
+- 模型下载和验证必须显式传 `--stack`;不得依赖 `model.stack=auto` 的硬件探测结果。
- 如果需要验证模型未准备好的 config 拦截分支,应使用新的隔离 `MINERU_HOME`,或在测试开始前清空该隔离 HOME 下的 `models/` 目录。
+- 模型未准备分支固定继承 `MINERU_MODEL_STACK=light`,确保断言针对 light 模型集。
- 正式 case 执行阶段仍只调用 `mineru ...` 命令。
+### 2.2.2 Model stack profile 切换
+
+全量主流程默认在 `light` profile 下执行。切换 profile 前必须停止 doclib server,使新的 server 和 managed parse-server 继承目标环境变量。
+
+切换到 `full` profile:
+
+```bash
+mineru config set parse_server.local.mode disabled
+mineru server stop
+export MINERU_MODEL_STACK=full
+mineru server start
+```
+
+恢复 `light` profile:
+
+```bash
+mineru config set parse_server.local.mode disabled
+mineru server stop
+export MINERU_MODEL_STACK=light
+mineru server start
+mineru config set parse_server.local.managed_tier standard
+mineru config set parse_server.local.mode managed
+```
+
+切换后必须轮询 `mineru server status --json`,直到 doclib 正常运行且目标 local parse-server healthy,再执行对应 profile 的 parse case。不得在 server 运行期间仅修改环境变量并假定 stack 已切换。
+
### 2.3 Fixture 生成方法
fixture 准备阶段允许使用 shell 文件操作创建隔离测试数据。`mineru` 命令限制只适用于正式 case 执行阶段。
@@ -523,14 +557,20 @@ export MINERU_HOME="$MAIN_MINERU_HOME"
2. 确认 `$MINERU_HOME/doclib.lock` 存在。
3. 使用相同环境直接执行第二个 `python -m mineru.doclib.app`。
4. 确认第二个进程立即失败,第一个 server 仍可通过 status 访问。
-5. 强制终止第一个 server 进程,再次执行 `mineru server start`。
+5. 保留 endpoint 中有效的 PID 和 `server_id`,临时将 transports 改为不可连接的地址,依次执行 `mineru server status --json`、
+ `mineru server start` 和 `mineru server stop`。
+6. 恢复原 endpoint,确认第一个 server 仍可通过 status 访问。
+7. 强制终止第一个 server 进程,再次执行 `mineru server start`。
预期:
- 第二个进程 exit code 非 0,stderr 包含当前 home,但不显示 `doclib.lock` 路径。
- 第二个进程不删除第一个实例的 endpoint 或 UDS socket。
-- endpoint 不可连接但 ownership lock 被占用时,status/start/stop 返回 `service_unavailable` 和统一的 home ownership 消息,
- 不得报告普通未运行状态;endpoint 含有效 PID 时,错误中包含 `reported PID <pid>`,但不自动终止进程。
+- endpoint 不可连接但 ownership lock 被占用时,`mineru server status --json` exit code = 0,stdout 为可直接解析的 JSON,
+ `status = starting`;endpoint 含有效 PID 时同时返回相同的 `pid`,不得报告普通未运行状态。
+- 同一状态下,`mineru server start` 和 `mineru server stop` exit code 非 0,stderr 包含统一的 home ownership 消息;
+ endpoint 含有效 PID 时消息包含 `reported PID <pid>`。错误输出不要求显示内部错误码 `service_unavailable`。
+- status/start/stop 的 ownership 诊断不得自动终止第一个 server;恢复原 endpoint 后,第一个 server 仍可访问。
- 第一个进程退出后 OS lock 自动释放;replacement 能取得 ownership、清理 stale discovery 文件并正常启动。
- `doclib.lock` 文件是否存在不表示 server 是否正在运行,其保留行为可能因平台而异。
@@ -883,7 +923,7 @@ mineru config get parse_server.local.mode --json
前置条件:
-- 使用已完成 `mineru-kit models download --tier basic` 和 `mineru-kit models verify --tier basic` 的 `MINERU_HOME`。
+- 使用已完成 `mineru-kit models download --tier basic --stack light` 和 `mineru-kit models verify --tier basic --stack light` 的 `MINERU_HOME`。
命令:
@@ -1497,6 +1537,8 @@ mineru parse "$MINERU_E2E_FIXTURE_DIR/sample.pdf" --tier flash --pages 1~1 --for
### PARSE-007 默认 tier 行为
+Profile 前置条件: `MINERU_MODEL_STACK=light`,doclib server 及 managed parse-server 均在该环境下启动。PARSE-007、PARSE-007A、PARSE-007B、PARSE-007C 构成 `light` profile 的本地 PDF tier 覆盖。
+
命令:
```bash
@@ -1521,7 +1563,7 @@ mineru show parse <created_parse_id> --json
- 不允许静默返回 flash 内容
- 不包含 Python traceback
-### PARSE-007A PDF local basic tier
+### PARSE-007A PDF local basic tier(light stack)
命令:
@@ -1548,7 +1590,7 @@ mineru show parse <created_parse_id> --json
- show JSON 中 `tier = basic`、`privacy = local`、`via = local`
- 不包含 Python traceback
-### PARSE-007B PDF local standard tier
+### PARSE-007B PDF local standard tier(light stack)
命令:
@@ -1575,7 +1617,7 @@ mineru show parse <created_parse_id> --json
- show JSON 中 `tier = standard`、`privacy = local`、`via = local`
- 不包含 Python traceback
-### PARSE-007C PDF local advanced tier
+### PARSE-007C PDF local advanced tier(light stack)
命令:
@@ -1602,6 +1644,88 @@ mineru show parse <created_parse_id> --json
- show JSON 中 `tier = advanced`、`privacy = local`、`via = local`
- 不包含 Python traceback
+### PARSE-007A1 PDF local basic tier(full stack)
+
+前置条件:
+
+- 已按 2.2.2 停止 server、设置 `MINERU_MODEL_STACK=full` 并重新启动 server。
+- 已完成 `mineru-kit models download --tier standard --stack full` 和对应 verify。
+
+命令:
+
+```bash
+mineru config set parse_server.local.managed_tier basic
+mineru config set parse_server.local.mode managed
+mineru server status --json
+mineru parse "$MINERU_E2E_FIXTURE_DIR/sample.pdf" --tier basic --pages 1~1 --force --wait 120 --json
+mineru show parse <created_parse_id> --json
+```
+
+执行说明:
+
+- 重复执行 `mineru server status --json`,直到 local parse-server healthy 且 `supported_tiers` 包含 `basic`,再执行 parse。
+- `<created_parse_id>` 从 parse JSON 的 `parse.created_parse_ids[0]` 提取。
+
+预期:
+
+- 五条命令均 exit code = 0
+- parse JSON 和 show JSON 均可直接解析
+- `parse.tier = basic`、`parse.status = done`、`content` 不为 null
+- show JSON 中 `tier = basic`、`privacy = local`、`via = local`
+- 不包含 Python traceback
+
+### PARSE-007B1 PDF local standard tier(full stack)
+
+前置条件: PARSE-007A1 已完成,当前 profile 仍为 `MINERU_MODEL_STACK=full`。
+
+命令:
+
+```bash
+mineru config set parse_server.local.managed_tier standard
+mineru config set parse_server.local.mode managed
+mineru server status --json
+mineru parse "$MINERU_E2E_FIXTURE_DIR/sample.pdf" --tier standard --pages 1~1 --force --wait 180 --json
+mineru show parse <created_parse_id> --json
+```
+
+执行说明:
+
+- 重复执行 `mineru server status --json`,直到 local parse-server healthy 且 `supported_tiers` 包含 `standard`,再执行 parse。
+- `<created_parse_id>` 从 parse JSON 的 `parse.created_parse_ids[0]` 提取。
+
+预期:
+
+- 五条命令均 exit code = 0
+- parse JSON 和 show JSON 均可直接解析
+- `parse.tier = standard`、`parse.status = done`、`content` 不为 null
+- show JSON 中 `tier = standard`、`privacy = local`、`via = local`
+- 不包含 Python traceback
+
+### PARSE-007C1 PDF local advanced tier(full stack)
+
+前置条件: PARSE-007B1 已完成,当前 profile 仍为 `MINERU_MODEL_STACK=full`;Standard managed server healthy 且 `supported_tiers` 包含 `advanced`。
+
+命令:
+
+```bash
+mineru server status --json
+mineru parse "$MINERU_E2E_FIXTURE_DIR/sample.pdf" --tier advanced --pages 1~1 --force --wait 300 --json
+mineru show parse <created_parse_id> --json
+```
+
+执行说明:
+
+- `<created_parse_id>` 从 parse JSON 的 `parse.created_parse_ids[0]` 提取。
+- 本用例完成后必须按 2.2.2 停止 server、恢复 `MINERU_MODEL_STACK=light` 并重新启动 server;等待 light local parse-server healthy 后再继续后续 case。
+
+预期:
+
+- 三条命令均 exit code = 0
+- parse JSON 和 show JSON 均可直接解析
+- `parse.tier = advanced`、`parse.status = done`、`content` 不为 null
+- show JSON 中 `tier = advanced`、`privacy = local`、`via = local`
+- 不包含 Python traceback
+
### PARSE-007D 旧 tier 名称不可用
命令:
@@ -1738,11 +1862,11 @@ mineru show parse <created_parse_id> --json
预期分支:
-- 如果 remote parse-server 暴露 quality tier:
+- 如果 remote parse-server 暴露 `standard` 或 `basic`:
- parse 和 show 均 exit code = 0,stdout 均为可直接解析的 JSON
- - 默认 tier 按 `standard`、`advanced`、`basic` 的顺序选择第一个受 remote 支持的 tier
+ - 默认 tier 按 `standard`、`basic` 的顺序选择第一个受 remote 支持的 tier
- show JSON 中 `privacy = remote`、`via = remote`
-- 如果 remote parse-server 未暴露任何 quality tier:
+- 如果 remote parse-server 未暴露 `standard` 或 `basic`,包括仅暴露 `advanced`:
- exit code != 0
- stdout 为可直接解析的 JSON error
- `error.code = quality_tier_unavailable`
@@ -3709,6 +3833,9 @@ mineru server start
- PARSE-007A PDF local basic tier
- PARSE-007B PDF local standard tier
- PARSE-007C PDF local advanced tier
+- PARSE-007A1 PDF local basic tier(full stack)
+- PARSE-007B1 PDF local standard tier(full stack)
+- PARSE-007C1 PDF local advanced tier(full stack)
- PARSE-007D 旧 tier 名称不可用
- PARSE-008 输出到文件
- PARSE-010 limit 截断与 next_request
@@ -3729,9 +3856,11 @@ mineru server start
执行要求:
- remote 路由必须通过 `show parse --json` 的 `privacy`、`via`、`tier` 验证,不能从 parse JSON 中推断。
-- 显式 quality tier 的 remote 请求在 remote 不可用时允许同 tier local fallback;未指定 tier 且 remote 无 quality tier 时应返回 `quality_tier_unavailable`。
+- 显式 quality tier 的 remote 请求在 remote 不可用时允许同 tier local fallback;未指定 tier 且 remote 无 `standard` 或 `basic` 时应返回 `quality_tier_unavailable`,不得隐式选择 `advanced`。
- remote/local fallback 不得改变 tier,也不得降级到 `flash`。
- PARSE-013A1 是 remote standard 硬性测试;remote 不可用或不支持 standard 均记录为失败,不能静默 fallback 到 local 或其它 tier。
+- PARSE-007A1、PARSE-007B1、PARSE-007C1 是 `full` stack 硬性测试;任何一项不得因 full runtime、模型或硬件不可用标记为 BLOCKED。
+- full profile 完成后必须恢复 `MINERU_MODEL_STACK=light` 并重启 server,避免影响后续 case。
- force/cache/no-wait 用例必须记录 parse id/status 是否符合预期。
### COVERAGE-007 read 边界、续读、image 与 context 补充
diff --git a/mineru/parser/tier.py b/mineru/parser/tier.py
index c59983db..b5fdb743 100644
--- a/mineru/parser/tier.py
+++ b/mineru/parser/tier.py
@@ -44,9 +44,6 @@ _BASIC_REQUIRED_MODULES = [
"torch",
"torchvision",
"transformers",
-]
-_STANDARD_REQUIRED_MODULES_COMMON = [
- *_BASIC_REQUIRED_MODULES,
"accelerate",
]
_STANDARD_REQUIRED_MODULES_BY_PLATFORM = {
@@ -218,10 +215,7 @@ def required_modules_for_tier(tier: DeploymentTier) -> list[str]:
platform_modules = list(_STANDARD_REQUIRED_MODULES_BY_PLATFORM.get(sys.platform, []))
if sys.platform == "darwin" and platform.machine() == "arm64":
platform_modules.extend(_APPLE_SILICON_STANDARD_REQUIRED_MODULES)
- return [
- *_STANDARD_REQUIRED_MODULES_COMMON,
- *platform_modules,
- ]
+ return [*_BASIC_REQUIRED_MODULES, *platform_modules]
def missing_modules_for_tier(tier: DeploymentTier) -> list[str]:
diff --git a/mineru/version.py b/mineru/version.py
index d9abcc92..25f1e49f 100644
--- a/mineru/version.py
+++ b/mineru/version.py
@@ -1 +1 @@
-__version__ = "4.0.0a5"
+__version__ = "4.0.0a6"
diff --git a/pyproject.toml b/pyproject.toml
index 9da25817..d3165d68 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -82,23 +82,22 @@ dev = [
"lxml-stubs",
]
test = [
- "mineru[standard]",
"pytest",
"pytest-cov",
"coverage",
"fuzzywuzzy",
"tomli; python_version < '3.11'",
]
-basic = [
+torch = [
"six>=1.17.0,<2",
"torch>=2.6.0,<3",
"torchvision",
"transformers>=4.57.3,<5.0.0",
+ "accelerate>=1.5.1",
"safetensors>=0.4.0,<1",
]
-standard = [
- "mineru[basic]",
- "accelerate>=1.5.1",
+full = [
+ "mineru[torch]",
"vllm>=0.10.1.1,<0.22.0 ; sys_platform == 'linux'",
"lmdeploy>=0.10.2,<0.12 ; sys_platform == 'win32'",
"qwen-vl-utils>=0.0.14,<1 ; sys_platform == 'win32'",
@@ -110,15 +109,10 @@ gradio = [
"gradio-pdf>=0.0.22",
]
all = [
- "mineru[standard]",
+ "mineru[full]",
"mineru[gradio]",
]
-[tool.uv]
-exclude-dependencies = [
- "datasets",
-]
-
[project.urls]
homepage = "https://mineru.net/"
documentation = "https://opendatalab.github.io/MinerU/"
diff --git a/skills/mineru/SKILL.md b/skills/mineru/SKILL.md
index 4d604851..0e489241 100644
--- a/skills/mineru/SKILL.md
+++ b/skills/mineru/SKILL.md
@@ -113,7 +113,7 @@ mineru read "doc:ab12cd3/tier:standard/page:18" --json
## Installation And Setup
-This skill requires MinerU `>=4.0.0a3`. Before using any workflow, check whether the CLI is installed:
+This skill requires MinerU `>=4.0.0a6`. Before using any workflow, check whether the CLI is installed:
```bash
command -v mineru
@@ -277,12 +277,12 @@ mineru telemetry flush
MinerU has four tiers:
-| Tier | Chinese name | Quality and speed | Local requirements | Local model download | Use for |
-|---|---|---|---|---|---|
-| `flash` | 极速解析 | Lowest quality; fastest | No special hardware | None | Discovery, preview, and indexing; never default final reading quality |
-| `basic` | 基础解析 | Basic quality; moderate speed | At least 16 GB total memory; CPU works, GPU can accelerate | About 2 GB | Private local reading or lower-resource local parsing |
-| `standard` | 标准解析 | Standard high quality; similar speed to `basic` on suitable hardware | At least 16 GB total memory plus a supported accelerator | About 4 GB | Default for normal active reading and complex documents |
-| `advanced` | 高级解析 | Standard quality on ordinary documents and better quality on difficult documents; slowest | Same as Standard, with greater compute use | About 4 GB | Difficult documents and maximum-quality work when the user accepts a longer wait |
+| Tier | Chinese name | Quality and speed | Use for |
+|---|---|---|---|
+| `flash` | 极速解析 | Lowest quality; fastest | Discovery, preview, and indexing; never default final reading quality |
+| `basic` | 基础解析 | Basic quality; moderate speed | Private local reading or lower-resource local parsing |
+| `standard` | 标准解析 | Standard high quality; similar speed to `basic` on suitable hardware | Default for normal active reading and complex documents |
+| `advanced` | 高级解析 | Standard quality on ordinary documents and better quality on difficult documents; slowest | Difficult documents and maximum-quality work when the user accepts a longer wait |
Default tier behavior:
@@ -312,6 +312,48 @@ mineru parse "paper.pdf" --tier advanced
mineru parse "paper.pdf" --tier flash
```
+## Model Stacks
+
+MinerU use neural network models for local `basic`, `standard`, and `advanced` parsing.
+To better support different hardwares, MinerU provide two model stacks: `light` and `full`.
+
+| Stack | Model engines | Install |
+|---|---|---|
+| `light` | ONNX + llama.cpp | Already in `mineru` base module |
+| `full` | PyTorch + vLLM/lmdeploy/mlx | Requires `mineru[full]` extra |
+
+Stack controls resource use and download size:
+
+| Tier | Stack | Model download | RAM (min) | Accelerator |
+|---|---|---|---|---|
+| `basic` | `light` | ~0.8 GB | 4 GB | None (CPU works) |
+| `basic` | `full` | ~2 GB | 16 GB | GPU/MPS recommended |
+| `standard` / `advanced` | `light` | ~2 GB | 8 GB | CPU works, Vulkan recommended |
+| `standard` / `advanced` | `full` | ~4 GB | 16 GB | GPU/MPS required, 8 GB+ VRAM |
+
+The default setting is `auto`: CPU uses `light`, while GPU, MPS, and other accelerators with `mineru[full]` installed use `full`.
+To select a stack explicitly for the current environment, set:
+
+```bash
+export MINERU_MODEL_STACK=light # or full, or auto
+```
+
+To persist the selection, set it in `config.yaml`:
+
+```yaml
+model:
+ stack: light
+```
+
+Stop and restart the MinerU server after changing the stack because running processes do not reload startup configuration.
+
+Download and verify models for a specific stack:
+
+```bash
+mineru-kit models download --tier <tier> --stack <stack>
+mineru-kit models verify --tier <tier> --stack <stack>
+```
+
## Server Rules
Most `mineru` commands use the local MinerU background service. If a command fails with `server_not_running`, start it:
@@ -347,7 +389,7 @@ Agent rules:
Use a local parse server when the user wants `basic`, `standard`, or `advanced` quality without sending the document to remote parsing.
-### Assess Local Hardware
+### Inspect Local Hardware
When no local quality tier is available, inspect the current machine before presenting the recovery choices. `mineru server status --json` shows which tiers are currently configured and available. An empty local `supported_tiers` list may simply mean that the local parse server is disabled or not configured, so inspect the hardware before deciding whether local quality tiers can run.
@@ -358,61 +400,68 @@ Use available read-only system commands to inspect the OS, architecture, total m
- Windows PowerShell: `(Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory`, `Get-CimInstance Win32_Processor`, and `nvidia-smi` when available.
- Other accelerators: use an already-installed vendor tool if available; do not install software merely to inspect hardware.
-Classify each local quality tier as `hardware-supported`, `hardware-unsupported`, or `hardware-unknown`. These labels describe hardware suitability only, not whether the required dependencies and models are installed or the tier is currently available:
-
-- `basic`: `hardware-supported` with at least 16 GB total memory. A CPU is sufficient, but warn that CPU-only parsing may be slow and GPU acceleration can materially reduce parsing time.
-- `standard` and `advanced`: `hardware-supported` with at least 16 GB total memory and either a Volta-or-newer NVIDIA GPU with at least 8 GB available VRAM or Apple Silicon with at least 16 GB unified memory.
-- For `standard` and `advanced`, an `npu`, `gcu`, `musa`, `mlu`, or `sdaa` qualifies as `hardware-supported` only when MinerU compatibility with the exact device and runtime can be verified; otherwise report `hardware-unknown`.
-- Report `hardware-unsupported` when a requirement is clearly not met. If a required property cannot be verified, report `hardware-unknown`.
-
-Before asking the user to choose a tier, summarize the detected hardware and identify each local tier's hardware status. Recommend local `standard` when `hardware-supported`, otherwise local `basic` when `hardware-supported`, otherwise offer remote `standard` when privacy rules allow or explicit `flash`. Mention `advanced` only when the user wants maximum quality and accepts the extra time. Do not install dependencies, download models, change config, or restart services without approval.
+### Choose Local Stack
-### Configure Managed Local Parsing
+The `light` stack is suitable for most hardwares, including CPU-only machines, Apple Silicon, and low-end iGPU/GPU machines.
-Change local parse-server config or restart the server only when the user asks for or approves local high-quality parsing.
+Install and use `full` stack only when you have enough RAM and powerful GPU/accelerator, accept extra installation disk space, and want a higher throughput. Hardware requirements:
+- At least 16 GB total memory.
+- A Volta-or-newer NVIDIA GPU with at least 8 GB available VRAM, or an `npu`, `gcu`, `musa`, `mlu`, or `sdaa` accelerator.
+- Consumes ~5GB more disk space.
-Managed local parsing requires optional runtime dependencies. Install the required extra with the same installation tool and environment that installed the current `mineru` command.
+To use the `full` stack, install the `mineru[full]` extra.
The following examples assume the current install tool is `uv tool`. If `mineru` was installed with another tool or environment, use the equivalent command for that actual tool/environment.
-Installing extras with `uv tool install --force --prerelease allow` can replace the active `mineru` environment. Stop the MinerU server first, confirm `running=false`, and start it again after installing dependencies and models.
-
-Managed local parsing has two startup tiers: `basic` and `standard`. A Standard server provides `basic`, `standard`, and `advanced` request tiers. Advanced uses the same Standard dependencies, model set, and hardware setup; it differs only by spending more inference compute when the request selects `--tier advanced`.
-
-Enable managed local parsing for `basic`:
+Installing extras with `uv tool install --force --prerelease allow` can replace the active `mineru` environment. Stop the MinerU server first, confirm `running=false`, and start it again after installing dependencies.
```bash
mineru server stop
mineru server status --json
-uv tool install --force --prerelease allow "mineru[basic]"
-mineru-kit models download --tier basic
-mineru-kit models verify --tier basic
+uv tool install --force --prerelease allow "mineru[full]"
mineru server start
-mineru config set parse_server.local.managed_tier basic
-mineru config set parse_server.local.mode managed
mineru server status --json
```
-Enable managed local parsing for both `standard` and `advanced` requests:
+### Choose Local Tier
+
+Managed local parsing has two startup tiers: `basic` and `standard`. A Standard server provides `basic`, `standard`, and `advanced` request tiers. Advanced uses the same Standard dependencies, model set, and hardware setup; it differs only by spending more inference compute when the request selects `--tier advanced`.
+
+- `basic` tier with `light` stack, requires at least 4GB total memory.
+- `standard` tier with `light` stack, requires at least 8GB total memory, recommended for GPU/Metal.
+- `basic` tier with `full` stack, recommended for `npu`, `gcu`, `musa`, `mlu`, or `sdaa`.
+- `standard` tier with `full` stack, recommended for high-end nvidia GPU.
+
+### Recommend and Ask
+
+After hardware was inspected, you already know the suitable stack and tier for current machine. Before asking the user to choose a tier/stack, summarize the detected hardware and identify each tier's hardware status.
+
+You should recommend a tier for user when the machine meets such requirements, otherwise offer remote `standard` when privacy rules allow, or use explicit `flash`.
+
+Mention `advanced` only when the user wants maximum quality and accepts the extra time. Do not install dependencies, download models, change config, or restart services without approval.
+
+### Configure Managed Parse Server
+
+First, download the models for the target startup tier (`basic`, or `standard`).
+Replace `<tier>` with `basic` or `standard`.
+
+```bash
+mineru-kit models download --tier <tier> --stack <stack>
+mineru-kit models verify --tier <tier> --stack <stack>
+```
+
+Then, enable managed local parse server for the startup tier.
```bash
-mineru server stop
-mineru server status --json
-uv tool install --force --prerelease allow "mineru[standard]"
-mineru-kit models download --tier standard
-mineru-kit models verify --tier standard
-mineru server start
-mineru config set parse_server.local.managed_tier standard
+mineru config set parse_server.local.managed_tier <tier>
mineru config set parse_server.local.mode managed
mineru server status --json
```
Rules:
-- Determine how the current `mineru` command was installed, then install the extra through that same tool/environment.
-- Stop the MinerU server and confirm `running=false` before replacing its environment, especially on Windows.
+- Change local parse-server config or restart the server only when the user asks for or approves.
- Download and verify models for the startup tier (`basic` or `standard`) before enabling managed mode.
-- Start the MinerU server only after the extra and models are ready.
- Set `parse_server.local.managed_tier` before `parse_server.local.mode=managed`.
- Poll `mineru server status --json` and use managed parsing only after the target tier is healthy.
- If local quality parsing cannot start, do not add `--remote` automatically; ask the user first.