LightOnOCR-3 document OCR

Run LightOnOCR-3-0.8B and 4B document parsers through Antfly's native inference runtime

LightOnOCR-3 is Antfly's recommended OCR model. The 0.8B and 4B checkpoints are Apache-2.0 document parsers based on Qwen3.5. Each transcribes page images into Markdown, including HTML tables and LaTeX formulas. Antfly uses the integrated safetensors checkpoint with the native Qwen vision and hybrid-attention decoder paths.

Install#

antfly inference pull lightonai/LightOnOCR-3-0.8B:safetensors@36d8636925327c671bd8e479c517a004f7566bd9

The pull installs the upstream configuration, tokenizer, chat template, image processor, and weights, plus a model_manifest.json declaring generation and reading. Refer to the model as lightonai/LightOnOCR-3-0.8B; the short alias lightonocr3-0.8b also resolves.

Downloads made by older Antfly versions may lack chat_template.jinja. With an updated Antfly, rerun the same pull command to fetch the missing sidecar while reusing verified weights. Keep this file when sharing the model directory with other runtimes: a bare image placeholder can produce silently empty pages. Antfly's native reader uses its built-in equivalent of the trained image-only, non-thinking prompt for both model sizes.

The larger model uses the same image-only prompt and /read API:

antfly inference pull lightonai/LightOnOCR-3-4B:safetensors@b71010f095dc3735de7ee6b9969bff8f8f50b39a

Refer to it as lightonai/LightOnOCR-3-4B. The 0.8B model needs about 1.7 GB for weights and the 4B model about 9.1 GB, plus working memory. Both run on CPU, Metal, and CUDA.

Read a page#

Send a rendered PDF page or other document image to the inference service:

curl http://localhost:8080/ai/v1/read \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "lightonai/LightOnOCR-3-0.8B",
    "images": [{"url": "data:image/png;base64,..."}],
    "max_tokens": 1024
  }'

Omit prompt or pass an empty string for transcription. This model is trained with an image-only prompt; a generic instruction such as Transcribe this page is rejected by /read. The alternative "prompt": "grounding" returns the model's native labeled bounding-box markers, descriptions, and chart tables in the result's text. These markers use coordinates normalized to 0–1000; they are not converted into pixel-coordinate regions.

On Metal, and on CUDA with the LightOn batch profile, /read batches pages from the same request and from concurrent requests on the GPU.

When max_tokens is omitted, both LightOnOCR-3 models default to 4096 output tokens per page. HTTP and embedded reading use the same model-specific budget, bounded by resources.inference.request_limits.max_output_tokens_per_item.

Set max_tokens explicitly to override the default, up to the /read ceiling of 8192 and the selected model's and deployment's limits. Explicit values above those limits are rejected rather than silently clamped. Truncated output is still rejected. Use this endpoint for repeated page extraction so the reader can reuse its prepared execution state.

For example, a dense page can request "max_tokens": 8192. The deployment must also allow the output ceiling and provide enough memory for the request. The larger budget increases its estimated work; work-unit accounting saturates at resources.inference.admission.max_work_units, so a large request can occupy the full configured capacity without bypassing competing requests. Concurrency, memory, image, and input-token limits remain enforced.

The Go docsaf/reading/antfly adapter omits max_tokens by default, including when falling back between models. Set AntflyConfig.DefaultMaxTokens for an adapter default, or reading.ReadOptions.MaxTokens for a per-call override. Positive per-call values take precedence over the adapter default.

For document ingestion, the same manual control is available as ocr.reader.max_tokens alongside the reader provider and model.

Other OCR models retain their own prompt and output-budget rules: Qwen3-VL uses its reader profile; encoder-decoder readers use their decoder metadata; Moondream retains its caption budget; detection/recognition pipelines have no generative output-token default.

Read documents during ingestion#

To OCR scanned PDF pages and images as they are indexed, name the model as the ocr.reader of a document_extraction enrichment:

{
  "type": "document_extraction",
  "config": {
    "ocr": {
      "reader": {"provider": "antfly", "model": "lightonai/LightOnOCR-3-0.8B"}
    }
  }
}

Index PDFs and Scanned Documents walks through the full table setup.

For dense pages, explicitly raise the per-page output budget:

{
  "type": "document_extraction",
  "config": {
    "ocr": {
      "reader": {
        "provider": "antfly",
        "model": "lightonai/LightOnOCR-3-0.8B",
        "max_tokens": 8192
      }
    }
  }
}

The default remains 4096. A page warning containing ReadOutputTruncated means the model reached its output budget before completing the page. Increase ocr.reader.max_tokens within model and deployment limits, then reprocess the artifact. If it already uses 8192, inspect the generated output for repetition before raising other limits; additional memory cannot increase the /read output ceiling. Incomplete OCR text is rejected.

Memory admission failures have two different remedies. ResourceLimitExceeded means the page cannot fit its configured budget even when admitted alone. The LightOn warning identifies the blocking budget, required bytes, and limit bytes, with the applicable inference-server and standalone flags. ResourceTemporarilyUnavailable means capacity is currently occupied or live memory pressure prevents admission; the reader waits with backoff, bounded by the request control and a 30-second stall timeout. Wide CUDA cohorts extend the stall timeout only when cohort steps advance. The model manager emits at most one admission denial diagnostic batch per second; denied_count includes suppressed attempts.

Image size#

The runtime takes its pixel limits from the installed image processor, capped at 4096 merged vision tokens per image. Resize pages before submitting them when optimizing latency; LightOn's own speed evaluation uses a 1540-pixel long side.

For PDF ingestion, ocr.render.max_dimension and ocr.render.max_pixels can bound rendering memory. A 2048-pixel cap can help large pages fit, but can also remove small print, handwriting strokes, and table detail. Compare transcription quality before adopting it for a corpus. Larger memory budgets likewise need headroom for concurrent requests and other server work.

Execution details, GPU tuning switches, and measured throughput are in the LightOnOCR-3 runtime notes. Published quality numbers are in LightOn's evaluation.