HuggingFace镜像/dots.mocr
模型介绍文件和版本分析
下载使用量0

dots.mocr

HuggingFace GitHub arXiv

🖥️ 在线演示 | 💬 微信交流 | 📕 小红书 | 🐦 X平台

简介

我们推出了dots.mocr。该模型在同等规模模型中不仅在标准多语言文档解析任务上达到了最先进(SOTA)性能,更能将结构化图形(如图表、UI布局、科学图表等)直接转换为SVG代码。其核心功能包括图像定位、识别、语义理解和交互式对话。

同时,我们还发布了dots.mocr-svg,这是一个专门针对稳健图像转SVG解析任务优化的变体模型。

更多信息详见论文。

评估

1. 文档解析

1.1 最新模型在不同基准上的Elo评分

模型olmOCR-BenchOmniDocBench (v1.5)XDocParse平均值
MonkeyOCR-pro-3B895.0811.3637.1781.1
GLM-OCR884.2972.6820.7892.5
PaddleOCR-VL-1.5897.3997.9866.4920.5
HuanyuanOCR997.61003.9951.1984.2
dots.ocr1041.11027.21190.31086.2
dots.mocr1104.41059.01210.71124.7
Gemini 3 Pro1180.41128.01323.71210.7

注:

  • Gemini 3 Pro、PaddleOCR-VL-1.5和GLM-OCR的结果通过API获取,HuanyuanOCR的结果通过本地推理生成。
  • Elo评分评估使用Gemini 3 Flash进行。提示词可参见:Elo评分提示词。这些结果与ocrarena上的发现一致。

1.2 olmOCR-bench

模型ArXiv旧扫描件数学公式表格旧扫描件页眉页脚多列长文本小字基础总体
Mistral OCR API77.267.560.629.393.671.377.199.472.0±1.1
Marker 1.10.183.866.872.933.586.680.085.799.376.1±1.1
MinerU 2.5.4*76.654.684.933.796.678.283.593.775.2±1.1
DeepSeek-OCR77.273.680.233.396.166.479.499.875.7±1.0
Nanonets-OCR2-3B75.446.186.840.932.181.993.099.669.5±1.1
PaddleOCR-VL*85.771.084.137.897.079.985.798.580.0±1.0
Infinity-Parser 7B*84.483.885.047.988.784.286.499.882.5±?
olmOCR v0.4.083.082.384.947.796.183.781.999.782.4±1.1
Chandra OCR 0.1.0*82.280.388.050.490.881.292.399.983.1±0.9
dots.ocr82.164.288.340.994.182.481.299.579.1±1.0
dots.mocr85.985.590.748.294.085.381.699.783.9±0.9

注:

  • 指标来源于olmocr及我们内部评估。
  • 我们删除了结果markdown中的页眉和页脚单元格。

1.3 其他基准测试

模型类型方法规模OmniDocBench(v1.5)
文本编辑距离↓
OmniDocBench(v1.5)
阅读顺序编辑距离↓
pdf-parse-bench
通用视觉语言模型Gemini-2.5 Pro-0.0750.0979.06
Qwen3-VL-235B-A22B-Instruct235B0.0690.0689.71
gemini3pro-0.0660.0799.68
专用视觉语言模型Mistral OCR-0.1640.1448.84
Deepseek-OCR3B0.0730.0868.26
MonkeyOCR-3B3B0.0750.1299.27
OCRVerse4B0.0580.071--
MonkeyOCR-pro-3B3B0.0750.128-
MinerU2.51.2B0.0470.044-
PaddleOCR-VL0.9B0.0350.0439.51
HunyuanOCR0.9B0.042--
PaddleOCR-VL1.50.9B0.0350.042-
GLMOCR0.9B0.040.043-
dots.ocr3B0.0480.0539.29
dots.mocr3B0.0310.0299.54

注:

  • 指标来源于OmniDocBench和其他模型发布资料。pdf-parse-bench结果由Qwen3-VL-235B-A22B-Instruct复现。
  • 由于OmniDocBench1.5的公式和表格指标对检测和匹配协议高度敏感,故省略。

2. 结构化图形解析

视觉语言(如图表、图形、化学公式、徽标)封装了密集的人类知识。dots.mocr 通过将这些元素直接解析为 SVG 代码,实现了对它们的统一解读。

方法UnisvgChartmimicDesign2CodeGenexamSciGenChemDraw
Low-LevelHigh-LevelScore
OCRVerse0.6320.8520.7630.799---0.881
Gemini 3 Pro0.5630.8500.7350.7880.7600.7560.7830.839
dots.mocr0.8500.9230.8940.7720.8010.6640.6600.790
dots.mocr-svg0.8600.9310.9020.9050.8340.80.7970.901

