Instructions to use AnandSingh/LightOnOCR-3-4B-bf16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use AnandSingh/LightOnOCR-3-4B-bf16 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("AnandSingh/LightOnOCR-3-4B-bf16") config = load_config("AnandSingh/LightOnOCR-3-4B-bf16") # 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 AnandSingh/LightOnOCR-3-4B-bf16 with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "AnandSingh/LightOnOCR-3-4B-bf16"
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": "AnandSingh/LightOnOCR-3-4B-bf16" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent
How to use AnandSingh/LightOnOCR-3-4B-bf16 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 "AnandSingh/LightOnOCR-3-4B-bf16"
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 AnandSingh/LightOnOCR-3-4B-bf16
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use AnandSingh/LightOnOCR-3-4B-bf16 with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "AnandSingh/LightOnOCR-3-4B-bf16"
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 "AnandSingh/LightOnOCR-3-4B-bf16" \ --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"
LightOnOCR-3-4B โ MLX (Apple Silicon)
BF16 weights of lightonai/LightOnOCR-3-4B
converted to MLX for native inference on
Apple Silicon via mlx-vlm (โฅ 0.6.5).
LightOnOCR-3-4B is a Qwen3.5-based vision-language OCR model: it transcribes
documents, tables, receipts, forms, charts and math to Markdown, and in
grounding mode returns labeled bounding boxes for every block, short
descriptions of images, and the underlying data of charts as HTML tables.
Install
pip install -U "mlx-vlm>=0.6.5"
The architecture is the stock qwen3_5 multimodal model already shipped in
mlx-vlm, so this is a pure weight conversion โ no patches required.
Usage
Transcription (default / "plain")
mlx_vlm.generate \
--model AnandSingh/LightOnOCR-3-4B-bf16 \
--image ./tests/images/receipt.jpeg \
--prompt "" \
--max-tokens 2048 --temperature 0.2 --top-p 0.9
Grounding (labels + bounding boxes)
mlx_vlm.generate \
--model AnandSingh/LightOnOCR-3-4B-bf16 \
--image page.png \
--prompt "grounding" \
--max-tokens 4096 --temperature 0.2 --top-p 0.9
Python
from mlx_vlm import load, generate
from mlx_vlm.prompt_utils import apply_chat_template
model, processor = load("AnandSingh/LightOnOCR-3-4B-bf16")
prompt = apply_chat_template(processor, model.config, "grounding", num_images=1)
result = generate(model, processor, prompt, image=["page.png"],
max_tokens=4096, temperature=0.2, top_p=0.9)
print(result.text)
A lighter, faster build lives at
AnandSingh/LightOnOCR-3-4B-4bit
(3 GB, ~37 tok/s on M4) โ recommended for most use. This BF16 build is the
full-precision reference (9.1 GB, ~11 tok/s), validated for numerical parity
against the original PyTorch checkpoint.
See run_ocr.py in the LightOnOCR-3 conversion repo for a runnable plain/grounding wrapper.
Prompt modes
| Mode | Prompt | Output |
|---|---|---|
| Transcription | "" (empty) |
All page text as Markdown |
| Grounding | "grounding" |
Each block prefixed with  (0โ1000 page coords) |
Other instructions are out of distribution โ use the empty prompt or grounding.
Thinking is disabled by default (the model was trained/evaluated that way), which
apply_chat_template sets automatically via enable_thinking=False.
Preprocessing tips
- Render PDFs at 400 DPI, then resize the longest edge to 2048 px (aspect ratio preserved). The bundled image processor (Qwen3-VL smart-resize) handles patch/merge sizing internally.
Provenance
Converted with mlx_vlm.convert from the original BF16 transformers
checkpoint. Weight keys were remapped by mlx-vlm's qwen3_5 sanitizer
(model.language_model.* โ language_model, model.visual.* โ vision_tower),
Conv1d axis flip, 5-D patch-embed transpose, and the +1.0 RMSNorm offset.
Validated for numerical parity against the PyTorch reference (see repo README).
- Source: https://huggingface.co/lightonai/LightOnOCR-3-4B
- License: Apache-2.0
- Downloads last month
- 202
Quantized
Model tree for AnandSingh/LightOnOCR-3-4B-bf16
Base model
lightonai/LightOnOCR-3-4B