baidubce/Qianfan-VL

GitHub: baidubce/Qianfan-VL

百度推出的企业级领域增强视觉语言模型系列,深度优化文档理解与 OCR 能力,提供从边缘到云端的多尺寸模型选择。

Stars: 402 | Forks: 29

简体中文 | English

千帆-VL 系列

面向企业的领域增强视觉语言模型
3B 至 70B 参数 | OCR 专家
文档理解与 OCR 增强
支持 Chain-of-Thought

📚 **[使用指南](https://github.com/baidubce/qianfan-models-cookbook)** |
## 简介 **千帆-VL 系列**是一系列领域增强的视觉语言模型,专为需要生产级视觉理解能力的企业用户而构建。该系列对文档解析、OCR 到复杂视觉推理等高频工业部署场景进行了深度优化,同时保留了强大的通用多模态能力。无论是在边缘端还是云端部署,千帆-VL 系列都能提供企业应用所需的视觉智能骨干支持。 ## 🔥 最新动态 - **[2026/03/18] 千帆-OCR 发布!** — 推出 **千帆-OCR**,这是一个 4B 参数的端到端模型,将文档解析、版面分析、表格提取、公式识别、图表理解与关键信息提取(KIE)统一在单一模型中。不再需要串联检测 → 识别 → LLM 的流程。核心创新:**Layout-as-Thought** — 一个可选的 ⟨think⟩ 阶段,模型在生成输出前会推理边界框、元素类型和阅读顺序。可以理解为“文档版面的 CoT”。 - 🏆 **OmniDocBench v1.5:** 93.12 (端到端模型 #1) - 🏆 **OCRBench:** 880 (所有模型总排名第一) - 🏆 **KIE avg:** 87.9 (超越 Gemini-3.1-Pro 与 Qwen3-VL-235B) - ⚡ 单张 A100 上达 **1.024 页/秒** (W8A8) - 🌍 支持 **192 种语言**,涵盖拉丁语系、西里尔语系、阿拉伯语系、南亚语系、东南亚语系及中日韩(CJK)语系 - 使用 1,024 张昆仑 P800 芯片进行训练,分 4 个阶段处理了 2.85T tokens - 📄 [论文](https://arxiv.org/abs/2603.13398) | 🤗 [HuggingFace 合集](https://huggingface.co/collections/baidu/qianfan-vl) | 💻 [GitHub](https://github.com/baidubce/Qianfan-OCR) | [ModelScope](https://modelscope.cn/models/baidu-qianfan/Qianfan-OCR) - **[2025/09/22] 千帆-VL 1.0 发布!** — 推出千帆-VL 模型系列(3B / 8B / 70B),提供覆盖从边缘到云端的多尺寸版本,增强了 OCR 及文档理解能力,并为 8B 和 70B 版本提供了 Chain-of-Thought 推理支持。 📄 [技术报告](https://arxiv.org/abs/2603.13398) ## 千帆-VL 1.0 核心特性 ### 🚀 多尺寸模型 提供 3B、8B 和 70B 模型版本,满足从边缘到云端的不同场景需求 ### 📝 OCR 与文档理解增强 - **全场景 OCR 识别**:支持手写体、印刷体、场景文本、公式等 - **复杂版面理解**:表格解析、图表理解、文档结构化能力 - **多语言支持**:中文、英文及多语言文档处理 ### 🧠 Chain-of-Thought 能力 8B 和 70B 模型支持 Chain-of-Thought 能力,在数学和推理计算等复杂场景中表现出色,适用于教学辅助、拍照解题、自动批阅等应用 ## 模型规格 | 模型名称 | 参数量 | 上下文长度 | 支持 CoT | 应用场景 | 模型下载 | |---------|--------|-----------|---------|----------|---------| | **Qianfan-VL-3B** | 3B | 32k | ❌ | 边缘实时场景,OCR 文本识别 | 🤗 **[HuggingFace](https://huggingface.co/baidu/Qianfan-VL-3B)** / 🤖 **[ModelScope](https://modelscope.cn/models/baidu-qianfan/Qianfan-VL-3B)** | | **Qianfan-VL-8B** | 8B | 32k | ✅ | 服务端通用场景,微调优化 | 🤗 **[HuggingFace](https://huggingface.co/baidu/Qianfan-VL-8B)** / 🤖 **[ModelScope](https://modelscope.cn/models/baidu-qianfan/Qianfan-VL-8B)** | | **Qianfan-VL-70B** | 70B | 32k | ✅ | 离线数据合成,复杂推理计算 | 🤗 **[HuggingFace](https://huggingface.co/baidu/Qianfan-VL-70B)** / 🤖 **[ModelScope](https://modelscope.cn/models/baidu-qianfan/Qianfan-VL-70B)** | | **Qianfan-OCR** | 4B | — | ✅ (Layout-as-Thought) | 端到端文档解析、版面分析、表格提取、公式识别、图表理解、KIE | 💻 **[GitHub](https://github.com/baidubce/Qianfan-OCR)** / 🤗 **[HuggingFace](https://huggingface.co/collections/baidu/qianfan-vl)** | ## 技术优势 ### 🚀 多阶段领域增强持续预训练 采用创新的四阶段渐进式训练策略,从跨模态对齐到通用知识注入,再到领域增强知识注入和后训练对齐,在维持通用能力的同时显著提升特定领域能力。通过精心设计的数据配比和训练策略,实现了通用能力与专业能力的良好平衡。 ### 🎯 高精度数据合成 构建多任务数据合成流水线,涵盖文档识别、数学解题、图表理解、表格识别、公式识别和自然场景 OCR 等核心任务。通过将传统 CV 模型与程序化生成方法相结合,借助精细的流水线设计和中间过程数据构建,实现了高质量训练数据的高效生产,显著提升了模型在长尾场景中的泛化能力。 ### ⚡ 大规模昆仑芯片集群并行训练 基于百度自研的昆仑 P800 芯片,通过 5000+ 芯片的超大规模分布式训练系统完成了所有模型规模的训练。采用 3D 并行训练策略与通信计算融合技术,实现了 90%+ 的集群扩展效率,高效处理了 3T tokens 的训练数据,展现了国产 AI 基础设施的成熟能力。 ## 性能指标 ### 通用能力评估 *注:加粗数值表示在所有模型中排名前二* | Benchmark | Qianfan-VL-3B | Qianfan-VL-8B | Qianfan-VL-70B | InternVL3-8B | InternVL3-78B | Qwen2.5-VL-7B | Qwen2.5-VL-72B | |---------|---------------|---------------|----------------|---------------|----------------|---------------|----------------| | **A-Bench_VAL** | 75.65 | 75.72 | **78.1** | 75.86 | 75.86 | 76.49 | **79.22** | | **CCBench** | 66.86 | 70.39 | **80.98** | **77.84** | 70.78 | 57.65 | 73.73 | | **SEEDBench_IMG** | 76.55 | 78.02 | **79.13** | 77.00 | 77.52 | 76.98 | **78.34** | | **SEEDBench2_Plus** | 67.59 | 70.97 | **73.17** | 69.52 | 68.47 | 70.93 | **73.25** | | **ScienceQA_TEST** | 95.19 | **97.62** | **98.76** | 97.97 | 97.17 | 85.47 | 92.51 | | **ScienceQA_VAL** | 93.85 | **97.62** | **98.81** | 97.81 | 95.14 | 83.59 | 91.32 | | **MMT-Bench_VAL** | 62.23 | 63.22 | **71.06** | 65.17 | 63.67 | 61.40 | **69.49** | | **MTVQA_TEST** | 26.5 | 30.14 | **32.18** | 30.30 | 27.62 | 29.08 | **31.48** | | **BLINK** | 49.97 | 56.81 | **59.44** | 55.87 | 51.87 | 54.55 | **63.02** | | **MMStar** | 57.93 | 64.07 | **69.47** | **68.40** | 66.07 | 61.53 | 66.00 | | **POPE** | 85.08 | 86.06 | **88.97** | **90.59** | 88.87 | 85.97 | 83.35 | | **RefCOCO (Avg)** | 85.94 | 89.37 | **91.01** | 89.65 | **91.40** | 86.56 | 90.25 | ### OCR 与文档理解 | Benchmark | Qianfan-VL-3B | Qianfan-VL-8B | Qianfan-VL-70B | InternVL3-8B | InternVL3-78B | Qwen2.5-VL-3B | Qwen2.5-VL-7B | Qwen2.5-VL-72B | |---------|---------------|---------------|----------------|---------------|----------------|---------------|---------------|----------------| | **OCRBench** | 831 | 854 | 873 | **881** | 847 | 810 | **883** | 874 | | **AI2D_TEST** | 81.38 | **85.07** | **87.73** | **85.07** | 83.55 | 77.07 | 80.47 | 83.84 | | **OCRVQA_TEST** | 66.15 | 68.98 | **74.06** | 39.03 | 35.58 | 69.24 | **71.02** | 66.80 | | **TextVQA_VAL** | 80.11 | 82.13 | **84.48** | 82.15 | 83.52 | 79.09 | **84.96** | 83.26 | | **DocVQA_VAL** | 90.85 | 93.54 | 94.75 | 92.04 | 83.82 | 92.71 | **94.91** | **95.75** | | **ChartQA_TEST** | 81.79 | **87.72** | **89.6** | 85.76 | 82.04 | 83.4 | 86.68 | 87.16 | ### 数学推理 | Benchmark | Qianfan-VL-8B | Qianfan-VL-70B | InternVL3-8B | InternVL3-78B | Qwen2.5-VL-7B | Qwen2.5-VL-72B | |---------|---------------|----------------|---------------|----------------|---------------|----------------| | **MathVista-mini** | 69.19 | **78.6** | 69.5 | 71.1 | 69.5 | 70.1 | | **MathVision** | 32.82 | **50.29** | 21.48 | 33.48 | 29.61 | 34.8 | | **MathVerse** | 48.4 | **61.04** | 30.96 | 43.32 | 43.68 | 49.26 | | **ChartQA Pro** | 50.41 | **52** | 19.38 | 47.92 | 37.32 | 44.43 | | **HallusionBench** | 51.72 | **54.52** | 49.7 | 40.5 | 49.2 | 40.2 | | **InHouse Dataset A** | 59.87 | **71.78** | 26 | 43.40 | 40.64 | 41.47 | | **InHouse Dataset B** | 61.33 | **75.6** | 26.81 | 39.7 | 36.25 | 42.65 | ## 快速开始 ### 安装 ``` pip install transformers torch torchvision pillow ``` ### 使用 Transformers ``` 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 MODEL_PATH = "Baidu/Qianfan-VL-8B" # or Qianfan-VL-3B, Qianfan-VL-70B 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) # 加载并处理 image pixel_values = load_image("./example/scene_ocr.png").to(torch.bfloat16) # Inference prompt = "Please recognize all text in the image" with torch.no_grad(): response = model.chat( tokenizer, pixel_values=pixel_values, question=prompt, generation_config={"max_new_tokens": 512}, verbose=False ) print(response) ``` ### 使用 vLLM 您可以使用 vLLM 官方的 Docker 镜像部署 Qianfan-VL,从而获得兼容 OpenAI API 的高性能推理能力: #### 启动 vLLM 服务 ``` docker run -d --name qianfan-vl \ --gpus all \ -v /path/to/Qianfan-VL-8B:/model \ -p 8000:8000 \ --ipc=host \ vllm/vllm-openai:latest \ --model /model \ --served-model-name qianfan-vl \ --trust-remote-code \ --hf-overrides '{"architectures":["InternVLChatModel"],"model_type":"internvl_chat"}' ``` #### 调用 API ``` curl 'http://127.0.0.1:8000/v1/chat/completions' \ --header 'Content-Type: application/json' \ --data '{ "model": "qianfan-vl", "messages": [ { "role": "user", "content": [ { "type": "image_url", "image_url": { "url": "https://example.com/image.jpg" } }, { "type": "text", "text": "Please recognize all text in the image" } ] } ] }' ``` 获取更多示例,请参考[使用指南](https://github.com/baidubce/qianfan-models-cookbook/blob/main/qianfan-vl/qianfan_vl_example.ipynb) ## 引用 如果您在研究中使用了 Qianfan-VL,请引用: ``` @misc{qianfan-vl-2025, title={Qianfan-VL: Domain-Enhanced Universal Vision-Language Models}, author={Baidu Qianfan Team}, year={2025}, publisher={Baidu AI Cloud}, howpublished={\url{https://github.com/baidubce/Qianfan-VL}} } ``` ## 开源协议本项目基于 MIT License 授权。详情请参阅 [LICENSE](LICENSE) 文件。 ## 联系我们 - GitHub Issues:[提交 Issue](https://github.com/baidubce/Qianfan-VL/issues)

百度智能云千帆 | 2025

标签:OCR, 企业级应用, 凭据扫描, 多模态大模型, 文档理解, 系统调用监控, 视觉语言模型, 逆向工具