ATH-MaaS/OvisOCR2
摘要
OvisOCR2 是一个紧凑的0.8B端到端模型,用于页面级文档解析,在OmniDocBench和PureDocBench基准测试中达到了最先进的性能。
任务: image-text-to-text, 标签: transformers, safetensors, qwen3_5, image-text-to-text, ocr, document-parsing, multimodal, markdown, tables, formulas, vllm, conversational, 基础模型: Qwen/Qwen3.5-0.8B, 微调基础模型: Qwen/Qwen3.5-0.8B, 许可证: apache-2.0, 端点兼容, 区域: us
查看缓存全文
缓存时间: 2026/07/14 22:15
ATH-MaaS/OvisOCR2 · Hugging Face 来源:https://huggingface.co/ATH-MaaS/OvisOCR2 Ovis ## https://huggingface.co/ATH-MaaS/OvisOCR2#introduction介绍 我们很高兴宣布发布 OvisOCR2,这是一个紧凑的 0.8B 端到端模型,用于页面级文档解析。给定文档页面图像,OvisOCR2 会按自然阅读顺序生成 Markdown 表示形式,涵盖文本、公式、表格和视觉区域。OvisOCR2 是通过后训练 Qwen3.5-0.8B 开发的,采用精心设计的数据引擎,结合真实世界与合成数据,并搭配集成 SFT、RL 和 OPD 的多阶段训练方案。该模型在保持较小部署规模的同时,提供了强大的文档解析性能。OvisOCR2 在 OmniDocBench v1.6 上取得了 96.58 的总分,创下新的最先进水平,成为首个登顶该榜单的端到端模型(此前该榜单由流水线方法主导)。在 PureDocBench 上,OvisOCR2 也以 75.06 的高分获得了最高的 Avg3 成绩。OvisOCR2 在 OmniDocBench v1.6 上的性能 ## https://huggingface.co/ATH-MaaS/OvisOCR2#performance性能 OmniDocBench v1.6 对比 PureDocBench 对比 ## https://huggingface.co/ATH-MaaS/OvisOCR2#inference推理 pip install "vllm==0.22.1" pillow from PIL import Image from vllm import LLM, SamplingParams class OvisOCR2Parser: def __init__(self, model_name_or_path: str): self.model = LLM( model=model_name_or_path, tensor_parallel_size=1, gpu_memory_utilization=0.8, gdn_prefill_backend="triton" ) prompt = '\n以自然人类阅读顺序从图像中提取所有可读内容,并将结果输出为单个 Markdown 文档。对于图表或图像,使用 HTML 图像标签表示:<' + 'img src="images/bbox_{left}_{top}_{right}_{bottom}.jpg" />,其中 left、top、right、bottom 是缩放至 [0, 1000) 的边界框坐标。将公式格式化为 LaTeX。将表格格式化为 HTML:.... 将所有其他文本转录为标准 Markdown。保留原文,不进行翻译或转述。' self.prompt = self.model.get_tokenizer().apply_chat_template( [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": prompt}]}], tokenize=False, add_generation_prompt=True, enable_thinking=False ) self.sampling_params = SamplingParams( max_tokens=16384, temperature=0.0 ) def _clean_truncated_repeats( self, text: str, min_text_len: int = 8000, max_period: int = 200, min_period: int = 1, min_repeat_chars: int = 100, min_repeat_times: int = 5 ) -> str: n = len(text) if n < min_text_len: return text max_period = min(max_period, n - 1) for unit_len in range(min_period, max_period + 1): if text[n - 1] != text[n - 1 - unit_len]: continue match_len = 1 idx = n - 2 while idx >= unit_len and text[idx] == text[idx - unit_len]: match_len += 1 idx -= 1 total_len = match_len + unit_len repeat_times = total_len // unit_len tail_len = total_len % unit_len if repeat_times >= min_repeat_times and total_len >= min_repeat_chars: return text[: n - total_len + unit_len] + text[n - tail_len:] return text def parse(self, images: list[Image.Image], filter_imgtags: bool = True) -> list[str]: vllm_inputs = [ { "prompt": self.prompt, "multi_modal_data": {"image": image}, "mm_processor_kwargs": { "images_kwargs": { "min_pixels": 448 * 448, "max_pixels": 2880 * 2880 } } } for image in images ] outputs = self.model.generate(vllm_inputs, self.sampling_params) markdowns = [] for output in outputs: text = output.outputs[0].text.strip() if filter_imgtags: text = "\n\n".join( block for block in text.split("\n\n") if not block.strip().startswith('' ) def save_renderable_markdown_with_visual_regions( markdown: str, page_image: Image.Image, output_dir: str, ) -> None: output_dir = Path(output_dir) images_dir = output_dir / "images" images_dir.mkdir(parents=True, exist_ok=True) width, height = page_image.size for left, top, right, bottom in BBOX_IMAGE_PATTERN.findall(markdown): x1 = max(0, min(width, round(int(left) * width / 1000))) y1 = max(0, min(height, round(int(top) * height / 1000))) x2 = max(0, min(width, round(int(right) * width / 1000))) y2 = max(0, min(height, round(int(bottom) * height / 1000))) if x2 <= x1 or y2 <= y1: continue crop_path = images_dir / f"bbox_{left}_{top}_{right}_{bottom}.jpg" page_image.crop((x1, y1, x2, y2)).convert("RGB").save(crop_path) (output_dir / "output.md").write_text(markdown, encoding="utf-8") parser = OvisOCR2Parser("ATH-MaaS/OvisOCR2") page_image = Image.open("test1.jpg") markdown = parser.parse([page_image], filter_imgtags=False)[0] save_renderable_markdown_with_visual_regions(markdown, page_image, "output") ## https://huggingface.co/ATH-MaaS/OvisOCR2#citation引用 如果您觉得 OvisOCR2 有用,请考虑引用我们的技术报告: @misc{lu2026ovisocr2, title = {{OvisOCR2 Technical Report}}, author = {Lu, Shiyin and Li, Yinglun and Xia, Yu and Chen, Yuhui and Ji, An-Yang and Jiang, Jun-Peng and Chen, Qing-Guo and Zhao, Jianshan and Lin, En and Li, Haijun and Qin, Cheng and Xu, Zhao and Luo, Weihua}, year = {2026} } ## https://huggingface.co/ATH-MaaS/OvisOCR2#license许可 本项目基于 Apache 许可证 2.0 版 (https://www.apache.org/licenses/LICENSE-2.0.txt)(SPDX-许可证标识符:Apache-2.0)许可。 ## https://huggingface.co/ATH-MaaS/OvisOCR2#disclaimer免责声明 我们在数据构建过程中使用了过滤和质量保证流程,以减少重复输出、内容不完整、无效表格/公式结构以及阅读顺序不一致等解析错误。由于真实世界文档的多样性和复杂性,OvisOCR2 仍可能产生不正确或不完整的输出。在关键应用中,请手动验证结果。
相似文章
OvisOCR2:一款有前景的0.8B本地文档解析器
OvisOCR2是一款基于Qwen3.5-0.8B的新型0.8B端到端OCR模型,能够将整个文档页面直接转换为结构化Markdown,包括文本、表格、公式和阅读顺序。它在基准测试中取得了优异的成绩,并基于Apache 2.0协议发布,支持vLLM。
OvisOCR2 技术报告
OvisOCR2 是一个0.8B参数量的端到端文档解析模型,能将文档页面图像转换为Markdown格式,通过结合监督微调、强化学习和模型融合,在公开基准上取得了最先进的分数。
OvisOCR2 (0.8B): 首个登顶OmniDocBench的端到端模型——我用827份真实医学扫描文档测试了它,以下是我学到的所有内容
OvisOCR2是一个0.8B参数的端到端文档解析视觉语言模型,在OmniDocBench排行榜上位居榜首,在实际扫描的医学文档上,其准确性和效率均优于流水线OCR系统。
@techNmak:1.7B 参数轻量 VLM,在 OmniDocBench 上碾压巨头的 OCR 新王者
仅 1.7B 参数的多语言文档解析器 dots.ocr,用轻量体积实现 SOTA,证明文档理解无需巨无霸模型。
@berryxia: https://x.com/berryxia/status/2067078380017828205
作者实测了PP-OCRv6三档模型并提供了本地部署的开源工具,展示了在OmniDocBench及真实场景下各模型的性能对比,强调轻量专用模型在OCR任务上的优势。