# Infinity-Parser: LayoutRL for Document Parsing with Verifiable Rewards

> Analysis of Infinity-Parser, a VLM trained with LayoutRL using layout-aware verifiable rewards for end-to-end document parsing

- Authors: Hunter Heidenreich
- Published: 2025-06-01
- Updated: 2026-03-04
- Paper: Infinity-Parser Paper <https://arxiv.org/abs/2506.03197>
- Code: INF-MLLM Code <https://github.com/infly-ai/INF-MLLM>
- Model: Infinity-Parser-7B Model <https://huggingface.co/infly/Infinity-Parser-7B>
- Source: Bevaya Labs, <https://labs.bevaya.ai/>

---


## TL;DR

Wang et al. introduce **LayoutRL**, a reinforcement learning framework that trains a VLM to output full-page structured Markdown from scanned documents using layout-aware, verifiable rewards (edit distance, paragraph count, and reading order). Built on top of Qwen2.5-VL-7B and trained with the new **Infinity-Doc-400K** corpus (roughly 400k documents with paired images and Markdown), **Infinity-Parser-7B** reports competitive results on OmniDocBench, olmOCR-Bench, PubTabNet, and FinTabNet relative to both pipeline OCR systems and general VLMs.

* * *

## What kind of paper is this?

**Dominant:** $\\Psi\_{\\text{Method}}$ (introduces LayoutRL, a reinforcement learning framework with multi-aspect layout-aware rewards for end-to-end document parsing).

**Secondary:** $\\Psi_{\\text{Resource}}$ (releases Infinity-Doc-400K, a large document corpus with paired images and Markdown annotations, plus synthetic data generation pipeline); $\\Psi_{\\text{Evaluation}}$ (extensive comparisons on four external benchmarks with ablations on reward design and training regime).

* * *

## What is the motivation?

-   **Problem:** Scanned document parsing requires hierarchical structure recovery (paragraphs, headers, tables, formulas, reading order), not just text recognition. Traditional multi-stage pipelines (layout detection, OCR, table/formula modules) suffer from error propagation and limited adaptability to layout variation.
-   **Limitations of supervised fine-tuning:** End-to-end VLM parsers trained via SFT tend to overfit surface patterns and provide token-level supervision only, which does not directly reward correct page-level structure or reading order. Generalization to out-of-distribution layouts remains weak, and high-quality layout annotations are expensive.
-   **Gap in RL approaches:** RL is promising for outcome-based training of LLMs and VLMs, but prior RL work mainly uses coarse binary success rewards that are not layout-aware and thus poorly suited to complex document parsing.
-   **Goal:** Design a layout-aware RL framework with verifiable multi-aspect rewards and supply a sufficiently large, reasonably clean dataset to train a robust VLM that generalizes across document domains, languages (English and Chinese), and structural complexities.

* * *

## What is the novelty?

### LayoutRL: multi-aspect, verifiable reward for document parsing

The model outputs a full-page Markdown representation, which is scored with three rule-based rewards:

-   **Edit distance reward** ($R_{\\text{dist}}$): Normalized Levenshtein distance between prediction and reference text, formulated as $R_{\\text{dist}} = 1 - D(y, \\hat{y}) / \\max(N, M)$, where $N$ and $M$ are lengths of reference and prediction.
-   **Count reward** ($R_{\\text{count}}$): Penalty for mismatch in number of predicted versus reference paragraphs. With $N_Y$ and $N_{\\hat{Y}}$ representing numbers of paragraphs in reference and prediction, $R_{\\text{count}} = 1 - |N_Y - N_{\\hat{Y}}| / N_Y$.
-   **Order reward** ($R_{\\text{order}}$): Penalty for inversions in paragraph reading order after optimal matching. After matching predicted and ground truth paragraphs using the Hungarian algorithm, count pairwise inversions ($D_{\\text{order}}$), then $R_{\\text{order}} = 1 - D_{\\text{order}} / \\text{maxinv}$, where $\\text{maxinv} = N_Y (N_Y - 1) / 2$.

Segments are matched using the Hungarian algorithm before computing rewards, so content and structure are aligned at the paragraph level. The combined reward is the simple sum: $R_{\\text{multi}} = R_{\\text{dist}} + R_{\\text{count}} + R_{\\text{order}}$.

