MinerU2 模型部署教程MinerU 是一款将 PDF 转化为机器可读格式的工具(如 markdown、json),可以很方便地抽取为任意格式。
主要功能
通过源码安装MinerU,首先创建虚拟环境,然后安装UV,克隆MinerU的源码,最后UV来安装
conda create -n mineru python=3.12 -y
conda activate mineru
pip install uv -i https://mirrors.aliyun.com/pypi/simple
git clone https://github.com/opendatalab/MinerU.git
cd MinerU
uv pip install -e .[all] -i https://mirrors.aliyun.com/pypi/simple
MinerU默认使用huggingface作为模型源,若用户网络无法访问huggingface,可以通过环境变量便捷地切换模型源为modelscope;
export MINERU_MODEL_SOURCE=modelscope
使用命令下载模型到本地,查看命令使用情况。下载好的模型目录通过 mineru.json 来调用,ineru.json 文件会在您使用内置模型下载命令 mineru-models-download 时自动生成,生成在用户目录,当前使用root用户,生成位置为 /root/mineru.json。
mineru-models-download --help
mineru-models-download
默认模型下载位置,若需要修改模型位置,可以移动模型到其它位置,然后修改 mineru.json文件。

mineru-sglang-server --port 30000 --model-path /root/.cache/modelscope/hub/models/OpenDataLab/MinerU2___0-2505-0___9B --max-running-requests 64 --mem-fraction-static 0.75 --weight-loader-disable-mmap
通过fast api 方式调用。
mineru-api --host 0.0.0.0 --port 8080
通过访问 /docs 可以查看调用方式。
(推荐)使用gradio webui。
mineru-gradio --server-name 0.0.0.0 --server-port 8080
在浏览器中访问 http://127.0.0.1:8080 使用 Gradio WebUI。
访问 http://127.0.0.1:8080/?view=api 使用 Gradio API。
已修改默认使用 sglang环境

通过编辑用户目录下的 mineru.json 文件,添加自定义配置。
latex-delimiter-config:用于配置 LaTeX 公式的分隔符,默认为 $ 符号,可根据需要修改为其他符号或字符串。llm-aided-config:用于配置 LLM 辅助标题分级的相关参数,兼容所有支持 openai协议 的 LLM 模型,默认使用 阿里云百炼 的 qwen2.5-32b-instruct 模型,您需要自行配置 API 密钥并将 enable 设置为 true 来启用此功能。models-dir:用于指定本地模型存储目录,请为 pipeline 和 vlm 后端分别指定模型目录,指定目录后您可通过配置环境变量 export MINERU_MODEL_SOURCE=local 来使用本地模型。点击此处,立即体验MinerU2!
