File size: 7,681 Bytes
93c9d01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
license: other
license_name: mixed-apache-2.0-oxr-and-ocria
license_link: https://huggingface.co/logxdx/hyperparse-models/blob/main/LICENSE-OXR
tags:
  - document-parsing
  - ocr
  - layout-analysis
  - formula-recognition
  - table-structure
  - onnx
  - tensorrt
---

# hyperparse models

ONNX source models for **hyperparse** (`hp`), a C++/CUDA PDF parser that turns PDFs
into layout, text, formulas and Markdown. The `hp` binaries run TensorRT engines
built from these ONNX files: on first use, hp downloads this repo into the
Hugging Face cache, checks every file against `manifest.json`, and builds the
engines for the local GPU and TensorRT version into its own cache.

## Files

| File | Model | Engine (built by hp) | Used for |
|---|---|---|---|
| `dfine_960_fp16.onnx` | D-FINE layout from OXR-1.0 (`stage2_b2`, 12 classes), FP16 | `dfine_960_fp16.plan` | Layout, 960² letterbox |
| `det_small_fp16.onnx` | PP-OCRv6 small text detection, FP16 | `det_small_fp16.plan` | OCR |
| `rec_small_fp16.onnx` | PP-OCRv6 small text recognition, FP16 | `rec_small_fp16.plan` | OCR |
| `keys_small.txt` | Recognition dictionary | — | OCR |
| `det_tiny_fp16.onnx` | PP-OCRv6 tiny text detection, FP16 | `det_tiny_fp16.plan` | OCR (default detector) |
| `rec_tiny_fp16.onnx` | PP-OCRv6 tiny text recognition, FP16 | `rec_tiny_logits_fp16.plan` | OCR (default recognizer) |
| `keys_tiny.txt` | Recognition dictionary for tiny (6,904 characters) | — | OCR |
| `det_medium_fp16.onnx` | PP-OCRv6 medium text detection, FP16 | `det_medium_fp16.plan` | OCR (`--det-model medium`) |
| `rec_medium_fp16.onnx` | PP-OCRv6 medium text recognition, FP16 (dictionary `keys_small.txt`) | `rec_medium_logits_fp16.plan` | OCR (`--rec-model medium`) |
| `formula/encoder.onnx` | PP-FormulaNet-S encoder, FP32 | `formula/encoder.plan` | Formulas |
| `formula/prep.onnx` | PP-FormulaNet-S decoder prep, FP32 | `formula/prep.plan` | Formulas |
| `formula/step_batched_fp16.onnx` | PP-FormulaNet-S decoder step, FP16 | `formula/step_fp16.plan` | Formulas |
| `formula/tokenizer.json` | Formula tokenizer | — | Formulas |
| `tablenet.onnx` | LayoutNet from OCRia-nano-1 (table structure over text units + page image), FP32 | — (source) | Tables |
| `tablenet_fp16.onnx` | LayoutNet, FP16 (from `tablenet.onnx`, see below) | `tablenet_fp16.plan` | Tables (default) |
| `tablenet_int8.onnx` | LayoutNet, INT8 Q/DQ with FP16 elsewhere | `tablenet_int8.plan` | Tables (`--tables-precision int8`) |
| `order.onnx` | OrderNet from Indra OCR v1.1.0 (reading order, block classes, same-block links over text lines), FP32 | — (source) | Reading order, blocks |
| `order_fp16.onnx` | OrderNet, FP16 (class head FP32) | `order_fp16.plan` | Reading order (default) |
| `order_int8.onnx` | OrderNet, INT8 Q/DQ with FP16 elsewhere | `order_int8.plan` | Reading order (`--order-precision int8`) |
| `doc_ori.onnx` | PP-LCNet_x1_0_doc_ori page orientation (0/90/180/270), FP32 | `doc_ori.plan` | Scans turned upright before OCR |

`manifest.json` lists every file with its size and SHA-256, for download
verification.