### Infinity-Doc-400K dataset and dual-pipeline construction

The training corpus contains roughly 400k annotated document pages with paired images and Markdown, constructed via two pipelines:

-   **Real-world pipeline** (about 331k documents): Scanned documents from financial reports, medical reports, academic papers, books, magazines, and web pages, pseudo-labeled via multiple expert models (layout, formula, table, OCR) plus VLM cross-checks. Only high-consensus regions are kept.
-   **Synthetic pipeline** (about 69k documents): HTML templates (single, double, triple column) filled with text and images from Wikipedia, CC3M, and web corpora via Jinja, rendered in a browser to images, with Markdown extracted directly from HTML.

Three document analysis experts manually inspected about 5% of the data and used feedback to refine screening rules across at least five iterations.

### Infinity-Parser-7B: RL-finetuned Qwen2.5-VL-7B

The parser is a standard VLM (Qwen2.5-VL-7B) trained to map full pages to Markdown without explicit intermediate layout detection. RL is applied directly on outputs using **Group Relative Policy Optimization (GRPO)**, learning from relative rewards across multiple sampled completions per page.

### Systematic comparison of SFT versus layout-aware RL

Ablations compare supervised SFT, RL with different reward subsets, and SFT followed by RL, studying both in-distribution and out-of-distribution behavior on OmniDocBench document types.

* * *

## What experiments were performed?

### External benchmarks

The model is evaluated on four external datasets:

-   **OmniDocBench**: Comprehensive evaluation across multiple document types with metrics for overall normalized edit distance, text, formulas, tables (TEDS and edit), and reading order. Comparisons against pipeline tools (MinerU, Marker, Mathpix, Docling, Pix2Text, Unstructured, OpenParse), OCR-focused VLMs (GOT-OCR, Nougat, Mistral OCR, olmOCR), and general VLMs (GPT-4o, Qwen2-VL-72B, Qwen2.5-VL-7B, InternVL2/3, SmolDocling).
-   **olmOCR-Bench**: Fact-based evaluation of document-level OCR across domains such as ArXiv, old scans, math tables, multi-column layouts, long tiny text, and "base" PDFs. Compares to pipeline systems and commercial APIs including GPT-4o, Gemini, Mistral OCR, Qwen2-VL variants, and olmOCR with "anchored" and "non-anchored" prompts.
-   **PubTabNet and FinTabNet**: Table recognition benchmarks focusing on structure and content, using TEDS and TEDS-S metrics. Comparisons to EDD, OmniParser, InternVL3 (8B and 78B), Qwen2.5-VL (7B and 72B), and GPT-4o.

### Ablations and analyses

-   **Reward ablation**: Compare zero-shot Qwen2.5-VL-7B, SFT on 43k documents, and RL with different reward subsets (edit-only, edit plus count, all three rewards, RL after SFT). Metrics include overall edit distance for English and Chinese pages, plus averaged category-level text edit distance across nine page types.
-   **Training stability and scaling**: Plot performance versus training data size for OmniDocBench subtasks (text, formulas, tables, reading order). RL curves are reported to be smoother and improve more steadily than SFT as data size increases.
-   **Robustness across document types**: Compare base model, SFT, and RL on different categories (old scans, tables, multi-column) on both olmOCR and OmniDocBench. RL is reported to consistently give higher similarity scores.
-   **In-distribution versus OOD generalization**: Evaluate models on in-distribution domains (magazines, research reports) and OOD domains (colorful textbooks and slides excluded from training) as training progresses. RL is reported to continue improving page-level scores in both settings, while SFT tends to plateau and degrade more in OOD cases.
-   **Case studies**: Qualitative comparisons on individual pages from academic papers, books, exams, magazines, newspapers, and slides, showing that Infinity-Parser reduces redundant recognition and formatting errors relative to MinerU and GPT-4o.

* * *

## What are the outcomes and limitations?

### Outcomes

**OmniDocBench overall:**

-   Infinity-Parser-7B achieves overall edit distance of about **0.141 (EN)** and **0.197 (ZH)**, lower than all listed baselines. Pipeline tools like MinerU and Mathpix are competitive on some subtasks but worse overall, particularly on Chinese pages.

