Views
No views yet
datalab-to/surya-ocr-2 at source commit 3b3d4cdf88d6928b0acdc75181b13206ea67c4a3.| File | Purpose | Precision / quantization | Shape contract |
|---|---|---|---|
surya_vision_fp16.mlpackage | Vision tower | CoreML FP16 compute | pixel_values [1024,1536] -> image_embeds [256,1024] |
surya_vision_int8.mlpackage | Quantized vision tower | CoreML linear INT8 weight compression | pixel_values [1024,1536] -> image_embeds [256,1024] |
surya_prefill_fp16_seq300_cache512.mlpackage | Language prefill, logits, and initial cache | CoreML FP16 compute | fixed prefill length 300, cache length 512 |
surya_decode_step_fp16_cache512.mlpackage | One-token cached decode step | CoreML FP16 compute | one token at a time, cache length 512 |
processor/. Native constants and embedding assets are under native_assets/. Validation JSONs are under validation/.native/SuryaCoreMLRuntime.1import SuryaCoreMLRuntime
2
3let runtime = try SuryaCoreMLRuntime(modelDirectory: modelDirectoryURL)
4let result = try runtime.generate(image: cgImage, maxNewTokens: 128, useInt8Vision: true)
5print(result.text ?? "")OCR this image to HTML.
1Invoice 123
2Total $42.00| Gate | Result |
|---|---|
| Prefill parity before CoreML export | native/custom first token 1039; logits max diff 2.6702880859375e-05 |
| Prefill CoreML smoke | Torch/CoreML first token 1039; logits max diff 0.3057253360748291; mean diff 0.03853870555758476 |
| Decode CoreML iterative smoke | 9/9 tokens match native; text <p>Invoice |
| CoreML prefill -> CoreML decode | 9/9 tokens match native; text <p>Invoice |
| CoreML FP16 vision -> CoreML prefill -> CoreML decode | 9/9 tokens match native; text <p>Invoice |
| CoreML INT8 vision -> CoreML prefill -> CoreML decode | 9/9 tokens match native; text <p>Invoice |
| Native Swift image -> CoreML INT8 vision -> CoreML prefill -> CoreML decode | 9/9 tokens match native; text <p>Invoice |
0.021211756393313408 vs the PyTorch vision tower on the canary.CGImage or already-preprocessed pixel_valuesscripts/export_surya_coreml_runtime.py shows the Python reference glue used for validation. The included native/SuryaCoreMLRuntime package is the native implementation.1pip install coremltools torch transformers pillow qwen-vl-utils huggingface_hub
2python scripts/export_surya_coreml_runtime.py vision-combined-runtime-smoke \
3 --model-id datalab-to/surya-ocr-2 \
4 --vision-package surya_vision_int8.mlpackage \
5 --prefill-package surya_prefill_fp16_seq300_cache512.mlpackage \
6 --decode-package surya_decode_step_fp16_cache512.mlpackage \
7 --output validation/local_vision_int8_prefill_decode_smoke.json \
8 --max-cache-length 512 \
9 --steps 81{
2 "all_tokens_match": true,
3 "coreml_text": "<p>Invoice ",
4 "native_text": "<p>Invoice "
5}1cd native/SuryaCoreMLRuntime
2swift run surya-coreml-smoke \
3 --model-dir ../.. \
4 --image /path/to/512x512-document.png \
5 --max-tokens 8 \
6 --vision int811039 2009 2046 2054 2047 2041 2035 2037 1979
2<p>Invoice pixel_values [1024,1536], prefill length 300, and full-attention cache length 512.allenai/olmOCR-bench.datalab-to/surya-ocr-2. No fine-tuning was performed.