注意:

  • 我们使用 UniSVG 中的 ISVGEN 指标来评估解析结果。对于本身不支持图像解析的基准测试,我们将原始图像作为输入,并计算渲染输出与原始图像之间的 ISVGEN 分数。
  • OCRVerse 的结果来自多种代码格式(如 SVG、Python),而 Gemini 3 Pro 和 dots.mocr 的结果则专门基于 SVG 代码。
  • 由于 3B 参数 VLM 的能力限制,dots.mocr 在某些任务(如 svg)上可能尚未表现出色。为了弥补这一点,我们同时发布了 dots.mocr-svg。我们计划在未来的更新中进一步解决这些局限性。

3. 通用视觉任务

模型CharXiv_descriptiveCharXiv_reasoningOCR_ReasoninginfovqadocvqaChartQAOCRBenchAI2DCountBenchQArefcoco
Qwen3vl-2b-instruct62.326.8-72.493.3-85.876.988.4-
Qwen3vl-4b-instruct76.239.7-80.395.3-88.184.184.9-
dots.mocr77.455.322.8573.7691.8583.286.082.1694.4680.03

快速开始

1. 安装

安装 dots.mocr

conda create -n dots_mocr python=3.12
conda activate dots_mocr

git clone https://github.com/rednote-hilab/dots.mocr.git
cd dots.mocr

# Install pytorch, see https://pytorch.org/get-started/previous-versions/ for your cuda version
# pip install torch==2.7.0 torchvision==0.22.0 torchaudio==2.7.0 --index-url https://download.pytorch.org/whl/cu128
# install flash-attn==2.8.0.post2 for faster inference
pip install -e .

如果您在安装过程中遇到问题,可以尝试使用我们的 Docker 镜像 来简化设置,请按照以下步骤操作:

下载模型权重

💡注意: 请使用不含句点的目录名称(例如 DotsMOCR,而非 dots.mocr)作为模型保存路径。这是在我们与 Transformers 集成完成前的临时解决方法。

python3 tools/download_model.py

# with modelscope
python3 tools/download_model.py --type modelscope

2. 部署

vLLM 推理

我们强烈建议使用 vLLM 进行部署和推理。自 vLLM 0.11.0 版本起,Dots OCR 已正式集成到 vLLM 中,且性能经过验证,您可以直接使用 vLLM Docker 镜像(例如 vllm/vllm-openai:v0.11.0)来部署模型服务器。

# Launch vLLM model server
## dots.mocr
CUDA_VISIBLE_DEVICES=0 vllm serve rednote-hilab/dots.mocr --tensor-parallel-size 1 --gpu-memory-utilization 0.9 --chat-template-content-format string --served-model-name model --trust-remote-code

## dots.mocr-svg
CUDA_VISIBLE_DEVICES=0 vllm serve rednote-hilab/dots.mocr-svg --tensor-parallel-size 1 --gpu-memory-utilization 0.9 --chat-template-content-format string --served-model-name model --trust-remote-code

# vLLM API Demo
# See dots_mocr/model/inference.py and dots_mocr/utils/prompts.py for details on parameter and prompt settings 
# that help achieve the best output quality.
## document parsing
python3 ./demo/demo_vllm.py --prompt_mode prompt_layout_all_en 
## web parsing 
python3 ./demo/demo_vllm.py --prompt_mode prompt_web_parsing --image_path ./assets/showcase/origin/webpage_1.png
## scene spoting
python3 ./demo/demo_vllm.py --prompt_mode prompt_scene_spotting --image_path ./assets/showcase/origin/scene_1.jpg
## image parsing with svg code
python3 ./demo/demo_vllm_svg.py --prompt_mode prompt_image_to_svg 
## general qa
python3 ./demo/demo_vllm_general.py

Hugginface 推理

python3 demo/demo_hf.py
Hugginface 推理详情
import torch
from transformers import AutoModelForCausalLM, AutoProcessor, AutoTokenizer
from qwen_vl_utils import process_vision_info
from dots_mocr.utils import dict_promptmode_to_prompt

model_path = "./weights/DotsMOCR"
model = AutoModelForCausalLM.from_pretrained(
    model_path,
    attn_implementation="flash_attention_2",
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True
)
processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True)

