AI SeedbankHelp preserve open and free AI for humanity's future

← All models

baidu_Unlimited-OCR

baidu · View on Hugging Face ↗

Get this model

Download TorrentMagnet Link

Seeders: 2 · Leechers: 0

Observed 2026-09-05T20:48:33Z across trackers.

Model card

The complete upstream card, rendered from this payload's README.md — the same hash-verified bytes the torrent distributes. Images and off-site links are removed; the original card on Hugging Face carries them.


pipeline_tag: image-text-to-text language:

  • multilingual tags:
  • baidu
  • vision-language
  • ocr
  • custom_code license: mit library_name: transformers


Unlimited OCR Works

Welcome the Era of One-shot Long-horizon Parsing.

Release

  • [2026/07/21] 🤝 Thanks to the ms-swift community for their support, our model now supports training with ms-swift.
  • [2026/07/03] 🤝 Thanks to the Baidu Cloud team for their support. Our model is now available on Baidu Cloud.
  • [2026/06/28] 🤝 Thanks to the vLLM community and Tianyu Guo for their support, our model now supports vLLM inference.
  • [2026/06/24] 🤝 Thanks to AK for creating a demo for us. It is now available at Hugging Face Spaces.
  • [2026/06/23] 📄 Our paper is now available on arXiv.
  • [2026/06/23] 🤝 Thanks to the ModelScope community for their support. Our model is now available at ModelScope.
  • [2026/06/22] 🚀 We present Unlimited-OCR, aiming to push Deepseek-OCR one step further.

Inference

Transformers

Inference using Huggingface transformers on NVIDIA GPUs. Requirements tested on python 3.12.3 + CUDA12.9:

torch==2.10.0
torchvision==0.25.0
transformers==4.57.1
Pillow==12.1.1
matplotlib==3.10.8
einops==0.8.2
addict==2.4.0
easydict==1.13
pymupdf==1.27.2.2
psutil==7.2.2
import os
import torch
from transformers import AutoModel, AutoTokenizer

model_name = 'baidu/Unlimited-OCR'

tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModel.from_pretrained(
    model_name,
    trust_remote_code=True,
    use_safetensors=True,
    torch_dtype=torch.bfloat16,
)
model = model.eval().cuda()

# ── Single image supports two configs: gundam or base ──
# gundam: base_size=1024, image_size=640, crop_mode=True
# base: base_size=1024, image_size=1024, crop_mode=False
model.infer(
    tokenizer,
    prompt='<image>document parsing.',
    image_file='your_image.jpg',
    output_path='your/output/dir',
    base_size=1024, image_size=640, crop_mode=True,
    max_length=32768,
    no_repeat_ngram_size=35, ngram_window=128,
    save_results=True,
)

# ── Multi page / PDF only uses base (image_size=1024) ──
model.infer_multi(
    tokenizer,
    prompt='<image>Multi page parsing.',
    image_files=['page1.png', 'page2.png', 'page3.png'],
    output_path='your/output/dir',
    image_size=1024,
    max_length=32768,
    no_repeat_ngram_size=35, ngram_window=1024,
    save_results=True,
)

# ── PDF (convert pages to images, then multi-page parsing) ──
import tempfile, fitz  # PyMuPDF

def pdf_to_images(pdf_path, dpi=300):
    doc = fitz.open(pdf_path)
    tmp_dir = tempfile.mkdtemp(prefix='pdf_ocr_')
    mat = fitz.Matrix(dpi / 72, dpi / 72)
    paths = []
    for i, page in enumerate(doc):
        out = os.path.join(tmp_dir, f'page_{i+1:04d}.png')
        page.get_pixmap(matrix=mat).save(out)
        paths.append(out)
    doc.close()
    return paths

model.infer_multi(
    tokenizer,
    prompt='<image>Multi page parsing.',
    image_files=pdf_to_images('your_doc.pdf', dpi=300),
    output_path='your/output/dir',
    image_size=1024,
    max_length=32768,
    no_repeat_ngram_size=35, ngram_window=1024,
    save_results=True,
)

