Interfaze

logo

Beta

pricing

docs

blog

sign in

Qianfan OCR

Qianfan OCR by baidu, a image-text-to-text model with OCR, multimodal capabilities. Understand and compare OCR, multimodal features, benchmarks, and capabilities.

Comparison

FeatureQianfan OCRInterfaze
Input Modalities

image, document

image, text, audio, video, document

Native OCRYesYes
Long Document ProcessingNoYes
Language Support

192 partial

162+

Native Speech-to-TextNoYes
Native Object DetectionNoYes
Guardrail ControlsNoYes
Context Input Size

32K

1M

Tool CallingNo

Tool calling supported + built in browser, code execution and web search

OCR Capabilities

FeatureQianfan OCRInterfaze
Text Bounding BoxesPartialYes
Confidence ScoresNoYes
Dense Image ProcessingYesYes
Low Quality ImagesNoYes
Handwritten TextPartialYes
Charts, Tables & EquationsPartialYes

Scaling

FeatureQianfan OCRInterfaze
Scaling

Self-hosted/Provider-hosted with quantization

Unlimited

View model card on Hugging Face

🤖 Demo | 📄 Technical Report | 🖥️ Qianfan Platform | 💻 GitHub | 🧩 Skill

Introduction

Qianfan-OCR is a 4B-parameter end-to-end document intelligence model developed by the Baidu Qianfan Team. It unifies document parsing, layout analysis, and document understanding within a single vision-language architecture.

Unlike traditional multi-stage OCR pipelines that chain separate layout detection, text recognition, and language comprehension modules, Qianfan-OCR performs direct image-to-Markdown conversion and supports a broad range of prompt-driven tasks — from structured document parsing and table extraction to chart understanding, document question answering, and key information extraction — all within one model.

Key Highlights

  • 🏆 #1 End-to-End Model on OmniDocBench v1.5 — Achieves 93.12 overall score, surpassing DeepSeek-OCR-v2 (91.09), Gemini-3 Pro (90.33), and all other end-to-end models
  • 🏆 #1 End-to-End Model on OlmOCR Bench — Scores 79.8
  • 🏆 #1 on Key Information Extraction — Overall mean score of 87.9 across five public KIE benchmarks, surpassing Gemini-3.1-Pro, Gemini-3-Pro, Seed-2.0, and Qwen3-VL-235B-A22B
  • 🧠 Layout-as-Thought — An innovative optional thinking phase that recovers explicit layout analysis within the end-to-end paradigm via ⟨think⟩ tokens
  • 🌍 192 Languages — Multilingual OCR support across diverse scripts
  • Efficient Deployment — Achieves 1.024 PPS (pages per second) with W8A8 quantization on a single A100 GPU

Architecture

Qianfan-OCR adopts the multimodal bridging architecture from Qianfan-VL, consisting of three core components:

ComponentDetails
Vision EncoderQianfan-ViT, 24 Transformer layers, AnyResolution design (up to 4K), 256 visual tokens per 448×448 tile, max 4,096 tokens per image
Language ModelQwen3-4B (3.6B non-embedding), 36 layers, 2560 hidden dim, GQA (32 query / 8 KV heads), 32K context (extendable to 131K)
Cross-Modal Adapter2-layer MLP with GELU activation, projecting from 1024-dim to 2560-dim

Layout-as-Thought

A key innovation is Layout-as-Thought: an optional thinking phase triggered by ⟨think⟩ tokens, where the model generates structured layout representations (bounding boxes, element types, reading order) before producing final outputs.

This mechanism serves two purposes:

  1. Functional: Recovers layout analysis capability within the end-to-end paradigm — users obtain structured layout results directly
  2. Enhancement: Provides targeted accuracy improvements on documents with complex layouts, cluttered elements, or non-standard reading orders

When to use: Enable thinking for heterogeneous pages with mixed element types (exam papers, technical reports, newspapers). Disable for homogeneous documents (single-column text, simple forms) for better results and lower latency.

Benchmark Results

OmniDocBench v1.5 (Document Parsing)

ModelTypeOverall ↑TextEdit ↓FormulaCDM ↑TableTEDs ↑TableTEDss ↑R-orderEdit ↓
Qianfan-OCR (Ours)End-to-end93.120.04192.4391.0293.850.049
DeepSeek-OCR-v2End-to-end91.090.04890.3187.7592.060.057
Gemini-3 ProEnd-to-end90.330.06589.1888.2890.290.071
Qwen3-VL-235BEnd-to-end89.150.06988.1486.2190.550.068
dots.ocrEnd-to-end88.410.04883.2286.7890.620.053
PaddleOCR-VL 1.5Pipeline94.500.03594.2192.7695.790.042

