OvisOCR2 (MLX bf16, verified)
OvisOCR2(0.9Bのend-to-endドキュメントパースモデル。OmniDocBench v1.6首位)を公式bf16重みからMLX形式に変換したものです。日本語ビジネス文書での検証済みで公開しています。
ページ画像を入力すると、読み順どおりのMarkdown(表はHTML、数式はLaTeX)を出力します。
変換品質の検証(tokimoa)
日本語ビジネス文書5種(議事録・請求書・契約条項・チェックシート・英日混在)で検証:
- transformers版(fp32・greedy)と5/5画像で出力完全一致
- 同一入力の反復で出力完全一致(決定論的)
- 実効速度: 5枚合計 約9.3秒(M4 Max、モデルロード込み)
使い方
# pip install mlx-vlm
from mlx_vlm import load, generate
model, processor = load("tokimoa/ovisocr2-mlx-bf16")
prompt = "Extract all readable content from the image in natural human reading order and output the result as a single Markdown document. For charts or images, represent them using an HTML image tag: <img src=\"images/bbox_{left}_{top}_{right}_{bottom}.jpg\" />, where left, top, right, bottom are bounding box coordinates scaled to [0, 1000). Format formulas as LaTeX. Format tables as HTML: <table>...</table>. Transcribe all other text as standard Markdown. Preserve the original text without translation or paraphrasing."
messages = [{"role":"user","content":[{"type":"image"},{"type":"text","text":prompt}]}]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)
out = generate(model, processor, text, image=["page.png"], max_tokens=4096, temperature=0.0, verbose=False)
print(out.text)
変換情報
- 変換元:
ATH-MaaS/OvisOCR2(bf16、Qwen3.5系 linear+full attentionハイブリッド) - 変換:
mlx-vlm 0.6.7convert(量子化なし・bf16、1.7GB) - 変換者: tokimoa
補足: transformersで元モデルを動かす場合の注意
元リポジトリには generation_config.json が同梱されておらず、config.json の eos_token_id は <|endoftext|> (248044) を指しています。実際のターン終端は <|im_end|> (248046) のため、transformersの generate() にそのまま渡すと停止せず文書を繰り返し生成します。eos_token_id=248046 を明示してください(mlx-vlm・vLLMはtokenizer側のEOSを使うため影響なし)。
ライセンス
Apache-2.0(元モデルに準拠)