Unlimited-OCR – 百度开源花生粒大小的大模型OCR

导语:百度开源了一款仅 3B 参数的轻量级 OCR 模型,支持一次性解析整本 100 页 PDF,而非传统工具那样逐页切割丢失上下文。模型已斩获 93% 标准解析基准分,40 页以后错误率低于 0.11,完全本地运行、永久免费。

工具背景

Unlimited-OCR 由百度研究团队开发,于 2026 年 6 月正式开源。项目的核心目标是推动长文档解析进入”一次搞定”(One-shot Long-horizon Parsing)时代——让 AI 一次性理解整份文档的完整上下文,而不是把文档拆成碎片逐页处理。

传统云端 OCR(AWS Textract、Google Vision、Azure Doc Intelligence)每 1000 页收费 1.5~15 美元。Unlimited-OCR 跑在你的本地机器上,省钱、隐私、永久免费。

GitHub 上线一个月即获 190 万次下载,TinyBERT 身材(3B 参数),却能完成GPT-4V 级别的文档理解。

核心能力

  • One-shot 长文本解析:32K context window,100 页 PDF 一次 forward pass 完成,无需切片,逐页处理不会丢上下文
  • 超高准确率:标准解析基准测试得分 93%(超基线 +6%),40 页以后错误率 < 0.11
  • 原生多语言:开箱即用,支持中英日韩等全球主要语言,无需额外微调
  • 真正的本地运行:100% 离线,GPU 资源完全自持,数据不上云,隐私零泄露
  • 极小体积:仅 3B 参数,INT4 量化后可部署在消费级显卡(RTX 3090 起)
  • 推理框架全覆盖:Transformers / vLLM / SGLang / Ollama / llama.cpp / Docker,总有一款适合你
  • PDF 直连:内置 PyMuPDF 渲染管道,PDF 转图片 + 多页 OCR 一气呵成
  • OpenAI 兼容 API:通过 vLLM 或 SGLang 部署后,可用标准 ChatGPT 接口调用
  • 截图展示

    Unlimited-OCR 官方架构图

    系统要求

    | 项目 | 最低要求 | |——|———-| | 显存 | ≥ 16GB(bf16);INT4 量化 ≥ 8GB | | 显卡 | NVIDIA GPU(CUDA 12.x) | | Python | 3.12+ | | 依赖库 | torch 2.10 / transformers 4.57 / PyMuPDF 等 |

    快速安装(Transformers)

    pip install torch torchvision transformers Pillow einops pymupdf
    

    python -c " import os, torch from transformers import AutoModel, AutoTokenizer

    model = AutoModel.from_pretrained( 'baidu/Unlimited-OCR', trust_remote_code=True, torch_dtype=torch.bfloat16, ) model = model.eval().cuda() tokenizer = AutoTokenizer.from_pretrained('baidu/Unlimited-OCR', trust_remote_code=True)

    单图 OCR

    model.infer(tokenizer, prompt='document parsing.', image_file='your_image.jpg', output_path='./outputs', base_size=1024, image_size=640, crop_mode=True, max_length=32768, no_repeat_ngram_size=35, ngram_window=128, save_results=True)

    PDF 多页 OCR

    model.infer_multi(tokenizer, prompt='Multi page parsing.', image_files=['page1.png', 'page2.png'], # 预先用 PyMuPDF 转成图片 output_path='./outputs', image_size=1024, max_length=32768, no_repeat_ngram_size=35, ngram_window=1024, save_results=True) "

    Docker 一键部署(vLLM)

    docker run --rm --gpus all --network host --ipc host 
      vllm/vllm-openai:unlimited-ocr 
      baidu/Unlimited-OCR 
      --trust-remote-code 
      --logits_processors vllm.model_executor.models.unlimited_ocr:NGramPerReqLogitProcessor 
      --no-enable-prefix-caching 
      --mm-processor-cache-gb 0
    

    部署后通过 OpenAI 兼容接口调用:

    POST http://127.0.0.1:8000/v1/chat/completions
    

    相关资源

    | 资源 | 链接 | |——|——| | GitHub | https://github.com/baidu/Unlimited-OCR | | Hugging Face | https://huggingface.co/baidu/Unlimited-OCR | | 论文 (arXiv) | https://arxiv.org/abs/2606.23050 | | vLLM Recipe | https://recipes.vllm.ai/baidu/Unlimited-OCR | | 在线 Demo | https://huggingface.co/spaces/baidu/Unlimited-OCR |

    下载 Unlimited-OCR
    © 版权声明
    THE END
    喜欢就支持一下吧
    点赞0分享
    相关推荐
  • 暂无相关文章