yolowpdf is a pure-Rust PDF-to-Markdown library that parses the format itself — no Poppler, no MuPDF. Version 0.2.0, released this week, is a consolidated release with two halves: the PDF core learned to reconstruct two-dimensional mathematics from glyph geometry, and the OCR side open-sourced its model suite. This post covers both, with the measured numbers.
The problem: text survives PDF extraction, math does not
A PDF does not store formulas. It stores glyphs at coordinates: a numerator here, a drawn line under it, a denominator below. A text extractor reading in stream order produces linear soup — the fraction loses which part was on top, a matrix flattens into a column of numbers, the limits of a summation detach and wander into the prose. For a human reader of the rendered page this is invisible. For an LLM pipeline ingesting papers, the math is precisely the part that matters, and it is the part that arrives broken.
The scores showed it plainly. On the born-digital benchmark suite (olmOCR's 1,269-page set), the math-heavy arXiv subset scored 0.0881 with the previous release — the extractor was effectively not reading those pages at all.
What the core does now: fold the geometry back into structure
0.2.0 adds a reconstruction pass that runs on glyph geometry before line splitting, folding drawn structure bottom-up:
- Rules first. Horizontal rules are classified — table lines and booktabs rules are excluded — and the rest are tried, shortest first, as radical bars, fraction bars, or overlines. Fraction geometry follows the invariants of Appendix G of the TeXbook: numerator and denominator bands relative to the math axis, single-layer isolation so a stacked fraction does not swallow the next line, and prose guards so a table rule with text under it is never promoted to a fraction. Inner structures fold first and are re-inserted as single composite glyphs, so nesting — a fraction inside a radical inside a fraction — composes for free.
- Big operators. Summations, integrals, and products get their limits collected from the bands above and below (to the side, for integrals), with guards that keep ordinary prose subscripts from being captured.
- Matrices and cases. Delimiter glyphs — including the stacked CMEX pieces TeX builds tall brackets from — are assembled into delimiter bars, paired inside-out, and the enclosed glyphs are split into rows and columns, emitting
pmatrix/bmatrix/vmatrix/cases— and\binomwhen a parenthesized two-by-one stack is really a binomial coefficient. - Drawn-as-image rules. Ghostscript/dvips-era files draw fraction bars as 1×1 image masks stretched by the transform matrix. Those are now recovered as rules at content-stream time and fed into the same machinery.
- Segmentation. A two-state Viterbi pass separates inline math from prose within a line, so reconstructed expressions re-enter the text flow in the right places.
Measured on the same born-digital set, same machine: mean score 0.5915 → 0.6950, passed tests 3,484 → 5,170, and the arXiv math subset 0.0881 → 0.6505. Speed went up at the same time — 1,269 pages in 0.562 s (2,256 pages/s, p50 3.4 ms/page), because the release also carries the parsing work: a flat direct-indexed object table, zero-copy lexing and filter paths, reused inflate state, and prefix-only decoding where only a stream's head is needed. Layout gained recursive X-Y-cut column detection for mixed two/three-column pages, and a round of TeX font-decoding fixes (mathabx, CM family) landed with it.
The OCR half: the model suite is now open source
For scanned pages, yolowpdf-ocr ships YolowOCR-Suite v2 — five models trained from scratch (detection, multilingual recognition, Latin recognition, layout, formula), published on Hugging Face under MIT as BF16 safetensors: 109.59 MB for the full multilingual suite, 8.14× smaller than the 892 MB FP32 upstream reference stack it stays format-compatible with (PP-OCRv6 / PP-DocLayoutV3 / PP-FormulaNet_plus-L). Pinned revisions and SHA-256 digests are registered in the crate itself, so the models you run are the models that were measured.
Two pieces of engineering came with the models:
- A rectangular formula encoder. Formulas are wide, not square. The encoder now takes rectangular inputs (224×672) with decomposed relative attention, keeping twice the horizontal resolution of the square pipeline instead of squashing a fraction into a thumbnail.
- Lossless MTP-4 speculative decoding. Four parallel prediction heads draft future tokens from the decoder's hidden state; one batched forward pass verifies them, and a mismatch truncates the KV cache and rolls back — so the output is bit-for-bit identical to plain greedy decoding, at ~3.1–3.5 ms/token on CPU. Speculation that cannot change the result, only the cost.
On the scanned suite (134 pages, full layout + formula stack): score 0.4799, 2.40× faster than the v1 stack, peak memory 938 MB — 58% less than v1's 2,225 MB.
Use it like this
fn main() -> Result<(), Box<dyn std::error::Error>> { let bytes = std::fs::read("document.pdf")?; let doc = yolowpdf::extract(&bytes)?; println!("{}", doc.markdown); Ok(()) } [dependencies] yolowpdf = "0.2" yolowpdf-ocr = "0.2" # optional, for scanned pages Use yolowpdf when you ingest documents — papers especially — into an LLM or RAG pipeline and the formulas are content, not decoration; or when you need the whole stack, models included, self-hosted and offline. If your PDFs are plain prose and any extractor's output looks fine, this is more machinery than you need.