vLLM

Please refer to the official vLLM recipe for deployment details:

Recipe: https://recipes.vllm.ai/baidu/Unlimited-OCR

Docker Images

Use the following Docker images depending on your GPU platform:

Default (CUDA 13.0):

docker pull vllm/vllm-openai:unlimited-ocr

For Hopper GPUs (CUDA 12.9)

docker pull vllm/vllm-openai:unlimited-ocr-cu129

SGLang

Set up the environment (uv-managed virtualenv). Install the local SGLang wheel first, then pin kernels==0.9.0 and install PyMuPDF for PDF-to-image conversion:

uv venv --python 3.12
source .venv/bin/activate

uv pip install wheel/sglang-0.0.0.dev11416+g92e8bb79e-py3-none-any.whl
uv pip install kernels==0.11.7
uv pip install pymupdf==1.27.2.2

Start the SGLang server:

python -m sglang.launch_server \
    --model baidu/Unlimited-OCR \
    --served-model-name Unlimited-OCR \
    --attention-backend fa3 \
    --page-size 1 \
    --mem-fraction-static 0.8 \
    --context-length 32768 \
    --enable-custom-logit-processor \
    --disable-overlap-schedule \
    --skip-server-warmup \
    --host 0.0.0.0 \
    --port 10000

Send streaming requests to the OpenAI-compatible API:

import base64
import json
import os
import tempfile

import fitz
import requests
from sglang.srt.sampling.custom_logit_processor import DeepseekOCRNoRepeatNGramLogitProcessor

server_url = "http://127.0.0.1:10000"

session = requests.Session()
session.trust_env = False


def pdf_to_images(pdf_path, dpi=300):
    doc = fitz.open(pdf_path)
    tmp_dir = tempfile.mkdtemp(prefix="pdf_ocr_")
    mat = fitz.Matrix(dpi / 72, dpi / 72)
    image_paths = []
    for i, page in enumerate(doc):
        image_path = os.path.join(tmp_dir, f"page_{i + 1:04d}.png")
        page.get_pixmap(matrix=mat).save(image_path)
        image_paths.append(image_path)
    doc.close()
    return image_paths


def encode_image(image_path):
    ext = os.path.splitext(image_path)[1].lower()
    mime = "image/jpeg" if ext in (".jpg", ".jpeg") else f"image/{ext.lstrip('.')}"
    with open(image_path, "rb") as f:
        data = base64.b64encode(f.read()).decode("utf-8")
    return {"type": "image_url", "image_url": {"url": f"data:{mime};base64,{data}"}}


def build_content(prompt, image_paths):
    return [{"type": "text", "text": prompt}] + [encode_image(path) for path in image_paths]


def generate(prompt, image_paths, image_mode, ngram_window):
    payload = {
        "model": "Unlimited-OCR",
        "messages": [{"role": "user", "content": build_content(prompt, image_paths)}],
        "temperature": 0,
        "skip_special_tokens": False,
        "images_config": {"image_mode": image_mode},
        "custom_logit_processor": DeepseekOCRNoRepeatNGramLogitProcessor.to_str(),
        "custom_params": {
            "ngram_size": 35,
            "window_size": ngram_window,
        },
        "stream": True,
    }
    response = session.post(
        f"{server_url}/v1/chat/completions",
        headers={"Content-Type": "application/json"},
        data=json.dumps(payload),
        timeout=1200,
        stream=True,
    )
    response.raise_for_status()

    chunks = []
    for line in response.iter_lines(chunk_size=1, decode_unicode=True):
        if not line or not line.startswith("data: "):
            continue
        data = line[len("data: "):]
        if data == "[DONE]":
            break
        event = json.loads(data)
        delta = event["choices"][0].get("delta", {}).get("content", "")
        if delta:
            print(delta, end="", flush=True)
            chunks.append(delta)
    print()
    return "".join(chunks)


