OCRia-1 / README.md
suryatmodulus's picture ajimeno's picture
Duplicate from llamaindex/OCRia-1
400c03b
|
Raw History Blame Contribute Delete
35 kB
---
library_name: transformers
pipeline_tag: image-text-to-text
base_model: Qwen/Qwen3.5-4B
license: other
license_name: ocria-1-license
license_link: LICENSE
language:
- en
tags:
- ocr
- pdf
- markdown
- document-parsing
- tables
- charts
- parsebench
---
<p align="center">
<img src="assets/llamaindex-logo.png" alt="LlamaIndex" width="96"/>
</p>
<h1 align="center">OCRia-1</h1>
<p align="center">
<a href="https://arxiv.org/abs/2611.00092">Technical report</a> ·
<a href="https://www.llamaindex.ai/blog/parse-ocria-1">Blog post</a> ·
<a href="https://www.llamaindex.ai/blog/the-inference-stack-behind-ocria">Inference blog</a> ·
<a href="https://cloud.llamaindex.ai">LlamaParse</a> ·
<a href="https://github.com/run-llama/ParseBench">ParseBench</a> ·
<a href="https://ollama.com/llamaindex/ocria-1">Ollama</a> ·
<a href="https://huggingface.co/llamaindex/OCRia-1-GGUF">GGUF</a>
</p>
OCRia-1 is a 4B vision-language model for document parsing from [LlamaIndex](https://www.llamaindex.ai). It reads a page
image and writes the page as Markdown, with tables in HTML, and it is built for the content that document parsers get
wrong most often: merged cells and spanning headers, tables with thousands of cells, charts whose data has to be read
off the plot, and formatting that carries meaning, such as strikethrough, underline, sub- and superscripts and
checkboxes.
- **Accuracy:** the highest-scoring open-weight model on both [ParseBench](https://parsebench.ai) leaderboards, with
visual grounding included: 85.2 on ParseBench 2 (six dimensions, seventh of 61 systems) and 84.7 on ParseBench 1
(five dimensions, second of 158). It is also first on olmOCR-bench tables and formulas, PulseBench-Tab and
fr-bench-pdf2md. See [Benchmarks](#benchmarks).
- **Tables:** nested headers, merged cells as `colspan` / `rowspan`, irregular grids and long financial tables.
- **Charts:** every chart becomes an HTML table of its data points, with each value under the right series and label
(82.5 on ParseBench 1 charts, against 69.1 for the next-best open-weight model).
- **Formatting and math:** bold, italic, ~~strikethrough~~, `<u>underline</u>`, `<mark>` highlights, `<sub>` /
`<sup>`, `[ ]` / `[x]` checkboxes, `[___]` blank fields, and formulas in LaTeX, including handwritten ones.
- **Page structure:** headers, footers, page numbers and watermarks in their own tags, multi-column text unrolled,
diagrams as Mermaid.
- **One call per page:** the text comes from the page image alone, with no layout detector, OCR engine or text layer.
[Layout boxes](#layout-boxes-experimental) are added afterwards.
> [!NOTE]
> This repository holds the **unoptimized BF16 weights**. The OCRia-1 that serves
> [LlamaParse](https://cloud.llamaindex.ai) is the same model, quantized and served with a speculative decoder and
> custom kernels, which makes it about ten times faster. See [Speed](#speed) and
> [The Inference Stack Behind OCRia](https://www.llamaindex.ai/blog/the-inference-stack-behind-ocria).
OCRia-1 runs inside [LlamaParse](https://cloud.llamaindex.ai), which also handles multi-page documents.
<p align="center">
<img src="assets/ocria1_radar.png" alt="OCRia-1 against leading document-parsing VLMs" width="760"/>
</p>
## Examples
Pages from ParseBench, rendered at 150 DPI and transcribed with greedy decoding. The right-hand image renders what the
model wrote, without editing.
| | Page | OCRia-1 output |
|---|:---:|:---:|
| **Dense financial table:** a Texas insurance rate filing with a three-level header; the header spans become `colspan` and the section rows stay in place. | <img src="assets/table_texas_page.jpg" width="300"/> | <img src="assets/table_texas_output.png" width="300"/> |
| **Chart as data:** a line chart with three series over five years becomes a table of its 15 data points, matching the printed labels. | <img src="assets/chart_line_page.jpg" width="300"/> | <img src="assets/chart_line_output.png" width="300"/> |
| **Formatting:** a hearing notice with struck-through withdrawn cases, underlined case names and bold times; all three are kept. | <img src="assets/format_hearing_page.jpg" width="300"/> | <img src="assets/format_hearing_output.png" width="300"/> |
| **Handwritten formulas:** a handwritten note in Czech; the text is transcribed and each formula written as LaTeX. | <img src="assets/handwritten_math_page.jpg" width="300"/> | <img src="assets/handwritten_math_output.png" width="300"/> |
More examples, including cash-flow statements, bank statements, timetables and economic charts, are in the
[blog post](https://www.llamaindex.ai/blog/parse-ocria-1).
## Quickstart
To run OCRia-1 on your own machine with llama.cpp or Ollama (Linux, Windows, macOS), use the GGUF builds in
[llamaindex/OCRia-1-GGUF](https://huggingface.co/llamaindex/OCRia-1-GGUF); the Q8_0 build scores the same as these
weights on a ParseBench 2 sample. On a GPU server:
Serve with vLLM 0.30 or later. vLLM compiles kernels for this architecture at start-up and needs the CUDA toolkit
(`nvcc`); the `vllm/vllm-openai` Docker image has it.
```bash
vllm serve llamaindex/OCRia-1 --served-model-name ocria-1 --max-model-len 32768 \
--limit-mm-per-prompt '{"image": 1}'
```
Send each page as one image, with [`prompt.txt`](prompt.txt) as the system message, no user text, and **thinking off**.
The Qwen3.5 chat template turns thinking on by default, and with it on the model answers in the wrong format.
```python
import base64
from huggingface_hub import hf_hub_download
from openai import OpenAI
prompt = open(hf_hub_download("llamaindex/OCRia-1", "prompt.txt")).read()
page = base64.b64encode(open("page.png", "rb").read()).decode()
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
resp = client.chat.completions.create(
model="ocria-1",
messages=[
{"role": "system", "content": prompt},
{"role": "user", "content": [{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{page}"}}]},
],
temperature=0.0,
max_tokens=24576,
extra_body={"chat_template_kwargs": {"enable_thinking": False}},
)
print(resp.choices[0].message.content)
```
### Offline with vLLM
```python
from vllm import LLM, SamplingParams
llm = LLM("llamaindex/OCRia-1", max_model_len=32768, limit_mm_per_prompt={"image": 1})
messages = [
{"role": "system", "content": prompt},
{"role": "user", "content": [{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{page}"}}]},
]
out = llm.chat(messages, SamplingParams(temperature=0.0, max_tokens=24576),
chat_template_kwargs={"enable_thinking": False})
print(out[0].outputs[0].text)
```
### With Hugging Face Transformers
```python
import torch
from PIL import Image
from transformers import AutoModelForImageTextToText, AutoProcessor
model = AutoModelForImageTextToText.from_pretrained("llamaindex/OCRia-1", dtype=torch.bfloat16, device_map="auto").eval()
processor = AutoProcessor.from_pretrained("llamaindex/OCRia-1")
messages = [
{"role": "system", "content": [{"type": "text", "text": prompt}]},
{"role": "user", "content": [{"type": "image", "image": Image.open("page.png").convert("RGB")}]},
]
inputs = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=True, return_dict=True,
return_tensors="pt", enable_thinking=False).to(model.device)
ids = model.generate(**inputs, max_new_tokens=24576, do_sample=False)
print(processor.decode(ids[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
```
Needs `pip install transformers accelerate torchvision` (Transformers 5.3 or later). Use it to try the model; use vLLM
for throughput.
### Input
- **One page per request.** Render PDF pages at 300 DPI, for example with `pymupdf`: `page.get_pixmap(dpi=300)`.
- **Image size.** The benchmark numbers below use an image budget of about 4.1 megapixels, about 210 DPI for a letter
page. To match them, downscale larger renders:
```python
from PIL import Image
img = Image.open("page.png")
scale = min(1.0, (4_100_000 / (img.width * img.height)) ** 0.5)
img = img.resize((round(img.width * scale), round(img.height * scale)), Image.LANCZOS)
```
Larger images also work and cost more image tokens; the model was trained on pages of about 1,024 px.
- **No PDF text.** The model reads only the image.
### Output
Markdown inside a ```` ```markdown ```` fence. Strip the fence:
```python
import re
m = re.search(r"```markdown\n(.*?)(?:\n```|$)", text, re.S)
markdown = m.group(1) if m else text
```
| Content | How OCRia-1 writes it |
|---|---|
| Tables, and charts as data | HTML `<table>`, with `colspan` / `rowspan` |
| Diagrams and flowcharts | a ```` ```mermaid ```` block |
| Formulas | `$...$` inline, `$$...$$` display |
| Chemical formulas | plain text with `<sub>` / `<sup>`, e.g. `K<sub>3</sub>Fe(CN)<sub>6</sub>` |
| Checkboxes and blank fields | `[ ]`, `[x]`, `[___]` |
| Images | `![label: description]`, with `label` one of logo, icon, photo, illustration, screenshot, map, signature, seal, code, drawing, image |
| Page furniture | `<page_header>`, `<page_footer>`, `<page_number>` (inside the header or footer), `<watermark>` |
Decode greedily (`temperature=0`) with `max_tokens` 24,576: dense pages can need more than 20,000 output tokens.
### The prompt
The model was trained and evaluated with this system prompt, which is also in [`prompt.txt`](prompt.txt). Use it
unchanged; other prompts change the output format.
<details>
<summary>Show the prompt</summary>
````text
Transcribe this Page in markdown, be as accurate as possible in your transcription, do not describe/summarize.
Formatting:
- Use ** for bold text and * for italic text.
- Use ~~ text ~~ for strikethrough text. Only use this for text that is visually stricken through.
- Use <mark> and </mark> tags for highlighted text, aka text to wich a stabilo hilight was applied Only use to hilight sentence or words, not full block of text/tables. Use HTML color names for different colors of highlight, e.g. <mark style="background-color: blue">text</mark>. Do not use mark for first cell of a table, as it is often used for the header and should not be highlighted.
- Use <u> and </u> tags for underlined text.
- Use \* for bullet points and - for sub-bullets.
- Use > for blockquotes.
- Use ` for inline code.
- Use ``` for code blocks.
- Use [ ] for empty checkboxes.
- Use [x] for checked checkboxes.
- Use <sub> and </sub> for subscript text.
- Use <sup> and </sup> for superscript text.
- Use [___] for empty fields to fill, if the field is already filled, represent them as field content in markdown.
- Use $...$ for inline equations and $$...$$ for display equations. Do NOT use \(...\) or \[...\] — the corpus uses dollar delimiters (43,604 inline occurrences against 35 in the parenthesis form).
- Chemical formulas are NOT LaTeX: write them as plain text with <sub> and <sup>, e.g. K<sub>3</sub>Fe(CN)<sub>6</sub> and 2H<sub>2</sub>O, never $K_3Fe(CN)_6$. Reserve $...$ for real mathematics.
Tables:
- Output tables in HTML when possible.
- Table should not be use for page formatting (column or grid like layout), but only for tabular data.
- Some table may be irregular, with merged cells, missing cells, or inconsistent formatting, or have an exotic structure (like a triangular table). Do your best to represent the table accurately with correct reading order.
Charts, Graphs, and Figures:
- IMPORTANT: Every chart or graph MUST be converted into an HTML <table>. This is non-negotiable. The table represent the chart data, not the chart layout. Focus on accurately capturing the underlying data and relationships in the table format.
- FORBIDDEN outputs for charts: <iframe>, <embed>, <canvas>, <img>, <object>, links, URLs, or plain-text descriptions. Using any of these for a chart is an automatic FAIL.
- MERMAID FALLBACK: For diagrams, figures and flowcharts that are better represented as a graph than as a table (architecture diagrams, flowcharts, org charts, entity relationships), use Mermaid syntax INSTEAD of an HTML table and output it between ```mermaid and ``` tags. This exception applies ONLY to diagrams; a chart or graph plotting data values is still an HTML <table>.
Images:
- Transcribe any text printed inside the image as markdown.
- Reference the image itself as ![label: description], where label is exactly one of: logo, icon, photo, illustration, screenshot, map, signature, seal, code, drawing, image. Use the caption or wording the page itself prints for the description; do not invent one, and do not describe an image the page says nothing about.
Page furniture:
- Output the page header (if any) between <page_header> and </page_header> tags.
- Output the page footer (if any) between <page_footer> and </page_footer> tags.
- Output the printed page number (if any) between <page_number> and </page_number> tags, nested inside the header or footer band it sits in.
Watermarks:
- Output a watermark stamped across the page (DRAFT, OBSOLETE, CONFIDENTIAL) between <watermark> and </watermark> tags, not as body text.
Multi-column Text:
- Unroll multi-column text into a single column format.
Completeness:
- Ensure ALL content from the page is transcribed without omissions.
- As this is a transcription task, fidelity is of upmost importance. You should NEVER truncate or shorten tabular data. Any instance of table data that looks like "[...table data continues in rows n - m ...]" or omits rows or columns will result in an automatic FAIL.
Accuracy:
- Maintain text and formatting as close to the original as possible within the constraints of Markdown syntax.
Handwriting / Cursive Text:
- If the page contains handwriting or cursive text, ignore the OCR output for those sections and rely solely on the screenshot to transcribe that content.
Output result between ```markdown and ```
````
</details>
## Layout boxes (experimental)
OCRia-1 writes no layout boxes. The [`ocria_grounding/`](ocria_grounding) package adds them after generation:
1. A layout detector finds the page's regions. It is Docling's Heron
([docling-project/docling-layout-heron](https://huggingface.co/docling-project/docling-layout-heron), Apache-2.0),
downloaded from its own repository on first use.
2. Every word of OCRia-1's answer gets a position. On a PDF page with a text layer, that is the word's exact box in the
PDF. Otherwise a second pass of the same weights over the page and the answer shows where the model looked while
writing each word, and that spot is snapped to the ink on the page.
3. Each region becomes one item holding the answer's words that fall inside it: a heading, a paragraph, a table, a
picture, a page header or footer.
The text can come from any server, vLLM included. The boxes need Transformers and a GPU.
### Run it
```bash
pip install "transformers==5.22.2" accelerate torchvision timm scipy pypdfium2 huggingface_hub
huggingface-cli download llamaindex/OCRia-1 --local-dir OCRia-1
python OCRia-1/examples/boxes.py doc.pdf --page 0 # PDF page: exact word positions from its text layer
python OCRia-1/examples/boxes.py page.png # image: word positions from the model's attention
```
The script writes the transcription and the items to `<name>.boxes.json` and draws them on `<name>.boxes.png`.
Pass `--attention-only` to skip the layout detector.
Or call the package from your own code:
```python
import sys
from huggingface_hub import snapshot_download
sys.path.insert(0, snapshot_download("llamaindex/OCRia-1", allow_patterns=["ocria_grounding/*", "prompt.txt"]))
from ocria_grounding import load, load_detector, transcribe, ground_layout, render_pdf_page
g = load() # OCRia-1 with Transformers, on CUDA
det = load_detector() # Heron, on CUDA (else MPS, else CPU)
image, words = render_pdf_page("doc.pdf", 0) # the page at 300 DPI and its text-layer words
answer = transcribe(g, image) # or the raw answer for this image from vLLM or any other server
page = ground_layout(g, image, answer, detector=det, words=words)
for it in page["items"]:
print(it["type"], it["box"], it["md"][:60])
```
For an image instead of a PDF, pass `image = Image.open("page.png").convert("RGB")` and `words=None`.
To add boxes to text served elsewhere (for example vLLM on another machine), run the box server next to a GPU:
`python OCRia-1/examples/serve_boxes.py --port 8100`. `POST /ground` takes the page image (base64 PNG), the raw
answer and the page's text-layer words (`ocria_grounding.pdf.page_words`, or `null` for images) and returns the same
`items` as `ground_layout`. The [ParseBench](https://github.com/run-llama/ParseBench) `ocria_1` pipeline uses it.
`page["items"]` lists the items in reading order. Each has a `type` (`Text`, `Section-header`, `Table`, `Picture`,
`Page-header`, ...), its markdown `md`, and `box` as `[x0, y0, x1, y1]` in pixels of `image`.
`to_layout_items_page(page, scale=72 / 300)` converts the result to a ParseBench layout page in PDF points. Here are
some of the items for the table page from [Examples](#examples), which is an image, and the boxes the example script
draws on it:
```text
Text [85, 231, 377, 268] **<u>Texas Department of Insurance</u>** ...
Key-Value Region [458, 209, 1156, 310] Claims Made ...
Text [85, 331, 784, 348] Exhibit E – Expense Information – Including Di
Table [81, 410, 1155, 1109] <table><tr><th colspan="8">UNDERWRITING EXPENS
Text [447, 1431, 789, 1448] Attach additional Exhibit E pages as needed.
Page-footer [85, 1492, 243, 1527] TDI form NO. PC 367 | Edition 05/2007
```
<p align="center"><img src="assets/boxes_table_texas.jpg" alt="Layout boxes drawn on the table page" width="560"/></p>
- **Use a PDF when you have one.** `render_pdf_page` renders the page as PDF viewers show it (CropBox and rotation
applied) and maps every text-layer word into that image, so each word lands exactly. On images, word positions come
from attention and are rougher: short labels in dense forms, like the header block above, can be split across
regions.
- **Use the same inputs.** Pass the exact image and raw answer from generation. A resized image, an edited answer or
another prompt moves the attention, and the boxes with it.
- **Cost per page,** on top of generation: one extra forward pass over the image and the answer, the detector (about
40 ms on a GPU, about 0.2 s on a laptop CPU), and about 1 s of CPU to place the words. On one A10G the boxes took 2
to 7 s per page. Generation with Transformers takes much longer, so for speed transcribe with vLLM and use
`ground_layout` only for the boxes.
- **Requirements:** the `pip install` line above. The package hooks into Transformers' attention interface, so other
Transformers versions may break it.
- **Without a detector** (`detector=None`, or the older `ground_page`), the boxes come from attention alone: one box
per paragraph, heading, list item, table, image reference and header/footer band, and much less accurate.
- **Known weak spots:**
- the items follow the detector's idea of a block, so a bold lead-in or a list can be split from its paragraph;
- text the PDF stores as images, and pages without a text layer, fall back to attention positions;
- pictures the detector scores low are dropped.
### Fast layout (experimental)
`fast-layout` is an optional CPU box-extraction backend. It uses the generated text,
attention maps, page dimensions, and the bundled frozen geometry predictors. It
needs no layout detector, PDF text, or raster processing after attention capture.
The existing layout method remains the default and does not import this backend.
Install the optional dependencies from this repository:
```bash
pip install -r requirements-fast-layout.txt
python examples/boxes.py page.png --layout fast-layout
```
The example still uses a CUDA model to transcribe and capture attention in a second
teacher-forced pass. Fast layout changes postprocessing; it does not remove that
pass. Existing `--attention-only` behavior remains available.
```python
from ocria_grounding import ground_layout, load_fast_layout
backend = load_fast_layout() # once per process; loads bundled trusted joblib files
page = ground_layout(grounder, image, answer,
method="fast-layout", fast_backend=backend)
```
For cached or engine-supplied attention, no GPU or image object is required:
```python
page = backend(answer=answer, attention=capture)
```
`capture` contains `width`, `height`, `grid: [rows, columns]`, and
`sparse_maps: {idx, val, has}`. Each row corresponds to a unit from
`parse_rl_utils.ocria_attention_grounding.io.units_for(answer, split_blocks(answer))`;
`split_blocks` is in that package's `blocks` module. Indices address the flattened
attention grid. Use the exact answer and unit order from capture. The live adapter
retains 512 cells per unit. Different heads, model revisions, and cell counts need
separate validation.
Outputs use pixel-coordinate `box` values and preserve detailed `layout_segments`.
Merged items do not supply a single source `start` offset. The public serializer
preserves these segments. Timings separate `attention_capture` from
`layout_postprocessing`; model loading is excluded and first-call initialization
can affect postprocessing time. PDF coordinate-frame conversion is caller-owned.
Optional native acceleration requires a C++17 compiler and Rust:
```bash
python -m parse_rl_utils.ocria_attention_grounding.native --output /tmp/ocria-native.so
python -m parse_rl_utils.ocria_attention_grounding.rust --output /tmp/ocria-rust.so
export OCRIA_GROUNDING_NATIVE=/tmp/ocria-native.so
export OCRIA_GROUNDING_RUST=/tmp/ocria-rust.so
export OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1
```
Python fallbacks work without those libraries. The retained cached benchmark had
69.1938% layout grounding accuracy and 47.65 ms/page mean CPU postprocessing
(99.18 ms p95; warm, native kernels, one CPU thread). These are not end-to-end
latencies or measurements of the public model's selected heads. The integration
preserves 1,341 existing cached replay outputs. A two-page H100 smoke test passes
transcription, attention capture, fast layout, and serialization, with identical default
outputs before and after fast layout. This smoke test does not establish benchmark
accuracy with the public attention heads.
The bundled artifacts are unchanged frozen predictors; this integration performs
no training. Only load joblib artifacts from trusted sources.
#### Integration checks
```bash
pip install pytest
PYTHONPATH=. python -m pytest tests -q
PYTHONPATH=. python tests/check_legacy_layout.py
```
The 17 tests cover malformed sparse captures, cached GPU/raster isolation, coordinate
frames, retained attention cells, dispatch, segmented serialization, the CLI, and a
localhost HTTP request. They pass with native kernels on macOS and Linux. The legacy
fixture compares four modes against the unmodified HF snapshot; a separate 10-page
cached comparison also preserves default outputs exactly. Invalid dimensions, grid
indices, sparse rows, and attention values raise `ValueError` before geometry runs.
Across 535 cached pages, Python and native execution preserve item counts and text;
5 pages have coordinate differences, at most 2.1 pixels. Input validation preserves
all native outputs. A separate native run including validation averaged 51.9 ms/page;
this was not an isolated latency experiment and is not an end-to-end measurement.
Run the bounded CUDA smoke on a machine with the model dependencies and weights:
```bash
PYTHONPATH=. python tests/check_cuda_layout.py --model /path/to/OCRia-1
```
It generates two synthetic pages, transcribes at most 256 tokens per page, blocks
both raster-geometry constructors during fast layout, and checks that subsequent
default layout output is unchanged. It uses the Python backend unless native
library environment variables are set. It does not run training or a full benchmark.
## Benchmarks
**[ParseBench leaderboard dashboard](https://parsebench.ai)**
| Benchmark | Dimensions | Pages | OCRia-1 | Rank | Open-weight rank |
|---|---:|---:|---:|---:|---:|
| [ParseBench 2](https://huggingface.co/datasets/llamaindex/ParseBench-2) | 6 | 4,317 | **85.24** | 7 of 61 | **1 of 23** |
| [ParseBench 1](https://huggingface.co/datasets/llamaindex/ParseBench) | 5 | 2,078 | **84.65** | 2 of 158 | **1 of 53** |
Both scores include visual grounding, using the [layout boxes](#layout-boxes-experimental) from this repository.
Results from the [technical report](https://arxiv.org/abs/2611.00092). Each benchmark is scored with its own scorer, at
its standard rendering: olmOCR-bench at 1,288 px on the long side, PulseBench-Tab crops capped at 2,560 px and
fr-bench-pdf2md at 2,048 px.
| Model | olmOCR-bench¹ | PulseBench-Tab | fr-bench-pdf2md |
|---|---:|---:|---:|
| Infinity-Parser2-Pro (35B) | 90.2 | 82 | 54.9 |
| LightOnOCR-3-4B | 90.1 | 82 | 71.4 |
| olmOCR-2 (7B) | 83.1 | 80 | 56.9 |
| Chandra-OCR-2 (4B) | 89.4 | 80 | 65.5 |
| dots.mocr (3B) | 87.4 | 82 | 56.8 |
| Surya OCR 2 (0.7B) | 85.4 | 71 | 50.9 |
| LightOnOCR-2-1B | 88.1 | 81 | 53.5 |
| Mistral OCR 4.1 | 80.3 | 75 | 54.1 |
| **OCRia-1 (4B)** | **90.5** | **84** | **72.1** |
¹ Mean of the three table and formula categories (Tables, arXiv math, Old scans math), from published numbers for the
other systems. In the report's comparison with every system rendered at 1,288 px, OCRia-1 also has the highest
official score over all eight categories, 83.5 against 83.2 for Infinity-Parser2-Pro.
PulseBench-Tab is reported on a 0–1 scale in the report and shown here ×100.
### ParseBench 2
[ParseBench 2](https://huggingface.co/datasets/llamaindex/ParseBench-2) scores six dimensions over 4,317 pages. OCRia-1
was run with the `ocria_1` pipeline of [parse-bench](https://github.com/run-llama/ParseBench) (text from vLLM, boxes from
[Layout boxes](#layout-boxes-experimental)) and scored the way the [leaderboard](https://parsebench.ai) re-scores its rows
(dataset revision `2d9a2344`, parse-bench 2.2.1).
| Model | Overall | Text | Formatting | Tables | Charts | Visual grounding | Forms |
|---|---:|---:|---:|---:|---:|---:|---:|
| Infinity-Parser2-Pro (35B) | 78.50 | 85.55 | 78.70 | 86.27 | 55.64 | 87.04 | 77.79 |
| LightOnOCR-3-4B | 78.39 | 84.30 | 81.44 | 78.25 | 62.90 | 84.25 | 79.19 |
| Chandra-OCR-2 (4B) | 77.54 | 77.18 | 88.80 | 85.60 | 62.48 | 72.44 | 78.73 |
| dots.mocr (3B) | 64.14 | 86.29 | 80.63 | 83.40 | 0.78 | 67.88 | 65.83 |
| Surya OCR 2 (0.7B) | 68.97 | 84.91 | 86.32 | 72.40 | 20.68 | 71.37 | 78.11 |
| Mistral OCR 4.1 (annotation) | 73.96 | 84.44 | 81.91 | 81.89 | 29.83 | 85.93 | 79.78 |
| KDL-Frontier-Parser-nano-v2 | 80.13 | 80.21 | 84.58 | 80.54 | 73.55 | **88.28** | 73.60 |
| **OCRia-1 (4B)** | **85.24** | **87.87** | **91.59** | **86.28** | **77.63** | 85.96 | **82.09** |
These are the models from the comparison above that have a ParseBench 2 row, plus KDL-Frontier-Parser-nano-v2, the
next-highest open-weight model. olmOCR-2 and LightOnOCR-2-1B are not on the ParseBench 2 leaderboard.
Among all 61 systems on the leaderboard, including commercial APIs and frontier vision models, OCRia-1 ranks seventh
overall.
### ParseBench 1 leaderboard
The same pipeline on [ParseBench 1](https://huggingface.co/datasets/llamaindex/ParseBench) (2,078 pages, five
dimensions, visual grounding included), scored the way the [leaderboard](https://parsebench.ai) re-scores its rows
(dataset revision `2805a1d9`, parse-bench 2.2.1).
| Model | Overall | Tables | Charts | Content faithfulness | Semantic formatting | Visual grounding |
|---|---:|---:|---:|---:|---:|---:|
| KDL-Frontier-Parser-nano-v2 | 79.03 | 86.19 | 69.14 | 87.59 | 76.91 | **75.33** |
| rakedoc-nano | 77.23 | 86.44 | 64.89 | 88.84 | 71.68 | 74.28 |
| aeddix-alpine-ocr (KDL pipeline) | 76.77 | 85.89 | 68.78 | 87.90 | 66.05 | 75.21 |
| LightOnOCR-3-4B | 75.34 | 83.63 | 66.35 | 90.07 | 68.08 | 68.59 |
| Infinity-Parser2-Pro (35B) | 71.19 | 86.39 | 58.16 | 89.66 | 47.12 | 74.64 |
| Chandra-OCR-2 (4B) | 70.59 | 89.20 | 62.77 | 85.45 | 64.37 | 51.18 |
| Surya OCR 2 (0.7B) | 60.63 | 82.74 | 19.04 | 87.84 | 63.59 | 49.93 |
| Mistral OCR 4 | 58.38 | 74.03 | 1.86 | 90.01 | 60.32 | 65.69 |
| dots.mocr (3B) | 54.18 | 85.03 | 0.84 | 89.99 | 40.11 | 54.91 |
| **OCRia-1 (4B)** | **84.65** | **91.80** | **82.47** | **90.27** | **85.50** | 73.23 |
The rows are the leading open-weight models on the leaderboard and the models from the comparison above that have a
verified row. Mistral appears as Mistral OCR 4, the version on this leaderboard. The rakedoc-nano and aeddix-alpine-ocr
rows are unverified on the leaderboard. olmOCR-2 is not on it, and LightOnOCR-2-1B has only an unverified row.
The technical report gives a four-dimension ParseBench 1 mean without visual grounding (87 for OCRia-1), so its figures
differ from this table.
Among all 158 systems on the ParseBench 1 leaderboard, OCRia-1 ranks second overall and first in semantic formatting.
Notes:
- The model writes constructs that these benchmarks do not expect, such as page-furniture tags, image markers and
Mermaid blocks. They are removed before scoring, and the markup inside table cells is normalized; the report's
appendix describes the post-processing.
- Scores depend on rendering. Giving OCRia-1 2,451 image tokens per page instead of 1,240 raises its olmOCR-bench score
by 2.4 points with no change to the weights, and other models respond the same way.
- ParseBench is maintained by LlamaIndex. olmOCR-bench, PulseBench-Tab and fr-bench-pdf2md are independent.
## Speed
The report's speed numbers are for the LlamaParse serving stack on one B200: these weights quantized to a mix of NVFP4
and FP8 (vision encoder in BF16), a 0.69B DFlash 2 block-diffusion speculator, and custom vLLM kernels. With one request
it decodes about 4,700 tokens per second; at 64 concurrent requests it parses 10.2 pages per second.
This repository holds the unoptimized BF16 weights only: no quantization, no speculator and no custom kernels. On stock
vLLM they decode about 320 to 330 tokens per second for a single page, about nine times slower than the optimized
stack. [The Inference Stack Behind OCRia](https://www.llamaindex.ai/blog/the-inference-stack-behind-ocria) explains how the optimized stack was built: workload-aware
mixed-precision quantization, speculative decoding, and cutting GPU and CPU overhead.
## Training
OCRia-1 starts from [Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B). The full account is in the
[technical report](https://arxiv.org/abs/2611.00092).
**Data.** 100,979 pages, about 0.37B target tokens, built around the cases document-parsing VLMs still get wrong:
dense and spanned tables, charts, mathematics, non-Latin scripts, old scans and handwriting.
- 82,943 real pages from eleven source families with permissive licenses: Internet Archive, arXiv, US and UK government
statistics, PubMed Central, contracts and public documents with tracked changes, the Library of Congress,
OpenAlex-indexed articles, EUR-Lex, other government and financial filings, the World Bank and publisher sites.
Their transcriptions come from a teacher pipeline, checked against the page image and the PDF text before they are
kept.
- 18,036 synthetic pages (13,953 tables and charts, 3,189 forms and formatting, 894 text variants), generated in the
styles of real documents, so the ground truth is exact.
- No customer data is used for training.
**Supervised fine-tuning.** Two epochs on pages of about 1,024 px.
**Reinforcement learning with verifiable rewards (GRPO).** Rewards check each dimension the way a benchmark would:
table structure and cell values, chart data points, text content and inline formatting, plus penalties for errors
such as merged or split tables, unfinished tables, repetition and formatting the page does not have.
**Checkpoint averaging.** OCRia-1 is the uniform average of two RL checkpoints that are stronger in different
dimensions.
## Files
| File | What |
|---|---|
| `model.safetensors` | BF16 weights, 10.35 GB, sha256 `426d9aa2df62e72e1e79068698962b407208d45df06b612641a87fc50f904a87` |
| `prompt.txt` | the system prompt the model was trained and evaluated with |
| `ocria_grounding/` | code that adds layout boxes to the model's answer (layout regions, PDF word positions, attention) |
| `examples/` | `boxes.py` draws a page's layout boxes; `serve_boxes.py` serves them over HTTP |
| `fast_layout_models/`, `parse_rl_utils/ocria_attention_grounding/`, `requirements-fast-layout.txt` | the [fast layout](#fast-layout-experimental) option: frozen predictors and the code that applies them |
| `tests/` | checks for the layout code |
| `config.json`, `generation_config.json`, `chat_template.jinja`, `processor_config.json`, `tokenizer*.json` | Qwen3.5 configuration, chat template, processor and tokenizer |
| `LICENSE` | the OCRia-1 Model and Code License |
| `assets/` | images for this card |
| GGUF (llama.cpp, Ollama) | in [llamaindex/OCRia-1-GGUF](https://huggingface.co/llamaindex/OCRia-1-GGUF): BF16, Q8_0 and the vision projector |
## License
The weights and the code in `ocria_grounding/` are released under the [OCRia-1 Model and Code License](LICENSE),
based on the AI Pubs Open RAIL-M license. The same terms apply to both, and the code is not open source:
- **Free for research:** academic and non-profit research, teaching, evaluation and benchmarking by anyone (including
publishing the results), and internal R&D that does not reach a product or production workflow.
- **Free for personal use, and for commercial use** by organizations under $2M in annual revenue and under $2M in
total funding.
- **Commercial license needed** above those thresholds, and for any use in a document parsing, OCR or extraction
product or service that competes with LlamaParse or LlamaCloud, whatever your size.
[Contact us](https://www.llamaindex.ai/contact), or use OCRia-1 through [LlamaParse](https://cloud.llamaindex.ai).
**Licensing:** anyone interested in licensing OCRia-1 may contact LlamaIndex at
[https://www.llamaindex.ai/contact](https://www.llamaindex.ai/contact).
You own your outputs. OCRia-1 is fine-tuned from [Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B) (Apache-2.0);
see Attachment B of the license.
## Citation
```bibtex
@misc{rangapur2026ocria1,
title = {{OCRia-1} Technical Report},
author = {Rangapur, Aman and Jimeno Yepes, Antonio and Bustamante, Daniel and Dendumrongsup, Nutchapol and
Acosta, Sebasti{\'a}n G. and Doulcet, Pierre-Lo{\"i}c and Suo, Simon},
year = {2026},
eprint = {2611.00092},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2611.00092},
}
```