不想寫代碼?一條命令解析 PDF,MinerU CLI 零門檻上手。
MinerU 是什么
MinerU 是上海人工智能實驗室開源的文檔解析工具,可以把 PDF、Word、PPT、圖片轉(zhuǎn)換成 Markdown、JSON 等結(jié)構(gòu)化格式。
最近團隊發(fā)布了 MinerU2.5-Pro(2026年4月),在 OmniDocBench v1.6 基準上拿到了 95.69 分,刷新生態(tài)最好成績。更難得的是,這個成績是在 1.2B 參數(shù)小體量下達成的,參數(shù)量不到同類方案的 1/200,純靠數(shù)據(jù)工程驅(qū)動。
MinerU 的核心能力:
| 能力 | 說明 |
|---|---|
| 版面分析 | 多欄識別、閱讀順序、頁眉頁腳過濾 |
| 文本識別 | 109 種語言 OCR |
| 公式識別 | 復(fù)雜數(shù)學(xué)公式轉(zhuǎn) LaTeX |
| 表格提取 | PDF 表格結(jié)構(gòu)化輸出 |
| 圖片處理 | 圖表、嵌入圖像、內(nèi)容保留 |
沒有 GPU?沒關(guān)系,MinerU 提供云端 API(mineru.net),不用自己部署,直接調(diào)用。本文介紹的 CLI 工具就是接入這個 API 最簡單的方式,一條命令就能跑。
安裝
Windows (PowerShell)
irm https://cdn-mineru.openxlab.org.cn/open-api-cli/install.ps1 | iex
macOS / Linux
curl -fsSL https://cdn-mineru.openxlab.org.cn/open-api-cli/install.sh | sh
驗證安裝:
mineru-open-api version
兩個核心命令:flash-extract vs extract
flash-extract |
extract |
|
|---|---|---|
| 需要 Token | ? 免登錄 | ? 需要 |
| 文件大小 | 最大 10 MB | 最大 200 MB |
| 頁數(shù) | 最大 20 頁 | 最大 600 頁 |
| 輸出格式 | 僅 Markdown | Markdown + HTML + LaTeX + DOCX + JSON |
| 批量 | 單文件 | 支持批量 |
| 適合場景 | 快速預(yù)覽、AI Agent | 正式項目、大文件、存檔 |
flash-extract:免登錄,零配置
# 解析本地 PDF,輸出到終端
mineru-open-api flash-extract report.pdf
# 解析 URL 上的 PDF
mineru-open-api flash-extract https://example.com/paper.pdf
# 保存到文件
mineru-open-api flash-extract report.pdf -o ./output/
# 指定語言和頁碼
mineru-open-api flash-extract report.pdf --language en --pages 1-10
extract:需要 Token,但功能更強
配置 Token
Token 獲取:mineru.net/apiManage/token
# 方式1:命令行傳 token
mineru-open-api extract report.pdf --token 你的token
# 方式2:環(huán)境變量
export MINERU_TOKEN=你的token
mineru-open-api extract report.pdf
# 方式3:保存到配置文件
mineru-open-api auth
extract 基礎(chǔ)用法
# 輸出 Markdown 到終端
mineru-open-api extract report.pdf
# 輸出多種格式
mineru-open-api extract report.pdf -f md,docx,html -o ./results/
# 從 URL 解析
mineru-open-api extract https://example.com/paper.pdf
# 指定模型(vlm 推薦,html 用于網(wǎng)頁)
mineru-open-api extract report.pdf --model vlm
開啟 OCR / 公式 / 表格識別
# 掃描件 PDF 需要開 OCR
mineru-open-api extract scanned-paper.pdf --ocr
# 關(guān)閉公式識別(默認開啟)
mineru-open-api extract report.pdf --formula=false
# 關(guān)閉表格識別(默認開啟)
mineru-open-api extract report.pdf --table=false
crawl:網(wǎng)頁內(nèi)容提取
# 提取單個網(wǎng)頁
mineru-open-api crawl https://mineru.net
# 批量提取多個網(wǎng)頁
mineru-open-api crawl https://mineru.net https://github.com/opendatalab/MinerU -o ./pages/
# 讀取 URL 列表文件
mineru-open-api crawl --list urls.txt -o ./pages/
批量處理
批量文件
# 處理目錄下所有 PDF
mineru-open-api extract ./*.pdf -o ./results/
# 讀取文件列表
mineru-open-api extract --list files.txt -o ./results/
stdin 管道輸入
# 把 PDF 內(nèi)容傳給其他工具
cat report.pdf | mineru-open-api extract --stdin --stdin-name report.pdf | jq .
# 下載并直接解析
curl -L https://example.com/paper.pdf | mineru-open-api extract --stdin --stdin-name paper.pdf
管道傳給 LLM
mineru-open-api extract report.pdf | llm "總結(jié)這份報告的核心觀點"
注意事項
stdout 規(guī)則
不用 -o 時,內(nèi)容輸出到終端(stdout),但有兩條規(guī)則:
- 只能有一個輸入文件
- 只能輸出一種格式
- DOCX 等二進制格式不能輸出到 stdout
批量處理時必須加 -o 指定輸出目錄。
Token 驗證
# 查看當(dāng)前 Token 配置(脫敏顯示)
mineru-open-api auth --show
# 驗證 Token 是否有效
mineru-open-api auth --verify
典型使用場景
快速預(yù)覽 PDF 內(nèi)容
mineru-open-api flash-extract paper.pdf | head -50
把 PDF 轉(zhuǎn)成 Markdown 存檔
mineru-open-api extract archive/*.pdf -f md -o ./markdown-archive/
批量提取論文并傳給 LLM 總結(jié)
for pdf in papers/*.pdf; do
echo "=== $pdf ===" >> summaries.txt
mineru-open-api extract "$pdf" | llm "用三句話總結(jié)" >> summaries.txt
done
抓取網(wǎng)頁內(nèi)容構(gòu)建知識庫
mineru-open-api crawl --list article-urls.txt -o ./content/
相關(guān)鏈接
- CLI 完整文檔:github.com/opendatalab/MinerU-Ecosystem/cli
- Token 申請:mineru.net/apiManage/token