# Single image supports two configs: gundam or base. Example below uses gundam.
generate("document parsing.", ["your_image.jpg"], image_mode="gundam", ngram_window=128)

# Multi image (base only)
generate("Multi page parsing.", ["page1.png", "page2.png"], image_mode="base", ngram_window=1024)

# PDF (base only)
generate("Multi page parsing.", pdf_to_images("your_doc.pdf", dpi=300), image_mode="base", ngram_window=1024)

For OmniDocBench evaluation, you need to perform the following post-processing.

DET_RE = re.compile(r'<\|det\|>([^<\s]+)(?:\s*\[[^\]]*\])?\s*<\|/det\|>(.*)', re.DOTALL)

def remove_det(raw: str) -> str:
    """
    Strip <|det|>type [bbox]<|/det|> markers, group lines belonging to the
    same block with \\n, and separate different blocks with \\n\\n.
    """
    blocks = []
    cur = None
    for line in raw.splitlines():
        line = line.rstrip()
        if not line:
            continue
        m = DET_RE.match(line)
        if m:
            category, content = m.group(1).strip(), m.group(2).strip()
            if category == 'image':
                continue
            if cur is not None:
                blocks.append(cur)
            cur = [content] if content else []
            continue
        if cur is None:
            cur = []
        cur.append(line)
    if cur is not None:
        blocks.append(cur)
    text = '\n\n'.join('\n'.join(b) for b in blocks).strip()
    return text

Visualization

Acknowledgement

We would like to thank Deepseek-OCR, Deepseek-OCR-2, PaddleOCR for their valuable models and ideas.

Citation

@misc{yin2026unlimitedocrworks,
      title={Unlimited OCR Works}, 
      author={Youyang Yin and Huanhuan Liu and YY and Qunyi Xie and Chaorun Liu and Shiqi Yang and Shaohua Wang and Zhanlong Liu and Hao Zou and Jinyue Chen and Shu Wei and Jingjing Wu and Mingxin Huang and Zhen Wu and Guibin Wang and Tengyu Du and Lei Jia},
      year={2026},
      eprint={2606.23050},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2606.23050}, 
}

Magnet link

Opens the swarm directly in your torrent client — no file download needed. Copy-paste works too:

magnet:?xt=urn:btih:31fae888281ffccb9e2b555b00d817d1df834d9d&dn=baidu_Unlimited-OCR

Open magnet in torrent client · infohash 31fae888281ffccb9e2b555b00d817d1df834d9d

Files & hashes