**OmniDocBench subtasks and categories:**

-   On text, formula, table TEDS, and reading order, Infinity-Parser generally gives the best or near-best scores among compared systems for both English and Chinese.
-   On nine page types (books, slides, financial reports, textbooks, exams, magazines, academic papers, notes, newspapers), the mean text edit distance is reported at **0.104**, noticeably lower than Qwen2-VL-72B (about 0.179) and pipeline tools.

**olmOCR-Bench:**

-   Infinity-Parser-7B has the highest reported overall score (**82.5**), ahead of the anchored olmOCR model (77.4) and GPT-4o variants. Gains are especially strong in multi-column and old scan categories, while performance on the "base" category is also high.

**Table benchmarks:**

-   On **PubTabNet**, Infinity-Parser reaches TEDS-S $\\approx$ 93.5 and TEDS $\\approx$ 91.8, slightly above EDD and OmniParser.
-   On **FinTabNet**, it reaches TEDS-S $\\approx$ 97.2 and TEDS $\\approx$ 95.9, surpassing OmniParser and InternVL3 variants.

**Effect of multi-aspect rewards:**

-   Relative to SFT on 43k documents, RL with only edit reward reduces overall edit distances, and adding count and order rewards further improves both page-level and category-level scores.

### Limitations and open questions

**Data usage versus dataset size:**

-   Infinity-Doc-400K contains about 400k documents, but RL training uses a **43k subset** due to compute constraints. It is unclear how much headroom remains if RL used the full dataset or a different sampling scheme.

**Label noise in real-world data:**

-   The real-world portion (about 331k documents) uses pseudo labels from multiple expert models. Cross-validation and expert spot checks reduce noise, but residual systematic errors or biases are not quantified.

**Language scope:**

-   Experiments cover English and Chinese, and some mixed-language tables. Other scripts and languages are not studied, so generalization to low-resource languages is unknown.

**Single backbone size:**

-   All experiments use Qwen2.5-VL-7B. There is no scaling study across model sizes, nor comparison of how much improvement comes from the RL recipe versus simply using a larger VLM.

**Reward design choices:**

-   The three rewards are summed with equal weights, and there is no systematic exploration of alternative weighting or additional layout signals. There is also no discussion of possible reward hacking (e.g., degenerate outputs that optimize edit distance while being hard to use downstream).

**Deployment aspects:**

-   The paper does not discuss inference latency, throughput, memory footprint, or production monitoring. There is no operational validation in real workflows, so all results are benchmark-based rather than field-based.

> **Contrast to olmOCR 2:** Both use RL for document parsing, but Infinity-Parser employs multi-aspect layout rewards (edit distance, paragraph count, reading order) optimized via GRPO, whereas olmOCR 2 uses binary unit tests as verifiable rewards. Infinity-Parser explicitly maintains general VLM capability, while olmOCR 2 focuses on document-specific optimization.

> **Contrast to dots.ocr:** dots.ocr treats document parsing as unified autoregressive sequence generation (layout detection, text recognition, and reading order in one pass), whereas Infinity-Parser uses RL with structured multi-aspect rewards on top of a base VLM, explicitly optimizing for layout awareness.

> **Contrast to MonkeyOCR:** MonkeyOCR decomposes parsing into SRR (Structure-Recognition-Relation) with separate YOLO detector, unified LMM, and reading-order model. Infinity-Parser is end-to-end VLM trained with RL, avoiding the pipeline architecture.

* * *

## Model

### Backbone

-   Base model: **Qwen2.5-VL-7B**, a vision-language model with high-resolution perception and a 7B-parameter language decoder. The paper treats it as a black-box backbone rather than detailing its internals.

### Task formulation

-   **Input:** Image(s) of scanned document pages.
-   **Output:** Markdown string encoding document structure (headings, paragraphs, lists, tables, formulas).
-   The model is trained without explicit thinking or intermediate layout reasoning; the output sequence is directly scored.

### Prompting

Document parsing uses a detailed Markdown conversion prompt:

-   Recognize all text.
-   Output Markdown.
-   Convert formulas to LaTeX (`$...$` inline and `$$...$$` block).
-   Convert tables to Markdown table syntax.
-   Ignore figures and images.
-   Maintain original document structure with clear line breaks.

