Qianfan-OCR 是由百度千帆团队开发的40亿参数端到端文档智能模型。它在单一视觉语言架构内统一了文档解析、版面分析和文档理解功能。
不同于传统多阶段OCR流水线将独立的版面检测、文字识别和语言理解模块串联,Qianfan-OCR实现直接图像到Markdown转换,并支持广泛的提示驱动任务——从结构化文档解析、表格提取到图表理解、文档问答和关键信息抽取——全部在一个模型内完成。
⟨think⟩标记在端到端范式内恢复显式版面分析Qianfan-OCR采用源自Qianfan-VL的多模态桥接架构,包含三个核心组件:
| 组件 | 详情 |
|---|---|
| 视觉编码器 | Qianfan-ViT,24层Transformer,AnyResolution设计(最高4K),每448×448区块256个视觉标记,单图像最多4,096个标记 |
| 语言模型 | Qwen3-4B(36亿非嵌入参数),36层,2560隐藏维度,GQA(32查询头/8键值头),32K上下文长度(可扩展至131K) |
| 跨模态适配器 | 2层MLP带GELU激活函数,从1024维度投影至2560维度 |
一项关键创新是布局即思维(Layout-as-Thought):这是一个由⟨think⟩标记触发的可选思考阶段,在此阶段,模型会在生成最终输出之前,先生成结构化的布局表示(边界框、元素类型、阅读顺序)。
该机制有两个目的:
使用时机:对于包含混合元素类型的异构页面(如试卷、技术报告、报纸),启用思考阶段。对于同构文档(如单栏文本、简单表单),禁用思考阶段以获得更好的结果和更低的延迟。
| 模型 | 类型 | Overall ↑ | TextEdit ↓ | FormulaCDM ↑ | TableTEDs ↑ | TableTEDss ↑ | R-orderEdit ↓ |
|---|---|---|---|---|---|---|---|
| Qianfan-OCR(我们的模型) | 端到端 | 93.12 | 0.041 | 92.43 | 91.02 | 93.85 | 0.049 |
| DeepSeek-OCR-v2 | 端到端 | 91.09 | 0.048 | 90.31 | 87.75 | 92.06 | 0.057 |
| Gemini-3 Pro | 端到端 | 90.33 | 0.065 | 89.18 | 88.28 | 90.29 | 0.071 |
| Qwen3-VL-235B | 端到端 | 89.15 | 0.069 | 88.14 | 86.21 | 90.55 | 0.068 |
| dots.ocr | 端到端 | 88.41 | 0.048 | 83.22 | 86.78 | 90.62 | 0.053 |
| PaddleOCR-VL 1.5 | 流水线 | 94.50 | 0.035 | 94.21 | 92.76 | 95.79 | 0.042 |
| 模型 | OCRBench | OCRBenchv2 (en/zh) | CCOCR-multilan | CCOCR-overall |
|---|---|---|---|---|
| Qianfan-OCR(我们的模型) | 880 | 56.0 / 60.77 | 76.7 | 79.3 |
| Qwen3-VL-4B | 873 | 60.68 / 59.13 | 74.2 | 76.5 |
| MonkeyOCR | 655 | 21.78 / 38.91 | 43.8 | 35.2 |
| DeepSeek-OCR | 459 | 15.98 / 38.31 | 32.5 | 27.6 |
| 基准测试 | Qianfan-OCR | Qwen3-VL-4B | Qwen3-VL-2B |
|---|---|---|---|
| DocVQA | 92.8 | 94.9 | 92.7 |
| CharXiv_DQ | 94.0 | 81.8 | 69.7 |
| CharXiv_RQ | 85.2 | 48.5 | 41.3 |
| ChartQA | 88.1 | 83.3 | 78.3 |
| ChartQAPro | 42.9 | 36.2 | 24.5 |
| ChartBench | 85.9 | 74.9 | 73.2 |
| TextVQA | 80.0 | 81.8 | 79.9 |
| OCRVQA | 66.8 | 64.7 | 59.3 |
💡 两阶段OCR+LLM系统在CharXiv(DQ和RQ)上的得分均为0.0,这表明在文本提取过程中丢弃的图表结构对于推理至关重要。
| 模型 | 总体得分 | OCRBench KIE | OCRBenchv2 KIE(英文) | OCRBenchv2 KIE(中文) | CCOCR KIE | Nanonets KIE(F1) |
|---|---|---|---|---|---|---|
| Qianfan-OCR(我方) | 87.9 | 95.0 | 82.8 | 82.3 | 92.8 | 86.5 |
| Qwen3-VL-235B-A22B | 84.2 | 94.0 | 85.6 | 62.9 | 95.1 | 83.8 |
| Qwen3-4B-VL | 83.5 | 89.0 | 82.1 | 71.3 | 91.6 | 83.3 |
| Gemini-3.1-Pro | 79.2 | 96.0 | 87.8 | 63.4 | 72.5 | 76.1 |
| 模型 | 页数/秒(PPS) |
|---|---|
| Qianfan-OCR(W8A8) | 1.024 |
| Qianfan-OCR(W16A16) | 0.503 |
| MinerU 2.5 | 1.057 |
| MonkeyOCR-pro-1.2B | 0.673 |
| Dots OCR | 0.352 |
所有基准测试均在单张 NVIDIA A100 GPU 上使用 vLLM 0.10.2 进行。
Qianfan-OCR 通过提示驱动控制,支持一系列全面的文档智能任务:
| 任务类别 | 具体任务 |
|---|---|
| 文档解析 | 图片转 Markdown 转换、多页解析、结构化输出(JSON/HTML) |
| 版面分析 | 边界框检测、元素类型分类(25 类)、阅读顺序 |
| 表格识别 | 复杂表格提取(合并单元格、旋转表格)、HTML 输出 |
| 公式识别 | 行内及独立数学公式、LaTeX 输出 |
| 图表理解 | 图表问答、趋势分析、多种图表类型数据提取 |
| 关键信息抽取 | 收据、发票、证书、医疗记录、身份证 |
| 手写识别 | 中英文手写文本 |
| 场景文本识别 | 街道标识、产品标签、自然场景文本 |
| 多语言 OCR | 192 种语言,包括拉丁语、西里尔语、阿拉伯语、南亚/东南亚语言、中日韩文字 |
from transformers import AutoModelForImageTextToText, AutoProcessor
import torch
from PIL import Image
MODEL_PATH = "baidu/Qianfan-OCR"
model = AutoModelForImageTextToText.from_pretrained(
MODEL_PATH,
torch_dtype=torch.bfloat16,
device_map="auto",
).eval()
processor = AutoProcessor.from_pretrained(MODEL_PATH)
image = Image.open("./examples/document.png").convert("RGB")
prompt = "Parse this document to Markdown."
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": prompt},
],
},
]
inputs = processor.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
with torch.no_grad():
output_ids = model.generate(
**inputs,
max_new_tokens=512,
do_sample=False,
)
generated_ids = output_ids[:, inputs["input_ids"].shape[1]:]
response = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)通过向 apply_chat_template 传入 enable_thinking=True 来启用思维模式。模型将首先生成结构化的版式分析结果(包括边界框、元素类型、阅读顺序),然后生成最终输出。
image = Image.open("./examples/complex_document.jpg").convert("RGB")
prompt = "Parse this document to Markdown."
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": prompt},
],
},
]
inputs = processor.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
enable_thinking=True,
).to(model.device)
with torch.no_grad():
output_ids = model.generate(
**inputs,
max_new_tokens=16384,
do_sample=False,
)
generated_ids = output_ids[:, inputs["input_ids"].shape[1]:]
response = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)image = Image.open("./examples/invoice.jpg").convert("RGB")
prompt = "请从图片中提取以下字段信息:姓名、日期、总金额。使用标准JSON格式输出。"
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": prompt},
],
},
]
inputs = processor.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
with torch.no_grad():
output_ids = model.generate(
**inputs,
max_new_tokens=16384,
do_sample=False,
)
generated_ids = output_ids[:, inputs["input_ids"].shape[1]:]
response = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)# Serve with vLLM for high-throughput inference
vllm serve baidu/Qianfan-OCR --trust-remote-code --hf-overrides '{"architectures": ["InternVLChatModel"]}'我们为图像和PDF理解工作流提供了Qianfan OCR Document Intelligence技能。
OpenClaw、Claude Code、Codex等支持该技能格式的助手用户均可使用。 该技能封装了可复用的指令、脚本和参考资料,使智能体能够自动将基于Qianfan的文档智能应用于以下任务:
该技能专为图像和PDF的视觉理解任务设计,包含准备输入、选择合适分析模式以及调用捆绑CLI工具所需的执行流程。
@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},
}感谢百度智能云团队提供的基础设施支持,感谢百舸和昆仑团队在AI基础设施方面的协助,以及所有为Qianfan平台做出贡献的人员。
本项目采用Apache License 2.0许可协议。完整的许可文本详见LICENSE文件。
部分捆绑的第三方源文件采用MIT License许可协议。文件列表及相应的归属信息详见NOTICE文件。