PathSizesha1sha256
LICENSE1.0 KB (1,061 B)890d455ae73d1d930eee703ce1e5478783ec9154d985048c6d69429d685fdbe7557340aa0897c0fd8dc038299b148b9c75dc3383
README.md10.8 KB (11,108 B)9a9880ab7dac523e66ff68ca9acc2e1235fab6624f573db255db5262bfe2ea92e459bfc11635a456f210e3a96289bb9605077a55
Unlimited-OCR.pdf449.5 KB (460,324 B)e56763c4f5b2cb0e27a47781022a59e42cea94cad4cc0b2e98f53d9165e63af925519cccbf80ecc6f047973e3f9b2bdd84474a8b
assets/Unlimited-OCR.png103.8 KB (106,286 B)dd5e1e30c7d288bd40153ac45fafb04c6a85b22777063289aecfedea40d90c94dac3bc5d57f42f65d2a988183bb665a69e26ce95
assets/baidu.png10.8 KB (11,109 B)35527f6ff2da8bf69b600c96328d356e228ce7b73342dd06c42f0abc227adf8e3a3602eda301adfb9af1371f22b9f40c6b5f3339
assets/long-horizon-ocr.gif78.4 MB (82,173,303 B)4e9e28feadb27ebdd64bad62bb76cedfc10612d0d4ba8964d33ffa3a3584d4a1259625ab659c02190e9655ddd51793d28307d962
config.json2.8 KB (2,881 B)51871434df16d1a04dbf190565e1a4e0d5f4803727246d03fd670904ec9601b1cb0861fbb79ec076830771daa8d943d6229946f9
configuration_deepseek_v2.py10.5 KB (10,720 B)1c28cf39e8b821ec2623d3762f08ffd77050e8f8b8470dd616ba8745fce6e27b093aef73a098863cc891b2477dcf9326a36000f7
conversation.py9.0 KB (9,253 B)65c295e81cd804080ec238b31d1922f33e1f9405ec7b6ce89bcda643de1f43269ffa66a7b2e65dc3ed30e427958f776546b4ba03
deepencoder.py37.1 KB (38,008 B)de1687dfec3a4a8a00980a8444baba0082ce779b0ae2fb6d1e5ae8cf100fc32f854830acd08c821a0a1f23a94a76588c222ddcf2
model-00001-of-000001.safetensors6.21 GB (6,672,547,120 B)1f91eddc73e09952589eddd66b69caaaae2a84f02bc48a7a110061ea58fff65d3169367eebe3aee371ca6968dc2219c1b2855fc6
model.safetensors.index.json251.6 KB (257,611 B)927d176a228105e796dd2193e33351bef791adcf354be1f2dcfb72ebb385e25465522ce5413a77c36f3b35fec088a3162a11af99
modeling_deepseekv2.py88.0 KB (90,162 B)17d5c358a6010e71fa1f3cc2040cd3e5508ccd1b74e36e6bd0ba7bc565ef76464a99baa8e6bccb710ae9c1007b54ac30b855fa4c
modeling_unlimitedocr.py52.2 KB (53,431 B)c329779827aa29c4b37d97c5510416aa3a9fde18268bdcbe12cf37bf5a2debb53faf542e56570958a5d9f3314aab3cab2cf6cb48
processor_config.json466 B (466 B)6b3c4e7b325d9ec404182a3b0585a988cc883d1f92588cffb1d7032ec83d0a06c3a5171b41df5cbf432d68765441139a57899328
special_tokens_map.json801 B (801 B)d59d312be868edc63b195e19e256c730dba685adab4bd57ce17d62e39e0a39e739de1e407484f090f0b2c7e391312bca7a5b061a
tokenizer.json9.5 MB (9,979,544 B)c93a1c4d2ecf31bb5a9ec39eb73dfbf915aaf77ea02f8fd5228c90256bb4f6554c34a579d48f909e5beb232dc4afad870b55a8b4
tokenizer_config.json162.0 KB (165,938 B)ba9d4175d69cde58ad9f68a76a4758df091eaffaa0cbe8464049da1f891b7a12676de06af4cb54c130995d42f71adc1c30c6e9f3
wheel/sglang-0.0.0.dev11416+g92e8bb79e-py3-none-any.whl11.9 MB (12,450,224 B)0a0d6d7118db74ee7782de7ee272e81f8f5762452644a1f349c55f0ca822e70a70679c98475754ec4722c3be1b18a72bac477cd5

Cite this release

Canonical URL
https://aiseedbank.org/models/baidu_Unlimited-OCR/
Slug
baidu_Unlimited-OCR
Infohash
31fae888281ffccb9e2b555b00d817d1df834d9d
License
mit
Signing key fingerprint
85a3b32c3712427b

Every file carries a locally computed sha256 — verify a download against the signed sums: baidu_Unlimited-OCR.SHA256SUMS (+ minisign signature).

Provenance

Upstream repositorybaidu/Unlimited-OCR
Revision (pinned)07dea832e22aefee32ad281d4b80551282e1c168
Fetched at2026-08-21T01:03:44Z
License at fetchmit
Snapshot toolhuggingface · seedbank 0.1.0

Trackers

✓ verified · rehash-vs-hf-metadata at 2026-08-21T01:07:50Z

mit6.31 GB (6,778,369,350 bytes)transformerssafetensorsunlimited-ocrfeature-extractionbaiduvision-languageocrcustom_codeimage-text-to-textmultilingualeval-resultspaper: 2606.23050