Instructions to use strangelab/ovisocr3-mlx-compact-vision with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use strangelab/ovisocr3-mlx-compact-vision 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("strangelab/ovisocr3-mlx-compact-vision") config = load_config("strangelab/ovisocr3-mlx-compact-vision") # 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 strangelab/ovisocr3-mlx-compact-vision with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "strangelab/ovisocr3-mlx-compact-vision"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "strangelab/ovisocr3-mlx-compact-vision" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent
How to use strangelab/ovisocr3-mlx-compact-vision 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 "strangelab/ovisocr3-mlx-compact-vision"
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 strangelab/ovisocr3-mlx-compact-vision
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use strangelab/ovisocr3-mlx-compact-vision with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "strangelab/ovisocr3-mlx-compact-vision"
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 "strangelab/ovisocr3-mlx-compact-vision" \ --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"
OvisOCR3 with compact vision weights for MLX
This Apple Silicon package stores compatible vision linear weights in 8-bit affine groups. Its model file is 533.8 MB, compared with 625.2 MB for the tested four-bit MLX package. The language tensors are byte-identical with the tested four-bit package. Use it with MLX-VLM on Apple Silicon.
Run two adjacent pages
Install the runtime and download the model into a new directory.
python -m pip install 'mlx-vlm==0.8.1' 'huggingface-hub==2.4.0'
hf download strangelab/ovisocr3-mlx-compact-vision --local-dir ovisocr3
Render two consecutive PDF pages to images. Save the following as merge_pages.py and run python merge_pages.py ovisocr3 page1.png page2.png. It reports the input page numbers and merged HTML. On pages without a table on each side, it returns an empty list. Treat generated HTML as untrusted when rendering it.
import json
from pathlib import Path
import re
import sys
from mlx_vlm import generate, load
from mlx_vlm.prompt_utils import apply_chat_template
from PIL import Image
folder = Path(sys.argv[1])
pages = [Image.open(path).convert("RGB") for path in sys.argv[2:]]
if len(pages) != 2:
raise ValueError("Supply two adjacent page images")
model, processor = load(str(folder))
processor.image_processor.min_pixels = 448 * 448
processor.image_processor.max_pixels = 2880 * 2880
def infer(images, text):
prompt = apply_chat_template(processor, model.config, text,
num_images=len(images), enable_thinking=False)
result = generate(model, processor, prompt, image=images,
max_tokens=16384, temperature=0.)
if result.generation_tokens >= 16384:
raise RuntimeError("The transcription hit its token limit")
return result.text.strip()
markdown_prompt = (folder / "prompts/document_markdown.txt").read_text()
table_prompt = (folder / "prompts/crosspage_table.txt").read_text().strip()
captures = []
for i, page in enumerate(pages, 1):
markdown = infer([page], markdown_prompt)
markdown = re.sub(r"(?<![\w/])(?:page_\d+/)?(images/bbox_\d+_\d+_\d+_\d+\.jpg)",
rf"page_{i}/\1", markdown)
if not re.search(r"<table\b.*?</table\s*>", markdown, flags=re.I | re.S):
print("[]")
sys.exit(0)
captures.append(f'<INPUT_PAGE index="{i}">\n{markdown}\n</INPUT_PAGE>')
answer = infer(pages, table_prompt + "\n\nInput Markdown:\n\n" + "\n\n".join(captures))
print(json.dumps(json.loads(answer), indent=2, ensure_ascii=False))
For a reproducible example, render pages 4 and 5 of the public TenderNed clarification PDF at 150 DPI. The two page fragments belong to one table. Record 7 should contain the continued answer from page 5.
Source and scope
The weights and prompts originate from ATH-MaaS/OvisOCR3. The size baseline is arlenecc/OvisOCR3-0.8B-MLX-4bit. The tests cover two adjacent pages, including tables that continue mid-row and separate tables with similar columns. Review extracted cell ownership and content against the original when it matters.
- Downloads last month
- 18
4-bit