lightonai/LightOnOCR-3-4B by LightOn, converted to ONNX for superPDF, where it powers
high-accuracy reading in the command-line tool and MCP server (--model 4b, model: "4b"). It runs with Transformers.js on ONNX Runtime (WebGPU), in the browser and in Node.
Conversion
- Base weights:
lightonai/LightOnOCR-3-4B at revision b71010f095dc3735de7ee6b9969bff8f8f50b39a (safetensors, bfloat16).
- Graphs:
onnx-community/Qwen3.5-4B-ONNX-OPT at revision 2e351a8a534116289140e31f351c5e9790cae2db (LightOnOCR-3 uses the Qwen3.5 architecture; the configurations match apart
from the unused multi-token-prediction layer). Every weight in those graphs is recomputed from LightOn's weights and
written at the same place, so the graphs themselves are unchanged.
- Quantisation: decoder and token embeddings 4-bit (ONNX Runtime
MatMulNBits / GatherBlockQuantized, block size 32,
asymmetric with zero points, computed with ONNX Runtime's own quantize_matmul_4bits); vision encoder float16.
Norm weights are stored as 1 + w and the gated delta net's A as -exp(A_log), as the builder expects.
- Converter: scripts/models/convert-lightonocr.py in the superPDF repository (to be published with the open-source release).
- Converted by superPDF with the converter below.
config.json is LightOn's with the transformers.js_config block of the onnx-community repository; tokenizer and
processor files are the onnx-community ones (same Qwen3.5 vocabulary).
Use
Transcription with boxes (LightOn's grounding prompt), greedy decoding, pages rendered with their longest side at
1540 to 2048 pixels:
import { AutoProcessor, Qwen3_5ForConditionalGeneration, RawImage } from '@huggingface/transformers';
const id = 'superpdf/LightOnOCR-3-4B-ONNX';
const processor = await AutoProcessor.from_pretrained(id);
const model = await Qwen3_5ForConditionalGeneration.from_pretrained(id, { device: 'webgpu', dtype: { embed_tokens: 'q4', decoder_model_merged: 'q4', vision_encoder: 'fp16' } });
const prompt = processor.apply_chat_template([{ role: 'user', content: [{ type: 'image' }, { type: 'text', text: 'grounding' }] }], { add_generation_prompt: true, enable_thinking: false });
const inputs = await processor(prompt, await RawImage.read('page.png'));
const output = await model.generate({ ...inputs, max_new_tokens: 6144, do_sample: false });
Files and SHA-256
| File |
Bytes |
SHA-256 |
chat_template.jinja |
7756 |
a4aee8afcf2e0711942cf848899be66016f8d14a889ff9ede07bca099c28f715 |
config.json |
3317 |
9573132702b2289ca6ea4615faae0ede96f70f19e7f9064c50acfd1768954dca |
generation_config.json |
204 |
8ce51af0baac298c116b7db144efe1ebd78b0b792d084002634fd3ed63f4d515 |
onnx/decoder_model_merged_q4.onnx |
771821 |
327c73159341412221e3a38425fdeaa100efbf95901b976f2f3e52eaede929f0 |
onnx/decoder_model_merged_q4.onnx_data |
2097044992 |
b38f3bb43eea40c4151c6e31de26bbe96e6828991db834172c3b7b28ce0ea3dc |
onnx/decoder_model_merged_q4.onnx_data_1 |
600476160 |
181e556427080e7c1257d9c0ecd70142d42a4c0121e176fdb421f75f8dd8be54 |
onnx/embed_tokens_q4.onnx |
857 |
b72feb6947db92d643f70abc6a4d3e5398a9535470a97685e3b1ab3b05047146 |
onnx/embed_tokens_q4.onnx_data |
407244800 |
56bd464ce04b3975f83af6f664f140c94862f00bc6f3cbb8a02b173fc45f6ade |
onnx/vision_encoder_fp16.onnx |
345836 |
fb2e2684c8c5914299a100fba847831a11911d8c0458079c27f5ab26142a2f55 |
onnx/vision_encoder_fp16.onnx_data |
671943680 |
b3235ddcd3dfef9b4c1b9a9276840f2da247ed26b0ddedea100114d30957fed0 |
preprocessor_config.json |
336 |
6a970fd06f30e6943b3e2c14d5d3b42d49b06cf99b99103d56689bef462d90f8 |
processor_config.json |
1300 |
14932921ca485d458a04dafd8069fbb0a4505622a48208d19ed247115801385b |
tokenizer.json |
19226111 |
89da80cc6689bef4d90cc1028249436975ffb0814618f1d93c65310e05801a9b |
tokenizer_config.json |
10061 |
5d35dd3e7792dcbc1082a2f4eeb10731d78b5c7824c004c230af860b1d44e214 |
Also in SHA256SUMS (check with shasum -a 256 -c SHA256SUMS).
Licence
Apache License 2.0, as the original model. See LICENSE and NOTICE. Scores and model details: see LightOn's
model card for lightonai/LightOnOCR-3-4B.