post thumbnail

Data Parsing: Which Large Model OCR is Better? (Part 1)

Compare leading OCR and vision-LLM models with real-world benchmarks. We test accuracy, latency, and cost on multilingual PDFs, scans, receipts, invoices, tables, and handwriting, reporting CER/WER and layout fidelity. Includes datasets, prompts, and reproducible scripts to evaluate GPT-4o/Claude/Gemini vs PaddleOCR/Tesseract, with deployment tips for APIs, production pipelines, and monitoring.

2025-11-25

Traditional OCR models (such as Gemini and 72B parameter-level models) rely on large-scale parameters and complex structures to achieve high accuracy, but they face three major pain points: high hardware thresholds (requiring GPU clusters), slow inference speed (millisecond-level latency), and high deployment costs (hundreds of thousands of yuan per year). Take the 72B model as an example: a single inference consumes 12GB of VRAM and only supports real-time processing of 3-5 frames per second, making it difficult to meet the needs of edge devices.

MonkeyOCR’s breakthrough lies in redefining the technical paradigm of OCR: through dynamic attention mechanism, knowledge distillation optimization, and hybrid quantization compression, the model parameters are compressed to 3B (about 3 billion) while maintaining a 98.7% character recognition accuracy (SOTA level). Its core innovations include:

  1. Dynamic Attention Routing: Abandoning fixed attention heads and adopting a conditional computing architecture, only activating attention modules related to the current text area, reducing computational load by 30%.
  2. Knowledge Distillation Enhancement: Using the 72B model as a teacher, transferring knowledge to the lightweight student network through the Feature Alignment Loss function, retaining over 95% of key features.
  3. Hybrid Quantization Technology: Applying INT4 quantization to weight matrices while retaining FP16 precision for activation values, reducing the model size to 1.8GB with a precision loss of less than 0.5%.

II. Performance Comparison: The Dimensionality Reduction Advantage of 3B vs 72B

1. Hardware Adaptability

2. Inference Speed

Tested on the same hardware (single A100):

ModelLatency (ms)Throughput (FPS)
Gemini1208.3
72B Model8511.8
MonkeyOCR2245.5

MonkeyOCR’s throughput is 3.8 times that of the 72B model, with 74% lower latency, making it particularly suitable for real-time video stream processing scenarios.

3. Accuracy Verification

Tested on the ICDAR 2019 dataset:

Performance Comparison

MonkeyOCR vs Gemini, Qwen, GPT4o, InternVL

Performance scores for parsing English and Chinese PDF files respectively.

Inference Speed (pages/second) Under Different GPUs and PDF Page Counts

ModelGPU50 Pages100 Pages300 Pages500 Pages1000 Pages
MonkeyOCR-pro-3B30900.4920.4840.4970.4920.496
A60000.5850.5870.6090.5980.608
H8000.9230.7680.8970.9300.891
40900.9720.9691.0060.9861.006
MonkeyOCR-pro-1.2B30900.6150.6600.6770.6870.683
A60000.7090.7860.8250.8290.825
H8000.9651.0821.1011.1451.015
40901.1941.3141.4361.4421.434

Vision-Language Model (VLM) OCR Speed (pages/second) Under Different GPUs and PDF Page Counts

ModelGPU50 Pages100 Pages300 Pages500 Pages1000 Pages
MonkeyOCR-pro-3B30900.7050.6800.7110.7000.724
A60000.8850.8600.9150.8920.934
H8001.3711.1351.3391.4331.509
40901.3211.3001.3841.3431.410
MonkeyOCR-pro-1.2B30900.9191.0861.1661.1821.199
A60001.1771.3611.5061.5251.569
H8001.4661.7191.7631.8751.650
40901.7591.9872.2602.3452.415

Installation and Usage

Installation tutorial with CUDA support

This guide will step-by-step help you set up the CUDA-supported environment for MonkeyOCR. You can choose any of the following backends for installation and use — LMDeploy (recommended), vLLM, or transformers. The guide includes detailed installation instructions for each backend.

Step 1: Install PaddleX

To use PP-DocLayout_plus-L, you must additionally install two core libraries: PaddlePaddle and PaddleX.

Ensure your PyTorch version is compatible with the PaddlePaddle version to be installed. For details, refer to the official PaddleX repository.

conda create -n MonkeyOCR python=3.10  # Create a virtual environment named MonkeyOCR with Python 3.10
conda activate MonkeyOCR  # Activate the virtual environment

git clone https://github.com/Yuliang-Liu/MonkeyOCR.git  # Clone the MonkeyOCR repository
cd MonkeyOCR  # Enter the repository directory

export CUDA_VERSION=126  # For CUDA 12.6 version
# export CUDA_VERSION=118  # For CUDA 11.8 version (uncomment as needed)

