Problem
目前 macdoc ocr 一次只能處理單一 input 檔案,要批次處理多個 PDF/PNG 時必須在外層用 xargs -P 或 shell background job 才能並行。但 Ollama 本身(v0.2+)預設支援 OLLAMA_NUM_PARALLEL=4 的併發請求,使用者沒有簡單的方法把這個能力用起來。
Use Case
實測情境:77 個轉學考 PDF(共數百頁)送遠端 Ollama(SSH tunnel 到 Kyle M4 Max 跑 glm-ocr)。序列版本跑了 2+ 小時、因 SSH tunnel 中斷還失敗 30 個;要手寫 xargs -P 4 包裝才能真正並行。
Type
feature
Expected
```bash
方式 A:多個輸入
macdoc ocr page-1.png page-2.png page-3.png --output-dir out/ --parallel 4
方式 B:目錄/glob
macdoc ocr "dir/*.png" --output-dir out/ --parallel 4
方式 C:PDF 多頁內部並行
macdoc ocr file.pdf --output file.md --parallel 4
```
需求:
- `--parallel N` (default 1) 控制並發數
- 支援多個 input 或 glob pattern
- `--output-dir` 輸出到目錄,檔名沿用 input basename
- 內部維持連線池或重用 URLSession 避免每次重建
- 遇到個別失敗不要整批中斷,最後彙整回報成功/失敗
- 每頁/每檔的進度回報到 stderr
Actual
```
USAGE: macdoc ocr [--output ] [--pages ] [--backend ] [--model ] [--host ] [--max-tokens ]
```
只接受單一 input,無並行選項。
Impact
- 批次 OCR 效能:序列 vs 4 路並行可達 ~2.4x(實測單頁 22s → 4 頁 37s)
- 使用者不用每個專案都手刻 xargs + tunnel 重連 wrapper
- 降低整體 wall-clock,對遠端 GPU 資源利用率也更高
Related
psychquant-claude-plugins 會同步新增 skill 章節(並行 pattern、Ollama 設定)
- 考慮另外做
batch-ocr plugin 處理更上層的編排(tunnel 管理、PDF→PNG→合併 pipeline)
Current Status
Phase: diagnosed
Last updated: 2026-04-22 by idd-diagnose (batch)
Problem
目前
macdoc ocr一次只能處理單一 input 檔案,要批次處理多個 PDF/PNG 時必須在外層用xargs -P或 shell background job 才能並行。但 Ollama 本身(v0.2+)預設支援OLLAMA_NUM_PARALLEL=4的併發請求,使用者沒有簡單的方法把這個能力用起來。Use Case
實測情境:77 個轉學考 PDF(共數百頁)送遠端 Ollama(SSH tunnel 到 Kyle M4 Max 跑 glm-ocr)。序列版本跑了 2+ 小時、因 SSH tunnel 中斷還失敗 30 個;要手寫 xargs -P 4 包裝才能真正並行。
Type
feature
Expected
```bash
方式 A:多個輸入
macdoc ocr page-1.png page-2.png page-3.png --output-dir out/ --parallel 4
方式 B:目錄/glob
macdoc ocr "dir/*.png" --output-dir out/ --parallel 4
方式 C:PDF 多頁內部並行
macdoc ocr file.pdf --output file.md --parallel 4
```
需求:
Actual
```
USAGE: macdoc ocr [--output ] [--pages ] [--backend ] [--model ] [--host ] [--max-tokens ]
```
只接受單一 input,無並行選項。
Impact
Related
psychquant-claude-plugins會同步新增 skill 章節(並行 pattern、Ollama 設定)batch-ocrplugin 處理更上層的編排(tunnel 管理、PDF→PNG→合併 pipeline)Current Status
Phase: diagnosed
Last updated: 2026-04-22 by idd-diagnose (batch)