image_path = "demo/demo_image1.jpg"
prompt = """Please output the layout information from the PDF image, including each layout element's bbox, its category, and the corresponding text content within the bbox.

1. Bbox format: [x1, y1, x2, y2]

2. Layout Categories: The possible categories are ['Caption', 'Footnote', 'Formula', 'List-item', 'Page-footer', 'Page-header', 'Picture', 'Section-header', 'Table', 'Text', 'Title'].

3. Text Extraction & Formatting Rules:
    - Picture: For the 'Picture' category, the text field should be omitted.
    - Formula: Format its text as LaTeX.
    - Table: Format its text as HTML.
    - All Others (Text, Title, etc.): Format their text as Markdown.

4. Constraints:
    - The output text must be the original text from the image, with no translation.
    - All layout elements must be sorted according to human reading order.

5. Final Output: The entire output must be a single JSON object.
"""

messages = [
        {
            "role": "user",
            "content": [
                {
                    "type": "image",
                    "image": image_path
                },
                {"type": "text", "text": prompt}
            ]
        }
    ]

# Preparation for inference
text = processor.apply_chat_template(
    messages, 
    tokenize=False, 
    add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
    text=[text],
    images=image_inputs,
    videos=video_inputs,
    padding=True,
    return_tensors="pt",
)

inputs = inputs.to("cuda")

# Inference: Generation of the output
generated_ids = model.generate(**inputs, max_new_tokens=24000)
generated_ids_trimmed = [
    out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
    generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)

使用 CPU 进行 Hugging Face 推理

请参考 CPU 推理

3. 文档解析

基于 vLLM 服务器,您可以使用以下命令解析图像或 PDF 文件:


# Parse all layout info, both detection and recognition
# Parse a single image
python3 dots_mocr/parser.py demo/demo_image1.jpg
# Parse a single PDF
python3 dots_mocr/parser.py demo/demo_pdf1.pdf  --num_thread 64  # try bigger num_threads for pdf with a large number of pages

# Layout detection only
python3 dots_mocr/parser.py demo/demo_image1.jpg --prompt prompt_layout_only_en

# Parse text only, except Page-header and Page-footer
python3 dots_mocr/parser.py demo/demo_image1.jpg --prompt prompt_ocr

基于 Transformers,您可以使用上述相同的命令解析图像或 PDF 文件,只需添加 --use_hf true。

注意:transformers 比 vllm 速度慢,如果您想使用 demo/* 搭配 transformers,只需在 DotsMOCRParser(..,use_hf=True) 中添加 use_hf=True

输出结果
  1. 结构化布局数据 (demo_image1.json): 一个包含检测到的布局元素的 JSON 文件,包括它们的边界框、类别和提取的文本。
  2. 处理后的 Markdown 文件 (demo_image1.md): 由所有检测到的单元格文本拼接生成的 Markdown 文件。
    • 还提供了另一个版本 demo_image1_nohf.md,该版本排除了页眉和页脚,以兼容 Omnidocbench 和 olmOCR-bench 等基准测试。
  3. 布局可视化 (demo_image1.jpg): 原始图像上绘制了检测到的布局边界框。

4. 演示

欢迎体验 在线演示。

文档解析示例

formula1.png table3.png Tibetan.png tradition_zh.png nl.png kannada.png russian.png

图像解析示例

svg_1.png svg_2.png svg_4.png svg_5.png svg_6.png

注意:

  • 由 dots.mocr-svg 推理生成

网页解析示例

webpage_1.png webpage_2.png

场景识别示例

scene_1.png scene_2.png

局限性与未来工作

  • 复杂文档元素:

    • 表格与公式:受限于模型的紧凑架构,复杂表格和数学公式的提取仍是一项艰巨任务。
    • 图片:我们已采用 SVG 代码表示来解析结构化图形,但性能尚未达到理想的稳健水平。
  • 解析失败:尽管相比上一版本,我们已降低了解析失败的概率,但此类问题仍可能偶有发生。我们将持续致力于在未来的更新中进一步解决这些边缘情况。

引用

@misc{zheng2026multimodalocrparsedocuments,
      title={Multimodal OCR: Parse Anything from Documents}, 
      author={Handong Zheng and Yumeng Li and Kaile Zhang and Liang Xin and Guangwei Zhao and Hao Liu and Jiayu Chen and Jie Lou and Jiyu Qiu and Qi Fu and Rui Yang and Shuo Jiang and Weijian Luo and Weijie Su and Weijun Zhang and Xingyu Zhu and Yabin Li and Yiwei ma and Yu Chen and Zhaohui Yu and Guang Yang and Colin Zhang and Lei Zhang and Yuliang Liu and Xiang Bai},
      year={2026},
      eprint={2603.13032},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2603.13032}, 
}