General OCR Benchmarks

ModelOCRBenchOCRBenchv2 (en/zh)CCOCR-multilanCCOCR-overall
Qianfan-OCR (Ours)88056.0 / 60.7776.779.3
Qwen3-VL-4B87360.68 / 59.1374.276.5
MonkeyOCR65521.78 / 38.9143.835.2
DeepSeek-OCR45915.98 / 38.3132.527.6

Document Understanding

BenchmarkQianfan-OCRQwen3-VL-4BQwen3-VL-2B
DocVQA92.894.992.7
CharXiv_DQ94.081.869.7
CharXiv_RQ85.248.541.3
ChartQA88.183.378.3
ChartQAPro42.936.224.5
ChartBench85.974.973.2
TextVQA80.081.879.9
OCRVQA66.864.759.3

💡 Two-stage OCR+LLM systems score 0.0 on CharXiv (both DQ and RQ), demonstrating that chart structures discarded during text extraction are essential for reasoning.

Key Information Extraction (KIE)

ModelOverallOCRBench KIEOCRBenchv2 KIE (en)OCRBenchv2 KIE (zh)CCOCR KIENanonets KIE (F1)
Qianfan-OCR (Ours)87.995.082.882.392.886.5
Qwen3-VL-235B-A22B84.294.085.662.995.183.8
Qwen3-4B-VL83.589.082.171.391.683.3
Gemini-3.1-Pro79.296.087.863.472.576.1

Inference Throughput

ModelPPS (pages/sec)
Qianfan-OCR (W8A8)1.024
Qianfan-OCR (W16A16)0.503
MinerU 2.51.057
MonkeyOCR-pro-1.2B0.673
Dots OCR0.352

All benchmarks on a single NVIDIA A100 GPU with vLLM 0.10.2.

Supported Tasks

Qianfan-OCR supports a comprehensive set of document intelligence tasks through prompt-driven control:

Task CategorySpecific Tasks
Document ParsingImage-to-Markdown conversion, multi-page parsing, structured output (JSON/HTML)
Layout AnalysisBounding box detection, element type classification (25 categories), reading order
Table RecognitionComplex table extraction (merged cells, rotated tables), HTML output
Formula RecognitionInline and display math formulas, LaTeX output
Chart UnderstandingChart QA, trend analysis, data extraction from various chart types
Key Information ExtractionReceipts, invoices, certificates, medical records, ID cards
Handwriting RecognitionChinese and English handwritten text
Scene Text RecognitionStreet signs, product labels, natural scene text
Multilingual OCR192 languages including Latin, Cyrillic, Arabic, South/Southeast Asian, CJK scripts

Quick Start

Basic Usage

import torch
import torchvision.transforms as T
from torchvision.transforms.functional import InterpolationMode
from transformers import AutoModel, AutoTokenizer
from PIL import Image

IMAGENET_MEAN = (0.485, 0.456, 0.406)
IMAGENET_STD = (0.229, 0.224, 0.225)

def build_transform(input_size):
    MEAN, STD = IMAGENET_MEAN, IMAGENET_STD
    transform = T.Compose([
        T.Lambda(lambda img: img.convert('RGB') if img.mode != 'RGB' else img),
        T.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC),
        T.ToTensor(),
        T.Normalize(mean=MEAN, std=STD)
    ])
    return transform

def find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_size):
    best_ratio_diff = float('inf')
    best_ratio = (1, 1)
    area = width * height
    for ratio in target_ratios:
        target_aspect_ratio = ratio[0] / ratio[1]
        ratio_diff = abs(aspect_ratio - target_aspect_ratio)
        if ratio_diff < best_ratio_diff:
            best_ratio_diff = ratio_diff
            best_ratio = ratio
        elif ratio_diff == best_ratio_diff:
            if area > 0.5 * image_size * image_size * ratio[0] * ratio[1]:
                best_ratio = ratio
    return best_ratio

