Instructions to use sahilchachra/LightOnOCR-3-4B-MXFP8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use sahilchachra/LightOnOCR-3-4B-MXFP8 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("sahilchachra/LightOnOCR-3-4B-MXFP8") config = load_config("sahilchachra/LightOnOCR-3-4B-MXFP8") # 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 sahilchachra/LightOnOCR-3-4B-MXFP8 with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "sahilchachra/LightOnOCR-3-4B-MXFP8"
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": "sahilchachra/LightOnOCR-3-4B-MXFP8" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent
How to use sahilchachra/LightOnOCR-3-4B-MXFP8 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 "sahilchachra/LightOnOCR-3-4B-MXFP8"
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 sahilchachra/LightOnOCR-3-4B-MXFP8
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use sahilchachra/LightOnOCR-3-4B-MXFP8 with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "sahilchachra/LightOnOCR-3-4B-MXFP8"
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 "sahilchachra/LightOnOCR-3-4B-MXFP8" \ --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 MXFP8
MLX MXFP8 quantization of lightonai/LightOnOCR-3-4B, LightOn's
OCR / document-understanding vision-language model. It's a standard qwen3_5
VL model (hybrid GatedDeltaNet linear-attention + full-attention text backbone, 32
layers, full attention every 4th, hidden 2560; Qwen3-VL-style vision tower, depth
24, hidden 1024) — the same architecture family already supported natively by
mlx-vlm 0.6.12, so no custom patch was needed for this one (unlike some other
qwen3_5-labeled checkpoints with custom attention). Runs on Apple Silicon via
mlx-vlm. Stays image-text-to-text — the
vision tower is kept in bf16; only the text backbone is quantized.
| Precision | MXFP8 (E4M3 + E8M0 shared scale, group size 32) |
| Bits per weight | 8.821 bpw |
| On-disk size | 4.7 GB (1 shard) |
| Quantized | text backbone (32 layers, hidden 2560; embeddings tied, no separate lm_head) |
| Kept in bf16 | vision tower (Qwen3-VL-style ViT, depth 24, hidden 1024) |
Quantizations
| Variant | Bits | Size | |
|---|---|---|---|
LightOnOCR-3-4B-MXFP4 |
5.116 bpw | 2.7 GB | smaller / fastest |
LightOnOCR-3-4B-MXFP8 |
8.821 bpw | 4.7 GB | ← this repo |
Verification
Tested with deterministic greedy decoding via native mlx-vlm, comparing
against the unquantized bf16 reference:
- Text coherence: both quantized builds answer correctly — "What is the capital of France?" → "Paris" (MXFP4) / "The capital of France is Paris." (MXFP8); "What is 25 + 17?" → "42" on both.
- Vision smoke test (solid-color and shape images, bf16 vision tower through the quantized text backbone): both builds correctly identify color ("red", "blue") and shape+color ("green circle").
- Real OCR task (synthetic invoice image: "Invoice #A-9921", "Total Due: $482.50", "Due Date: 2026-11-01", "Bill To: Sahil Chachra") — bf16, MXFP4, and MXFP8 all produce byte-identical, fully correct output, reading all four lines with no hallucination or omission.
- LM Studio (tested via
lms load+ the OpenAI-compatible chat completions API onlocalhost:1234): both builds load cleanly (qwen3_5architecture recognized,format: mlxpresent) and reproduce the same correct OCR output through the API as the native mlx-vlm test.
Usage (mlx-vlm)
pip install -U mlx-vlm # needs the qwen3_5 architecture (>= 0.6.12)
from mlx_vlm import load, generate
from mlx_vlm.prompt_utils import apply_chat_template
model, processor = load("sahilchachra/LightOnOCR-3-4B-MXFP8")
config = model.config
prompt = apply_chat_template(processor, config, "Read all the text in this image.", num_images=1)
print(generate(model, processor, prompt, image=["invoice.png"], max_tokens=300, verbose=True))
Run in LM Studio
Loads and runs out of the box — the qwen3_5 architecture is recognized natively
by LM Studio's bundled MLX runtime (tested on 0.4.20). Works through both the UI
and the OpenAI-compatible /v1/chat/completions API with image inputs
(image_url with a base64 data URL). No patch file or extra setup required.
Notes & limitations
tie_word_embeddings=true— no separatelm_headtensor; embeddings are quantized once and reused for the output projection.- Inherits all capabilities and limitations of the base model, including its OCR specialization — it is tuned for document/table/form understanding rather than general chit-chat. See the original model card.
- Quantized by @sahilchachra with MLX. Apache-2.0.
- Downloads last month
- -
8-bit
Model tree for sahilchachra/LightOnOCR-3-4B-MXFP8
Base model
lightonai/LightOnOCR-3-4B