Pix2Text MFR with cached ONNX decoding

This package reuses decoder attention state when transcribing a cropped formula into LaTeX. It uses the original Pix2Text MFR checkpoint with the 1,200-token vocabulary. The encoder and tokenizer match the original publisher files. The decoder keeps the original FP32 parameters and adds an ONNX cache.

Install in Pix2Text

python -m pip install 'pix2text==1.1.7' 'cnstd==1.2.7.1' 'cnocr==2.3.2.3' \
  'torch==2.7.1' 'torchvision==0.22.1' 'transformers==4.52.3' \
  'optimum==1.27.0' 'onnxruntime==1.32.0' 'huggingface-hub==0.36.0'
hf download strangelab/pix2text-mfr-onnx-cache --local-dir pix2text-mfr-cached
from pix2text.latex_ocr import LatexOCR

ocr = LatexOCR(
    model_dir="pix2text-mfr-cached",
    device="cpu",
    more_model_configs={"provider": "CPUExecutionProvider", "use_cache": True},
)
print(ocr.recognize("formula.png"))

Results

On 32 frozen UniMER-Test crops, the native Pix2Text CPU path kept every LaTeX string. The median warm recognition time fell from 186 ms to 92 ms on an Apple M4 with two ONNX Runtime threads. Both runs hit the same generation cap on one image.

A local OCR Buddy 2.6.1 build with the installed encoder and tokenizer kept all 32 LaTeX strings and abstention decisions in headless Chromium. ONNX Runtime Web WASM time fell from 757 ms to 365 ms at the median. OCR Buddy needs a cache-aware build to use decoder_model_merged.onnx. Browser integrators can download that decoder separately.

The measurements apply to formula crops after model warmup and show agreement with the original checkpoint. UniMER-Test ยท OCR Buddy source

BreezeDeus trained and published the original MIT checkpoint. Strange Lab exported the cached decoder. MIT license

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for strangelab/pix2text-mfr-onnx-cache

Quantized
(3)
this model