Table-specific tasks use a set of paraphrased prompts that all request encoding the table as HTML, matching evaluation format on table benchmarks.

* * *

## Data

### Infinity-Doc-400K

**Scale and composition:**

-   About **400k** documents in total. Real-world documents: **331k** across six domains. Synthetic documents: **69k**.
-   Real-world domains and sizes: Financial reports (58.0k), Medical reports (5.0k), Academic papers (71.7k), Books (11.3k), Magazines (180.0k), Web pages (5.0k).
-   Synthetic documents: 69.0k generated via HTML templates plus content from CC3M, web, and Wikipedia.

**Real-world pipeline:**

-   Data collection: scanned documents from six domains.
-   Filtering: low-quality images removed, duplicates filtered.
-   Layout analysis: layout model identifies regions such as title, text, table, formula, figure.
-   Expert models: layout model for block segmentation, table recognition model, formula recognition model, OCR for text content.
-   Cross validation: predictions across models and an end-to-end VLM are compared. Only regions with consistent outputs are kept as pseudo-ground-truth.
-   Annotation: resulting images paired with Markdown, giving document-level annotations for OCR, tables, formulas, and reading order.

**Synthetic pipeline:**

-   Collect text and images from Wikipedia, web corpora, and image datasets.
-   Use Jinja templates to construct HTML with varying layouts (single, double, triple columns) and content types (tables, formulas, figures).
-   Render HTML to images via a browser engine.
-   Filter low-quality and overlapping images.
-   Extract ground-truth annotations by parsing HTML into Markdown. This gives exact alignment between the rendered page and the structured representation.

**Quality control:**

-   Three document analysis experts manually inspected about 5% of the data and used feedback to refine screening rules in at least five iterations.
-   A model-based cross-verification mechanism at scale keeps only high-consistency pseudo labels, with inconsistent samples feeding back into rule refinement.

### Training context statistics

-   Maximum training context: **8192 tokens**.
-   Observed lengths in raw data: Minimum (17 tokens), Maximum (31,147 tokens), Average (1,765 tokens), Median (1,127 tokens).
-   About **73%** of samples between 512 and 4k tokens. Sequences longer than 8k are left-truncated to keep trailing content, presumably more relevant.

* * *

## Algorithms / Training

### LayoutRL and multi-aspect reward

For each training document:

1.  **Generate candidates:** The policy model (Infinity-Parser) generates $G$ candidate outputs (eight in this work) with a maximum length of 8192 tokens and temperature 1.0.
2.  **Compute raw rewards:** For each candidate output $\\hat{y}$ versus reference $y$:
    -   **Edit distance reward:** $R\_{\\text{dist}} = 1 - D(y, \\hat{y}) / \\max(N, M)$, where $D(y, \\hat{y})$ is normalized Levenshtein distance, and $N$ and $M$ are lengths of reference and prediction.
    -   **Count reward:** $R_{\\text{count}} = 1 - |N_Y - N_{\\hat{Y}}| / N_Y$, where $N_Y$ and $N_{\\hat{Y}}$ are numbers of paragraphs in reference and prediction. This penalizes extra or missing paragraphs.
    -   **Order reward:** After matching predicted and ground truth paragraphs using the Hungarian algorithm, count pairwise inversions ($D_{\\text{order}}$) between the two lists. With $\\text{maxinv} = N_Y (N_Y - 1) / 2$, $R_{\\text{order}} = 1 - D\_{\\text{order}} / \\text{maxinv}$.
    -   **Combined reward:** $R_{\\text{multi}} = R_{\\text{dist}} + R_{\\text{count}} + R_{\\text{order}}$.
3.  **Group Relative Policy Optimization (GRPO):** Within each group of candidate outputs, rewards are converted into relative advantages by comparing each output to others in the same group. Training uses these group-based advantages and a KL penalty against a reference model, avoiding the need for a learned critic.

### Training setup