The FP32 sources of the tiny and medium OCR models are in
[`logxdx/hyperparse-models-fp32`](https://huggingface.co/logxdx/hyperparse-models-fp32).

## Provenance

- **D-FINE layout:** the layout model inside [SoMark OXR-1.0](https://github.com/SoMarkAI),
  exported to ONNX at a fixed 960² input and converted to FP16. It is the only
  part of OXR that hp uses.
- **PP-OCRv6 small det/rec:** [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)'s text
  detection and recognition models (Apache-2.0). Conversion: PaddlePaddle inference model ->
  ONNX (dynamic batch and width), then FP16 with NVIDIA ModelOpt autocast (all nodes FP16).
- **PP-OCRv6 tiny / medium det/rec:** PaddleOCR's ONNX exports (FP32, in hyperparse-models-fp32),
  converted to FP16 with NVIDIA ModelOpt autocast, inputs and outputs kept FP32. Same scores
  as FP32 on IDL, BHL, OmniParseBench and olmOCR-bench; 1.4-2x faster on TensorRT.
- **PP-FormulaNet-S:** [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)'s formula
  recognition model (Apache-2.0). Conversion: exported to ONNX as three graphs so the
  decoder can run step by step on TensorRT: the image encoder (`encoder.onnx`), the
  cross-attention key/value projection of the encoder output (`prep.onnx`), and one
  batched decoder step of 3 tokens with a fixed 1,056-slot self-attention cache passed in
  and out (`step_batched_fp16.onnx`). The decoder step is FP16 (ModelOpt autocast); the
  encoder and prep stay FP32, where FP16 changed tokens on some formulas.

- **LayoutNet (`tablenet.onnx`):** the table / layout model of LlamaIndex's
  [OCRia-nano-1](https://huggingface.co/llamaindex/OCRia-nano-1), copied unmodified from
  commit `53d45fe6803a568deedb081550c2fdb97cc99f97` (SHA-256 `3b913866…552a95`). hp runs it
  for table structure in D-FINE's Table regions.

- **OrderNet (`order.onnx`):** the reading-order model of [Indra OCR](https://huggingface.co/datalab-to/indra-ocr)
  (tag `v1.1.0`, commit `bd02167f`), copied unmodified. hp runs it over its text lines for
  reading order and block structure.

- **Page orientation (`doc_ori.onnx`):** PaddleOCR's `PP-LCNet_x1_0_doc_ori`, the ONNX export from
  [monkt/paddleocr-onnx](https://huggingface.co/monkt/paddleocr-onnx) (commit `7b02d0a3`,
  `preprocessing/doc-orientation/`), copied unmodified. hp runs it on pages read wholly from pixels
  and turns a page upright when it is at least 0.8 sure of 90/180/270 (picked over Indra OCR's
  orient model and OCRia-nano-1's router vote: 95% exact angle on 2,520 synthetic rotations, 0 of
  614 upright pages turned).

- **Reduced precision (`*_fp16.onnx`, `*_int8.onnx`):** made from the FP32 sources with NVIDIA
  ModelOpt 0.48. FP16: `modelopt.onnx.autocast` (inputs / outputs kept FP32), calibrated on real
  inputs (OmniDocBench and olmOCR-bench pages). INT8: `modelopt.onnx.quantization` (int8, high
  precision FP16), same calibration, lines / units padded to 256 and masked. LayoutNet's two
  attention-mask constants are -3e4 instead of -1e9 first (-1e9 overflows FP16 to NaN; the
  masked softmax weights stay exactly 0). CPU checks against FP32: OrderNet FP16 / INT8 scored
  the same on olmOCR-bench and OmniDocBench reading order; LayoutNet FP16 the same TEDS (0.511),
  INT8 0.498. OrderNet's class head (`/cls/*`) stays FP32 in `order_fp16.onnx`: with it in FP16,
  TensorRT 11.5 fails with a misaligned-address error in a fused kernel.

Engines are built strongly typed (precision comes from the ONNX), with the
optimization profiles in hp's `src/engine_build.cpp`.

## Licences

- `dfine_960_fp16.onnx`: **OXR Open Source License**
  (`LICENSE-OXR`: Apache 2.0 plus additional terms that take precedence).
  In short: free commercial use only below USD 2M total funding and USD 2M annual
  revenue; no hosted service that competes with SoMark's; online services must
  credit "SoMark OXR". Read `LICENSE-OXR` for the binding text.
- `tablenet.onnx`: **OCRia-nano-1 Model License** (`LICENSE-OCRIA`: based on AI Pubs Open
  RAIL-M, with LlamaIndex's modifications), from LlamaIndex, Inc. The model is subject to the
  use-based restrictions in paragraph 5 and Attachment A of that license, which apply to anyone
  receiving it from this repo. In short: free for research, evaluation and personal use, and for
  commercial use only below USD 2M annual revenue and USD 2M total funding; never in a document
  parsing / OCR product that competes with LlamaParse or LlamaCloud. Read `LICENSE-OCRIA` for the
  binding text. Not endorsed by LlamaIndex.
- All other files: **Apache License 2.0** (`LICENSE`), from PaddleOCR.