def dynamic_preprocess(image, min_num=1, max_num=12, image_size=448, use_thumbnail=False):
    orig_width, orig_height = image.size
    aspect_ratio = orig_width / orig_height

    # calculate the existing image aspect ratio
    target_ratios = set(
        (i, j) for n in range(min_num, max_num + 1) for i in range(1, n + 1) for j in range(1, n + 1) if
        i * j <= max_num and i * j >= min_num)
    target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])

    # find the closest aspect ratio to the target
    target_aspect_ratio = find_closest_aspect_ratio(
        aspect_ratio, target_ratios, orig_width, orig_height, image_size)

    # calculate the target width and height
    target_width = image_size * target_aspect_ratio[0]
    target_height = image_size * target_aspect_ratio[1]
    blocks = target_aspect_ratio[0] * target_aspect_ratio[1]

    # resize the image
    resized_img = image.resize((target_width, target_height))
    processed_images = []
    for i in range(blocks):
        box = (
            (i % (target_width // image_size)) * image_size,
            (i // (target_width // image_size)) * image_size,
            ((i % (target_width // image_size)) + 1) * image_size,
            ((i // (target_width // image_size)) + 1) * image_size
        )
        # split the image
        split_img = resized_img.crop(box)
        processed_images.append(split_img)
    assert len(processed_images) == blocks
    if use_thumbnail and len(processed_images) != 1:
        thumbnail_img = image.resize((image_size, image_size))
        processed_images.append(thumbnail_img)
    return processed_images

def load_image(image_file, input_size=448, max_num=12):
    image = Image.open(image_file).convert('RGB')
    transform = build_transform(input_size=input_size)
    images = dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num)
    pixel_values = [transform(image) for image in images]
    pixel_values = torch.stack(pixel_values)
    return pixel_values


MODEL_PATH = "baidu/Qianfan-OCR"
model = AutoModel.from_pretrained(
    MODEL_PATH,
    torch_dtype=torch.bfloat16,
    trust_remote_code=True,
    device_map="auto"
).eval()
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH, trust_remote_code=True)


pixel_values = load_image("./Qianfan-OCR/examples/document.png").to(torch.bfloat16).to(model.device)


prompt = "Parse this document to Markdown."
with torch.no_grad():
    response = model.chat(
        tokenizer,
        pixel_values=pixel_values,
        question=prompt,
        generation_config={"max_new_tokens": 16384}
    )
print(response)

With Layout-as-Thought (Thinking Mode)



pixel_values = load_image("./Qianfan-OCR/examples/complex_document.jpg").to(torch.bfloat16)
prompt = "Parse this document to Markdown.<think>"
with torch.no_grad():
    response = model.chat(
        tokenizer,
        pixel_values=pixel_values,
        question=prompt,
        generation_config={"max_new_tokens": 16384}
    )
print(response)


Key Information Extraction

pixel_values = load_image("./Qianfan-OCR/examples/invoice.jpg").to(torch.bfloat16)
prompt = "请从图片中提取以下字段信息:姓名、日期、总金额。使用标准JSON格式输出。"
with torch.no_grad():
    response = model.chat(
        tokenizer,
        pixel_values=pixel_values,
        question=prompt,
        generation_config={"max_new_tokens": 16384}
    )
print(response)

vLLM Deployment


vllm serve baidu/Qianfan-OCR --trust-remote-code

Skill

We provide a Qianfan OCR Document Intelligence skill for image and PDF understanding workflows.

It can be used by users of OpenClaw, Claude Code, Codex, and other assistants that support this skill format. This skill packages reusable instructions, scripts, and references so the agent can automatically apply Qianfan-powered document intelligence to tasks such as:

  • document parsing to Markdown
  • layout analysis
  • element recognition
  • general OCR
  • key information extraction
  • chart understanding
  • document VQA

The skill is designed for visual understanding tasks over images and PDFs, and includes the execution flow needed to prepare inputs, choose the right analysis mode, and call the bundled CLI tools.

Citation

@misc{dong2026qianfanocrunifiedendtoendmodel,
  title={Qianfan-OCR: A Unified End-to-End Model for Document Intelligence},
  author={Daxiang Dong and Mingming Zheng and Dong Xu and Chunhua Luo and Bairong Zhuang and Yuxuan Li and Ruoyun He and Haoran Wang and Wenyu Zhang and Wenbo Wang and Yicheng Wang and Xue Xiong and Ayong Zheng and Xiaoying Zuo and Ziwei Ou and Jingnan Gu and Quanhao Guo and Jianmin Wu and Dawei Yin and Dou Shen},
  year={2026},
  eprint={2603.13398},
  archivePrefix={arXiv},
  primaryClass={cs.CV},
  url={https://arxiv.org/abs/2603.13398},
}

Acknowledgments

We thank the Baidu AI Cloud team for infrastructure support, the Baige and Kunlun teams for AI infrastructure assistance, and all contributors to the Qianfan platform.

License

This project is licensed under the Apache License 2.0. See LICENSE for the full license text.

Some bundled third-party source files are licensed under the MIT License. See NOTICE for the file list and corresponding attribution details.

Want more deterministic results?