



| Task | Infinity-Parser2-Pro | Infinity-Parser2-Flash | PaddleOCR-VL-1.5 | DeepSeek-OCR-2 | MinerU2.5 | Gemini-3-Pro |
|---|---|---|---|---|---|---|
| Document Parsing | ||||||
| olmOCR-bench | 87.6 | 86.0 | 78.5 | 76.3 | 75.2 | - |
| ParseBench | 74.3 | 72.2 | 66.0 | 41.2 | 45.9 | 69.1‡ |
| OmniDocBench-v1.6 | 93.95 | 91.98 | 94.87 | 90.17 | 92.98 | 92.85 |
| Layout Analysis (mIoU) | ||||||
| DocLayNet | 64.93* | 64.97* | 71.05* | 45.62* | 67.74* | - |
| D4LA | 52.41* | 46.05* | 50.21* | 33.03* | 51.62* | - |
| OmniDocBench-v1.5-Layout | 74.56* | 73.07* | 74.80* | 55.28* | 76.28* | - |
| Element Parsing | ||||||
| OmniDocBench-v1.5-TextBlock | 95.05 | 94.31 | 94.97* | 84.13* | 86.00 | - |
| PubTabNet (val) | 94.76 | 92.41 | 84.60 | 89.53* | 89.07 | 91.40 |
| UniMERNet | 97.7 | 96.5 | 95.8* | 79.8* | 96.5 | 96.4 |
| Chart Parsing | ||||||
| Chart2Table | 86.5 | 80.49 | 86.2* | 49.7* | - | - |
| Chart2Json | 73.69 | 67.66 | - | - | - | - |
| Chemical Formula Parsing | ||||||
| CoSyn_Chemical | 73.19 | 63.34 | - | 47.02* | - | - |
| Document VQA | ||||||
| DocVQA (val) | 96.43 | 93.16 | - | 43.42* | - | 93.68* |
| InfoVQA (val) | 86.26 | 75.94 | - | 22.07* | - | 85.24* |
| General Multimodal Understanding | ||||||
| AI2D | 88.89 | 79.53 | - | 37.66* | - | 91.87* |
| MathVista (testmini) | 71.4 | 59.5 | - | - | - | 81.8* |
| MMBench-EN (dev) | 87.54 | 77.92 | - | - | - | 90.29* |
| MMBench-CN (dev) | 86.43 | 75.77 | - | - | - | 90.98* |
| MMMU (val) | 61.89 | 45.89 | - | - | - | 56.00* |
| MMStar | 69.66 | 57.13 | - | - | - | 83.78* |
| OCRBench | 86.20 | 81.60 | - | 47.20* | - | 89.30* |
transformers library, here is a simple snippet:1from PIL import Image
2import torch
3from transformers import AutoModelForImageTextToText, AutoProcessor
4from qwen_vl_utils import process_vision_info
5
6# Load the model and processor
7model = AutoModelForImageTextToText.from_pretrained(
8 "infly/Infinity-Parser2-Pro",
9 torch_dtype="float16",
10 device_map="auto",
11)
12processor = AutoProcessor.from_pretrained("infly/Infinity-Parser2-Pro")
13
14# Build the messages for the model
15pil_image = Image.open("demo_data/demo.png").convert("RGB")
16min_pixels = 2048 # 32 * 64
17max_pixels = 16777216 # 4096 * 4096
18prompt = """
19- Extract layout information from the provided PDF image.
20- For each layout element, output its bbox, category, and the text content within the bbox.
21- Bbox format: [x1, y1, x2, y2].
22- Allowed layout categories: ['header', 'title', 'text', 'figure', 'table', 'formula', 'figure_caption', 'table_caption', 'formula_caption', 'figure_footnote', 'table_footnote', 'page_footnote', 'footer'].
23- Text extraction and formatting:
24 1) For 'figure', the text field must be an empty string.
25 2) For 'formula', format text as LaTeX.
26 3) For 'table', format text as HTML.
27 4) For all other categories (e.g., text, title), format text as Markdown.
28- The output text must be exactly the original text from the image, with no translation or rewriting.
29- Sort all layout elements in human reading order.
30- Final output must be a single JSON object.
31"""
32
33messages = [
34 {
35 "role": "user",
36 "content": [
37 {
38 "type": "image",
39 "image": pil_image,
40 "min_pixels": min_pixels,
41 "max_pixels": max_pixels,
42 },
43 {"type": "text", "text": prompt},
44 ],
45 }
46]
47
48chat_template_kwargs = {"enable_thinking": False}
49
50text = processor.apply_chat_template(
51 messages, tokenize=False, add_generation_prompt=True, **chat_template_kwargs
52)
53image_inputs, _ = process_vision_info(messages, image_patch_size=16)
54
55inputs = processor(
56 text=text,
57 images=image_inputs,
58 do_resize=False,
59 padding=True,
60 return_tensors="pt",
61)
62
63# Move all tensors to the same device as the model
64inputs = {
65 k: v.to(model.device) if isinstance(v, torch.Tensor) else v
66 for k, v in inputs.items()
67}
68
69# Generate the response
70generated_ids = model.generate(
71 **inputs,
72 max_new_tokens=32768,
73 temperature=0.0,
74 top_p=1.0,
75)
76
77# Strip input tokens, keeping only the newly generated response
78generated_ids_trimmed = [
79 out_ids[len(in_ids) :]
80 for in_ids, out_ids in zip(inputs["input_ids"], generated_ids)
81]
82output_text = processor.batch_decode(
83 generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
84)
85print(output_text)1# Create a Conda environment (Optional)
2conda create -n infinity_parser2 python=3.12
3conda activate infinity_parser2
4
5# Install PyTorch (CUDA). Find the proper version at https://pytorch.org/get-started/previous-versions based on your CUDA version.
6pip install torch==2.10.0 torchvision==0.25.0 torchaudio==2.10.0 --index-url https://download.pytorch.org/whl/cu128
7
8# Install FlashAttention (FlashAttention-2 is recommended by default)
9# Standard install (compiles from source, ~10-30 min):
10pip install flash-attn==2.8.3 --no-build-isolation
11# Faster install: download wheel from https://github.com/Dao-AILab/flash-attention/releases. Then run: pip install /path/to/<wheel_filename>.whl
12# For Hopper GPUs (e.g. H100, H800), we recommend FlashAttention-3 instead. See: https://github.com/Dao-AILab/flash-attention
13# NOTE: The code will prioritize detecting FlashAttention-3. If not found, it falls back to FlashAttention-2.
14
15# Install vLLM
16# NOTE: you may need to run the command below to resolve triton and numpy conflicts before installing vllm.
17# pip uninstall -y pytorch-triton opencv-python opencv-python-headless numpy && rm -rf "$(python -c 'import site; print(site.getsitepackages()[0])')/cv2"
18pip install vllm==0.17.1pip install infinity_parser21git clone https://github.com/infly-ai/INF-MLLM.git
2cd INF-MLLM/Infinity-Parser2
3pip install -e .parser command is the fastest way to get started.1# NOTE: The Infinity-Parser2 model will be automatically downloaded on the first run.
2
3# Parse a PDF (outputs Markdown by default)
4parser demo_data/demo.pdf
5
6# Parse an image
7parser demo_data/demo.png
8
9# Batch parse multiple files
10parser demo_data/demo.pdf demo_data/demo.png -o ./output
11
12# Parse an entire directory
13parser demo_data -o ./output
14
15# Output raw JSON with layout bboxes
16parser demo_data/demo.pdf --output-format json
17
18# Convert to Markdown directly
19parser demo_data/demo.png --task doc2md1# View all options
2parser --help1# NOTE: The Infinity-Parser2 model will be automatically downloaded on the first run.
2
3from infinity_parser2 import InfinityParser2
4
5parser = InfinityParser2()
6
7# Parse a single file (returns Markdown)
8result = parser.parse("demo_data/demo.pdf")
9print(result)
10
11# Parse multiple files (returns list)
12results = parser.parse(["demo_data/demo.pdf", "demo_data/demo.png"])
13
14# Parse a directory (returns dict)
15results = parser.parse("demo_data")| task_type | Description | Default Output |
|---|---|---|
doc2json | Extract layout elements with bboxes (default) | Markdown |
doc2md | Directly convert to Markdown | Markdown |
custom | Use your own prompt | Raw model output |
1# doc2json: get raw JSON with bbox coordinates
2result = parser.parse("demo_data/demo.pdf", output_format="json")
3
4# doc2md: direct Markdown conversion
5result = parser.parse("demo_data/demo.pdf", task_type="doc2md")
6
7# Custom prompt
8result = parser.parse("demo_data/demo.pdf", task_type="custom",
9 custom_prompt="Please transform the document's contents into Markdown format.")
10
11# Batch processing with custom batch size
12result = parser.parse("demo_data", batch_size=8)
13
14# Save results to directory
15parser.parse("demo_data/demo.pdf", output_dir="./output")1# vLLM Engine (default) — offline batch inference
2parser = InfinityParser2(
3 model_name="infly/Infinity-Parser2-Pro",
4 backend="vllm-engine", # default
5 tensor_parallel_size=2,
6)
7
8# Transformers — local single-GPU inference
9parser = InfinityParser2(
10 model_name="infly/Infinity-Parser2-Pro",
11 backend="transformers",
12 device="cuda",
13 torch_dtype="bfloat16", # "float16" or "bfloat16"
14)
15
16# vLLM Server — online HTTP API (start server first)
17parser = InfinityParser2(
18 model_name="infly/Infinity-Parser2-Pro",
19 backend="vllm-server",
20 api_url="http://localhost:8000/v1/chat/completions",
21 api_key="EMPTY",
22)1vllm serve infly/Infinity-Parser2-Pro \
2 --trust-remote-code \
3 --reasoning-parser qwen3 \
4 --host 0.0.0.0 \
5 --port 8000 \
6 --tensor-parallel-size 2 \
7 --gpu-memory-utilization 0.85 \
8 --max-model-len 65536 \
9 --mm-encoder-tp-mode data \
10 --mm-processor-cache-type shm \
11 --enable-prefix-caching| Visualization | Note |
|---|---|
| A-Stock | Easy to miscount colspan in tables |
| Multi-Column Layout | Complex layout analysis and reading order recovery. |
| Historical Newspaper | High probability of bounding box omission caused by ultra-dense text distribution, narrow column margins, and microscopic fonts. |
| US-Stock | Precise row alignment across wide frameless spaces and capturing the hierarchical semantics of indented headers. |
| Academic Paper (arXiv) | Accurate structural preservation of complex multi-line mathematical formulas, dense inline notations, and deeply nested subscripts/superscripts. |
| Magazine Page | Complex reading order recovery in an asymmetric multi-column layout. |
| Scanned Mathematics | Degraded and blurred print |
@misc{huang2026infinityparser2technicalreport,
title={Infinity-Parser2 Technical Report},
author={Zuming Huang and Jun Huang and Kexuan Ren and Baode Wang and Weizhen Li and Jianming Feng and Yu Wang and Yichen Yao and Shijun Lin and Yige Tang and Cheng Peng and Weidi Xu and Wei Chu and Yinghui Xu and Yuan Qi},
year={2026},
eprint={2607.07836},
archivePrefix={arXiv},
primaryClass={cs.AI},
url={https://arxiv.org/abs/2607.07836},
}