Yuliang-Liu/MonkeyOCRv2
MonkeyOCRv2 Vision Encoder — A Document-Native Visual Backbone
MonkeyOCRv2 – A Visual‑Text Foundation Model for Document AI
What it is – MonkeyOCRv2 is an open‑source, document‑oriented vision encoder plus a set of downstream models for OCR‑style tasks (text detection, recognition, parsing, understanding, formula recognition, etc.). It is released as a Hugging Face/ModelScope model zoo and can be dropped into any PyTorch/Transformers pipeline.
Key components
| Component | Purpose | Typical size |
|---|---|---|
| Vision Encoder (MonkeyOCRv2‑S /‑B /‑AS) | Extracts image features from document images. Built on ViT‑S, ViT‑B or ViTAE‑v2‑S backbones. | 28 M – 113 M params |
| Parsing model (‑S‑Parsing /‑B‑Parsing) | Multilingual layout‑aware document parsing (tables, headings, etc.). | ~0.6‑0.7 B params |
| Understanding model (‑S‑Und /‑B‑Und) | End‑to‑end document‑question‑answering (DocVQA, InfoVQA, ChartQA, …). | ~1.7‑1.8 B params |
All models support 17 languages (Latin + non‑Latin scripts) and have been benchmarked on MDPBench, DocVQA, OCRBench, Union14M, etc.
How to get started
- Create a conda env (Python 3.11) and install the required libraries – PyTorch 2.8,
transformers,accelerate,flash‑attn,vllm(for fast inference) andmodelscope(optional). - Download weights with the provided
download_model.pyscript, choosing a model name (e.g.,MonkeyOCRv2-B). - Vision encoder – run
vision/extract_feature.py(orextract_feature_vitae.pyfor the AS variant) to obtain image embeddings. - Document parsing – start a vLLM server (
parsing/serve.py) and callparsing/parse.py(CLI) or use the supplied Gradio/FastAPI demos to send PDFs or images and receive Markdown layouts. - Document understanding – similarly launch
understanding/serve.pyand rununderstanding/infer.pywith a natural‑language question.
Special notes
- CPU support – as of 2026‑08‑22 the parsing service can run on CPU (see
docs/cpu_support.md). - DFlash acceleration – vLLM 0.25.1 + CUDA 12.9+ enables up to 2× faster inference for the B‑Parsing model.
- MonkeyDoc v2 dataset – a 113 M image‑text pair corpus (≈10 TB after download) released for pre‑training document models.
Where to find the models
- Hugging Face collections:
zenosai/MonkeyOCRv2‑* - ModelScope equivalents:
zenosai/MonkeyOCRv2‑* - Demo UI: http://vlrlabmonkey.xyz:8891/
Typical use‑case example (Python)
from transformers import AutoModel
# Load the vision backbone
encoder = AutoModel.from_pretrained(
"zenosai/MonkeyOCRv2-B",
trust_remote_code=True,
dtype="auto",
device_map="auto",
)
Why it matters – By providing a single, document‑native visual encoder and high‑performing multilingual parsing/understanding heads, MonkeyOCRv2 lets researchers and developers build OCR pipelines that work out‑of‑the‑box on scanned PDFs, photos, scientific papers, historical documents, and even remote‑sensing reports without stitching together separate detection, recognition, and layout models.
Related
- Project
- Dispatch
- Project
- Dispatch
- Project