-   **Base model:** Qwen2.5-VL-7B.
-   **Data for RL:** Random **43k-document subset** from Infinity-Doc-400K.
-   **Framework:** GRPO implemented using Verl or EasyR1-like infrastructure.
-   **Hyperparameters:**
    -   KL coefficient: $\\beta = 1.0 \\times 10^{-2}$.
    -   Number of samples per document: 8.
    -   Max response length: 8192 tokens.
    -   Temperature: 1.0.
    -   Rollout batch size: 128.
    -   Global batch size: 128.
    -   Optimizer: AdamW with $\\beta_1 = 0.9$, $\\beta_2 = 0.99$, learning rate $1.0 \\times 10^{-6}$.
    -   Training duration: **1 epoch** over the 43k subset.

### SFT versus RL training variants

-   **SFT-only baseline:** Supervised fine-tuning on 43k labeled documents, using token-level loss on Markdown outputs. Details of SFT optimizer and schedule are not fully elaborated but appear standard.
-   **RL from scratch versus after SFT:** RL directly on top of the base model ("Zero + RL") versus RL starting from the SFT model ("SFT + RL"). Results suggest that, for this task and backbone, RL on the base model with full multi-aspect rewards is competitive with, and in some metrics better than, SFT-based starts.

* * *

## Evaluation

### OmniDocBench

**Metrics:**

-   Overall and per-subtask normalized edit distance for text, formulas, and reading order.
-   TEDS and TEDS-S for tables (structure and structure-plus-content).

**Baselines:**

-   Pipeline tools: MinerU, Marker, Mathpix, Docling, Pix2Text, Unstructured, OpenParse.
-   Document OCR VLMs: GOT-OCR, Nougat, Mistral OCR, olmOCR, SmolDocling.
-   General VLMs: GPT-4o, Qwen2-VL-72B, Qwen2.5-VL-7B, InternVL2-76B, InternVL3-8B.

**Key results:**

-   Infinity-Parser-7B yields lowest overall edit distances among listed systems for both English and Chinese.
-   Strong performance across text, formulas, tables, and reading order.
-   Reported robust performance across page types and complex table conditions (merged cells, formulas in cells, colorful and rotated tables).

### olmOCR-Bench

**Setup:**

-   Fact-based evaluation on single-page PDFs, checking whether specific "facts" are present in OCR output rather than using raw edit distance.
-   Models are evaluated in both anchored and non-anchored prompt settings.

**Outcome:**

-   Infinity-Parser-7B has the highest overall score (82.5), outperforming specialized and general systems across most document categories.

### PubTabNet and FinTabNet

**Metrics:**

-   **TEDS-S** for table structure.
-   **TEDS** for structure plus content.

**Comparisons:**

-   Infinity-Parser surpasses EDD, OmniParser, InternVL3, Qwen2.5-VL, and GPT-4o on both datasets according to reported numbers. Improvements are on the order of a few TEDS points.

### Ablation and behavior analysis

**Reward ablation:**

-   RL with edit-only reward improves over SFT on overall edit distance. Adding count and order rewards further improves structural metrics and category-level averages.
-   SFT followed by RL improves category-level averages slightly further but does not give the best English/Chinese overall edit distances, suggesting a tradeoff.

**Task-level behavior:**

-   RL curves for text, tables, formulas, and reading order show smoother growth with data size and higher end performance than SFT, which can plateau or regress.

**Distribution shift:**

-   In in-distribution settings, RL continues to improve page-level accuracy with more data, whereas SFT tends to focus on paragraph-level edit scores and stagnates on page-level metrics.
-   In OOD settings (textbooks and slides excluded from training), RL degrades less and achieves better final scores than SFT.

* * *

## Hardware / Production

**Training hardware:**

-   RL training performed on **8 $\\times$ NVIDIA A100 (80 GB)** GPUs in a distributed setup using Verl or EasyR1 tooling.

**Training cost and time:**

-   The paper does not state wall-clock training time or total FLOPs. The limited use of 43k documents with one epoch suggests a moderate training run, but this is not quantified.

**Serving / production:**

-   No details are given about deployment, latency benchmarks, or throughput optimizations. Infinity-Parser is described only in the research context; operationalization is out of scope for this report.

* * *

_Note: This analysis follows the Bevaya research note guidelines and classification taxonomy. For academic or production use, consult the original paper and verify claims through independent evaluation._

