PDFluent Formula Recognition (ONNX): Math Formula to LaTeX for PDF to Markdown

Convert cropped images of PDF display math formulas into LaTeX with this ONNX model. For developers building PDF-to-Markdown and RAG pipelines, it plugs into the PDFluent SDK. PDFluent 1.3.0 ranks above every engine on the published opendataloader-bench leaderboard (as of 3 November 2026)*. Formulas output as $$...$$ blocks in your Markdown.

*Overall score 0.9168 (quality="auto", keep_furniture=True, Linux) against the engines listed in the benchmark README on 3 November 2026; submitted as pull request #37 (https://github.com/opendataloader-project/opendataloader-bench/pull/37). Other engines have submissions open that are not yet on the leaderboard.

Use it in two lines

pip install pdfluent
pdfluent models install formula
import pdfluent; print(pdfluent.open("paper.pdf").extract_markdown(formula_model=True))  # display formulas appear as $$...$$

The formula model is off by default. The command above installs it and the flag switches it on.

Inspect the ONNX files without the SDK

With plain onnxruntime, to load the three files and inspect the interface:

import json
import onnxruntime as ort

encoder = ort.InferenceSession("encoder.onnx")
decoder = ort.InferenceSession("decoder.onnx")
vocab = json.load(open("vocab.json"))["tokens"]

for name, sess in (("encoder", encoder), ("decoder", decoder)):
    print(name, [(i.name, i.shape, i.type) for i in sess.get_inputs()])
    print(name, [(o.name, o.shape, o.type) for o in sess.get_outputs()])

Image preprocessing and the decoding loop are implemented in the SDK. If you drive the model yourself, decode greedily from <bos> (id 1) until <eos> (id 2) and map ids back to LaTeX tokens with vocab.json.

What you get

  • ONNX files (encoder.onnx, decoder.onnx, vocab.json) for local inference
  • LaTeX output in $$...$$ for Markdown compatibility
  • Direct integration into PDFluent SDK parsing workflows
  • Training provenance file listing all arXiv source papers
  • Licence choice: AGPL-3.0-only or PDFluent Commercial Licence

Inputs and outputs

The model takes a greyscale image of a formula and its width as input. It outputs token ids mapped to LaTeX via the vocabulary. In the PDFluent SDK 1.3.0, enable it with pdfluent models install formula and formula_model=True in extract_markdown. The SDK wraps the LaTeX in $$ ... $$ in the Markdown output.

Graph Name Type Shape
encoder in image float32 1 x 1 x 64 x 768
encoder in width int64 1
encoder out memory float32 1 x 96 x 256
encoder out mask bool 1 x 96
decoder in tokens int64 1 x 202
decoder in memory, mask from encoder as above
decoder out logits float32 1 x 202 x 587

Training data and provenance

Training data comes from arXiv papers under CC BY 4.0 and CC0 1.0, excluding CC BY-SA. Formulas were cropped from aligned ground truth, re-rendered with open fonts, and degraded to resemble scans. All training papers are listed with their licence, title, authors and source URL in PROVENANCE.md, which also serves as the CC BY attribution list. Held-out evaluation papers were not used for training.

Provenance: PROVENANCE.md. Digests of the three weight files are in SHA256SUMS; the files are byte-identical to the formula package in the models-v1 release of the SDK.

Limitations

  • Off by default in the SDK.
  • Most formulas are not reproduced exactly.
  • Errors are likely on unfamiliar notation, unusual fonts and poor scans.
  • Display formulas only, no inline formulas.
  • Input must be a tight crop of one formula; layout detection is handled by the SDK.

Licence in plain words

Model weights are AGPL-3.0-only or available under the PDFluent Commercial Licence. AGPL works for open-source projects. Closed-source products or those avoiding AGPL obligations need the commercial licence. Details at https://pdfluent.com/license.

Try PDFluent

Run pip install pdfluent, install the formula model and watch display formulas in your own papers come out as LaTeX. See the SDK at github.com/pdfluent/pdfluent-sdk and docs at pdfluent.com/docs.

Citation

@misc{pdfluent_formula_recognition_onnx_2026,
  author       = {{Innovation Trigger B.V.}},
  title        = {PDFluent formula recognition (ONNX): formula-own-v1},
  year         = {2026},
  publisher    = {Hugging Face},
  url          = {https://huggingface.co/PDFluent/formula-recognition-onnx},
  note         = {PDFluent, https://pdfluent.com}
}

Links

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Collection including PDFluent/formula-recognition-onnx