Image-Text-to-Text
MLX
Safetensors
Japanese
English
qwen3_5
ocr
document-parsing
markdown
japanese
conversational
4-bit precision
Instructions to use tokimoa/ovisocr2-mlx-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use tokimoa/ovisocr2-mlx-4bit with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("tokimoa/ovisocr2-mlx-4bit") config = load_config("tokimoa/ovisocr2-mlx-4bit") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use tokimoa/ovisocr2-mlx-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "tokimoa/ovisocr2-mlx-4bit"
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "tokimoa/ovisocr2-mlx-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use tokimoa/ovisocr2-mlx-4bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "tokimoa/ovisocr2-mlx-4bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default tokimoa/ovisocr2-mlx-4bit
Run Hermes
hermes
- OpenClaw new
How to use tokimoa/ovisocr2-mlx-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "tokimoa/ovisocr2-mlx-4bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "tokimoa/ovisocr2-mlx-4bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
OvisOCR2 (MLX 4bit, verified)
OvisOCR2(0.9Bのend-to-endドキュメントパースモデル。OmniDocBench v1.6首位)を公式bf16重みからMLX 4bit(group size 64、実効5.86bpw)に量子化したものです。日本語ビジネス文書での検証済みで公開しています。
ページ画像を入力すると、読み順どおりのMarkdown(表はHTML、数式はLaTeX)を出力します。
変換品質の検証(tokimoa)
日本語ビジネス文書5種(議事録・請求書・契約条項・チェックシート・英日混在)で検証:
- transformers版(fp32・greedy)と3/5画像で出力完全一致。差分は2画像×各1文字で、いずれも小書き文字の通常かな化(セキ「ュ」リティ→セキ「ユ」リティ、テ「ィ」ング→テ「イ」ング)
- この劣化は決定論的(同一入力では毎回同じ箇所が同じように化ける)。日本語OCRで小書き文字の忠実度が重要な場合は 8bit版 を推奨
- 同一入力の反復で出力完全一致(決定論的)
- 実効速度: 5枚合計 約7.4秒(M4 Max、モデルロード込み)
使い方
# pip install mlx-vlm
from mlx_vlm import load, generate
model, processor = load("tokimoa/ovisocr2-mlx-4bit")
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-q --q-bits 4(実効5.86bpw、622MB) - 変換者: 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(元モデルに準拠)
- Downloads last month
- 27
Model size
0.2B params
Tensor type
BF16
·
U32 ·
Hardware compatibility
Log In to add your hardware
4-bit