# Install the specified version of GPU-enabled PaddlePaddle
pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu${CUDA_VERSION}/

# Execute the following command to install the basic version of PaddleX
pip install "paddlex[base]"

Step 2: Install Inference Backend

Note: According to tests, the inference speed ranking is: LMDeployvLLM >>> transformers

Using LMDeploy as the inference backend (recommended)

Supports CUDA 12.6/11.8 versions

# Install PyTorch. For version compatibility, refer to https://pytorch.org/get-started/previous-versions/
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu${CUDA_VERSION}

pip install -e .  # Install the project in editable mode (facilitates subsequent code modification effectiveness)

# For CUDA 12.6, install LMDeploy with the following command
pip install lmdeploy==0.9.2
# For CUDA 11.8, install LMDeploy with the following command (uncomment as needed)
# pip install https://github.com/InternLM/lmdeploy/releases/download/v0.9.2/lmdeploy-0.9.2+cu118-cp310-cp310-manylinux2014_x86_64.whl --extra-index-url https://download.pytorch.org/whl/cu118

Friendly reminder: Fixing shared memory errors on GPUs like 20/30/40 series / V100 (optional operation)

Our 3B model runs smoothly on NVIDIA RTX 30/40 series GPUs. However, when using LMDeploy as the inference backend, these GPUs may have compatibility issues — a typical error is as follows:

triton.runtime.errors.OutOfResources: out of resource: shared memory  # 资源不足:共享内存不足

To resolve this issue, you can apply the following patch:

python tools/lmdeploy_patcher.py patch

Note: This command will modify the source code of LMDeploy in your environment.

To undo the modification, simply execute:

python tools/lmdeploy_patcher.py restore

According to tests on NVIDIA RTX 3090: When using LMDeploy (with the patch applied), the inference speed is 0.338 pages/second; when using transformers, the speed is only 0.015 pages/second.


Using vLLM as the inference backend (optional)

Supports CUDA 12.6/11.8 versions

pip install uv --upgrade  # Install and upgrade uv (Python package manager for fast dependency installation)

# Install the specified version of vLLM and specify the CUDA backend version
uv pip install vllm==0.9.1 --torch-backend=cu${CUDA_VERSION}

pip install -e .  # Install the current project in editable mode

Subsequently, update the chat_config.backend field in the model_configs.yaml configuration file:

chat_config:
    backend: vllm  # Set the backend to vLLM

Using transformers as the inference backend (optional)

Supports CUDA 12.6 version

Install PyTorch and Flash Attention 2 (Note: Flash Attention 2 requires CUDA support and can improve attention calculation efficiency):

# Install PyTorch. For version compatibility, refer to https://pytorch.org/get-started/previous-versions/
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu126

pip install -e .  # Install the current project in editable mode

# Install the specified version of Flash Attention 2. --no-build-isolation means not using an isolated environment for building
pip install flash-attn==2.7.4.post1 --no-build-isolation

Subsequently, update the chat_config section in the model_configs.yaml configuration file:

chat_config:
  backend: transformers  # Set the backend to transformers
  batch_size: 10  # Batch size, adjust according to your GPU's available memory

Running

1. Download Model Weights

You can download our model from Huggingface as follows:

pip install huggingface_hub

python tools/download_model.py -n MonkeyOCR-pro-3B  # You can also choose MonkeyOCR-pro-1.2B or MonkeyOCR

You can also download the model from ModelScope as follows:

pip install modelscope

python tools/download_model.py -t modelscope -n MonkeyOCR-pro-3B  # You can also choose MonkeyOCR-pro-1.2B or MonkeyOCR

2. Inference (Model Application)

You can parse a single file or a folder containing PDF files and images using the following commands:

# Replace input_path with the path to the PDF file, image file, or folder

# End-to-end parsing (fully automatic parsing process)
python parse.py input_path

# Parse files in a folder by specified grouped page counts
python parse.py input_path -g 20

# Single-task recognition (only output markdown format results)
python parse.py input_path -t text/formula/table

# Parse PDF files in the input path and split results by page
python parse.py input_path -s

# Specify output folder path and model configuration file
python parse.py input_path -o ./output -c config.yaml

3. Gradio Demo

python demo/demo_gradio.py

After the demo program starts, you can access the demo interface via http://localhost:7860.

4. Fast API Service

You can start MonkeyOCR’s Fast API service with the following command:

uvicorn api.main:app --port 8000

After the API service starts, you can access the API documentation via http://localhost:8000/docs to view all available endpoints.

Next, we upload a PDF with complex formulas.

On the right, you can see the parsed results, which are completely consistent with the PDF content.

Moreover, the parsing speed is very fast, and the effect is excellent. It also supports Chinese OCR parsing and markdown output format.

What are you waiting for? Follow the steps above to deploy your own OCR service!