baidu/Qianfan-OCR
- License
- apache-2.0
- Size
- not mirrored yet
No official torrent yet — requesting it tells the flock what to host next. You cannot seed a catalog-only page.
Cataloged from baidu/Qianfan-OCR
All models by baidu →No official torrent yet — requesting it tells the flock what to host next. You cannot seed a catalog-only page.
Cataloged from baidu/Qianfan-OCR
All models by baidu →🤖 Demo | 📄 Technical Report | 🖥️ Qianfan Platform | 💻 GitHub | 🧩 Skill
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.
⟨think⟩ tokensQianfan-OCR adopts the multimodal bridging architecture from Qianfan-VL, consisting of three core components:
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:
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.
💡 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.
All benchmarks on a single NVIDIA A100 GPU with vLLM 0.10.2.
Qianfan-OCR supports a comprehensive set of document intelligence tasks through prompt-driven control:
Enable thinking mode by passing enable_thinking=True to apply_chat_template. The model will first generate structured layout analysis (bounding boxes, element types, reading order), then produce the final output.
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:
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.
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.
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.
from transformers import AutoModelForImageTextToText, AutoProcessorimport torchfrom 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)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 inferencevllm serve baidu/Qianfan-OCR --trust-remote-code --hf-overrides '{"architectures": ["InternVLChatModel"]}'@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},}