Skip to content

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

feat: update CLI documentation and environment variables for mineru and mineru-router

myhloli208b2c7c0c42
diff --git a/docs/en/usage/cli_tools.md b/docs/en/usage/cli_tools.md
index 545d944c..351657ac 100644
--- a/docs/en/usage/cli_tools.md
+++ b/docs/en/usage/cli_tools.md
@@ -23,6 +23,9 @@ Options:
-t, --table BOOLEAN Enable table parsing (default: enabled)
--help Show help information
```
+> [!TIP]
+> `mineru` currently supports local `PDF`, image, and `DOCX` file or directory inputs.
+
```bash
mineru-api --help
Usage: mineru-api [OPTIONS]
@@ -50,12 +53,28 @@ Options:
from PDF to Markdown.
--server-name TEXT Set the server name for the Gradio app.
--server-port INTEGER Set the server port for the Gradio app.
+ --api-url TEXT MinerU FastAPI base URL. If omitted, gradio
+ starts a reusable local mineru-api service.
--latex-delimiters-type [a|b|all]
Set the type of LaTeX delimiters to use in
Markdown rendering: 'a' for type '$', 'b' for
type '()[]', 'all' for both types.
--help Show this message and exit.
```
+```bash
+mineru-router --help
+Usage: mineru-router [OPTIONS]
+
+Options:
+ --host TEXT Server host (default: 127.0.0.1)
+ --port INTEGER Server port (default: 8002)
+ --reload Enable auto-reload (development mode)
+ --upstream-url TEXT Existing MinerU FastAPI base URL; repeat to add more
+ --local-gpus TEXT Local GPU workers to launch: auto, none, or CSV such
+ as 0,1,2
+ --worker-host TEXT Host for router-managed workers (default: 127.0.0.1)
+ --help Show this message and exit.
+```
## Environment Variables Description
@@ -99,6 +118,30 @@ Here are the environment variables and their descriptions:
* Default is `4`; you can set a different value via an environment variable to adjust the number of threads for image rendering.
* Only effective on Linux and macOS systems.
+- `MINERU_PROCESSING_WINDOW_SIZE`:
+ * Used to control the processing window size, which affects memory use and throughput on large-document workloads.
+ * Default is `64`; set it to another positive integer when needed.
+
+- `MINERU_API_MAX_CONCURRENT_REQUESTS`:
+ * Used to control the maximum concurrent requests handled by `mineru-api` or router-managed workers.
+ * Default is `3`, and it must be a positive integer.
+
+- `MINERU_API_ENABLE_FASTAPI_DOCS`:
+ * Used to control whether FastAPI documentation endpoints such as `/docs`, `/openapi.json`, and `/redoc` are enabled.
+ * Default is `true`.
+
+- `MINERU_API_OUTPUT_ROOT`:
+ * Used to configure the root output directory for `mineru-api`.
+ * Default is `./output` under the current working directory.
+
+- `MINERU_API_TASK_RETENTION_SECONDS`:
+ * Used to set how long completed or failed tasks are retained, in seconds.
+ * Default is `86400` seconds (24 hours).
+
+- `MINERU_API_TASK_CLEANUP_INTERVAL_SECONDS`:
+ * Used to set the cleanup polling interval for expired tasks, in seconds.
+ * Default is `300` seconds (5 minutes).
+
- `MINERU_INTRA_OP_NUM_THREADS`:
* Used to set the intra_op thread count for ONNX models, affects the computation speed of individual operators
* Default is `-1` (auto-select), can be set to other values via environment variable to adjust the thread count.
@@ -113,9 +156,9 @@ Here are the environment variables and their descriptions:
* Single Client VRAM Size | MINERU_HYBRID_BATCH_RATIO
------------------------|--------------------------
<= 6 GB | 8
- <= 4.5 GB | 4
+ <= 4 GB | 4
<= 3 GB | 2
- <= 2.5 GB | 1
+ <= 2 GB | 1
- `MINERU_HYBRID_FORCE_PIPELINE_ENABLE`:
* Used to force the text extraction part in `hybrid-*` backends to be processed using small models.
diff --git a/docs/zh/usage/cli_tools.md b/docs/zh/usage/cli_tools.md
index be8e6af6..2d478cbf 100644
--- a/docs/zh/usage/cli_tools.md
+++ b/docs/zh/usage/cli_tools.md
@@ -23,6 +23,9 @@ Options:
-t, --table BOOLEAN 是否启用表格解析(默认开启)
--help 显示帮助信息
```
+> [!TIP]
+> `mineru` 当前支持本地 `PDF`、图片与 `DOCX` 文件或目录输入。
+
```bash
mineru-api --help
Usage: mineru-api [OPTIONS]
@@ -45,12 +48,27 @@ Options:
--max-convert-pages INTEGER 设置从 PDF 转换为 Markdown 的最大页数
--server-name TEXT 设置 Gradio 应用程序的服务器主机名
--server-port INTEGER 设置 Gradio 应用程序的服务器端口
+ --api-url TEXT MinerU FastAPI 服务地址;不传时自动拉起可复用的本地
+ mineru-api
--latex-delimiters-type [a|b|all]
设置在 Markdown 渲染中使用的 LaTeX 分隔符类型
('a' 表示 '$' 类型,'b' 表示 '()[]' 类型,
'all' 表示两种类型都使用)
--help 显示此帮助信息并退出
```
+```bash
+mineru-router --help
+Usage: mineru-router [OPTIONS]
+
+Options:
+ --host TEXT 路由服务主机地址(默认:127.0.0.1)
+ --port INTEGER 路由服务端口(默认:8002)
+ --reload 启用自动重载(开发模式)
+ --upstream-url TEXT 现有 MinerU FastAPI 服务地址;可重复传入多个
+ --local-gpus TEXT 本地 GPU worker 配置:auto、none 或 0,1,2 形式
+ --worker-host TEXT 路由托管 worker 的监听地址(默认:127.0.0.1)
+ --help 显示此帮助信息并退出
+```
## 环境变量说明
@@ -94,6 +112,30 @@ MinerU命令行工具的某些参数存在相同功能的环境变量配置,
* 默认为`4`,可通过环境变量设置为其他值以调整渲染图片时的线程数。
* 仅在linux和macOS系统中生效。
+- `MINERU_PROCESSING_WINDOW_SIZE`:
+ * 用于设置单次处理窗口大小,影响大文档处理时的内存占用和吞吐表现
+ * 默认为`64`,可通过环境变量设置为其他正整数。
+
+- `MINERU_API_MAX_CONCURRENT_REQUESTS`:
+ * 用于设置 `mineru-api` 或 `mineru-router` 管理的 worker 最大并发请求数
+ * 默认为`3`,需设置为正整数。
+
+- `MINERU_API_ENABLE_FASTAPI_DOCS`:
+ * 用于控制是否启用 FastAPI 自动生成的 `/docs`、`/openapi.json`、`/redoc`
+ * 默认为`true`。
+
+- `MINERU_API_OUTPUT_ROOT`:
+ * 用于指定 `mineru-api` 输出目录根路径
+ * 默认为当前工作目录下的 `./output`。
+
+- `MINERU_API_TASK_RETENTION_SECONDS`:
+ * 用于设置任务完成或失败后的保留时长(秒)
+ * 默认为 `86400` 秒(24 小时)。
+
+- `MINERU_API_TASK_CLEANUP_INTERVAL_SECONDS`:
+ * 用于设置任务清理轮询间隔(秒)
+ * 默认为 `300` 秒(5 分钟)。
+
- `MINERU_INTRA_OP_NUM_THREADS`:
* 用于设置onnx模型的intra_op线程数,影响单个算子的计算速度
* 默认为`-1`(自动选择),可通过环境变量设置为其他值以调整线程数。
@@ -108,9 +150,9 @@ MinerU命令行工具的某些参数存在相同功能的环境变量配置,
* 单个client端显存大小 | MINERU_HYBRID_BATCH_RATIO
------------------|------------------------
<= 6 GB | 8
- <= 4.5 GB | 4
+ <= 4 GB | 4
<= 3 GB | 2
- <= 2.5 GB | 1
+ <= 2 GB | 1
- `MINERU_HYBRID_FORCE_PIPELINE_ENABLE`:
* 用于强制将 hybrid-* 后端中的 文本提取部分使用 小模型 进行处理
diff --git a/mineru/backend/hybrid/hybrid_analyze.py b/mineru/backend/hybrid/hybrid_analyze.py
index ba6ea9f6..90327c23 100644
--- a/mineru/backend/hybrid/hybrid_analyze.py
+++ b/mineru/backend/hybrid/hybrid_analyze.py
@@ -478,7 +478,7 @@ def get_batch_ratio(device):
------------------|------------------------
<= 6 GB | 8
<= 4 GB | 4
- <= 2.5 GB | 2
+ <= 3 GB | 2
<= 2 GB | 1
例如:
export MINERU_HYBRID_BATCH_RATIO=4