Image-Text-to-Text
Transformers
Safetensors
qwen3_5
ocr
document-parsing
multimodal
markdown
tables
formulas
conversational
Run this model with HF Jobs
Run AndyLiuys/Mu-OCR on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/AndyLiuys/Mu-OCR. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/AndyLiuys/Mu-OCR on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/AndyLiuys/Mu-OCR. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/AndyLiuys/Mu-OCR. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use AndyLiuys/Mu-OCR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AndyLiuys/Mu-OCR with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="AndyLiuys/Mu-OCR") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("AndyLiuys/Mu-OCR") model = AutoModelForMultimodalLM.from_pretrained("AndyLiuys/Mu-OCR", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AndyLiuys/Mu-OCR with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AndyLiuys/Mu-OCR" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AndyLiuys/Mu-OCR", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/AndyLiuys/Mu-OCR
- SGLang
How to use AndyLiuys/Mu-OCR with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "AndyLiuys/Mu-OCR" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AndyLiuys/Mu-OCR", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "AndyLiuys/Mu-OCR" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AndyLiuys/Mu-OCR", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use AndyLiuys/Mu-OCR with Docker Model Runner:
docker model run hf.co/AndyLiuys/Mu-OCR
|
Download README.md from AndyLiuys/Mu-OCR: direct link, hf CLI and curl.
- Browser
- Download file 6.88 kB
-
https://huggingface.co/AndyLiuys/Mu-OCR/resolve/main/README.md
- Command line
-
hf download hf://AndyLiuys/Mu-OCR/README.md
-
curl -L -o README.md https://huggingface.co/AndyLiuys/Mu-OCR/resolve/main/README.md
6.88 kB
| license: apache-2.0 | |
| library_name: transformers | |
| pipeline_tag: image-text-to-text | |
| base_model: ATH-MaaS/OvisOCR2 | |
| tags: | |
| - ocr | |
| - document-parsing | |
| - multimodal | |
| - markdown | |
| - tables | |
| - formulas | |
| # Mu-OCR | |
| [GitHub repository](https://github.com/AndyLiuYS-AI/Mu-OCR) | |
| Mu-OCR is a document parsing model distilled from [OvisOCR2](https://huggingface.co/ATH-MaaS/OvisOCR2) using Multi-Teacher On-Policy Distillation (MOPD). It aims to improve formula recognition while preserving table recognition and overall document parsing quality. The original model architecture and inference pipeline are retained. | |
| **Training data.** We use mathematical formula images from [IBEM-v1-cropped](https://huggingface.co/datasets/deepcopy/IBEM-v1-cropped) and table images from [PubTabNet](https://github.com/ibm-aur-nlp/PubTabNet). For formula recognition, we use displayed (`isolated`) formula images. For table recognition, we select samples on which the original OvisOCR2 performs better than a formula-only distilled model, targeting table recognition capabilities that may degrade during formula-specific distillation. | |
| **Multi-Teacher On-Policy Distillation (MOPD).** We initialize the student from OvisOCR2 and use [MiniCPM-OCR 1.0](https://huggingface.co/openbmb/MiniCPM-OCR-1.0) as the formula teacher and the frozen original OvisOCR2 as the table teacher. The student generates its own token sequences from formula and table images, and the task-specific teachers provide token-level probability supervision on the student-generated prefixes. We align candidate tokens across the student and teacher vocabularies where necessary and minimize reverse KL divergence over the aligned top-64 student candidates. The formula and table distillation losses are computed separately and combined with task-specific weights to balance formula enhancement and table preservation. We fine-tune the student using LoRA and merge the adapted weights for inference. | |
| ## Results on OmniDocBench | |
| | Model | Overall β | Text<sup>Edit</sup> β | Formula<sup>CDM</sup> β | Table<sup>TEDS</sup> β | Table<sup>TEDS-S</sup> β | Read Order<sup>Edit</sup> β | | |
| | --- | ---: | ---: | ---: | ---: | ---: | ---: | | |
| | Mu-OCR | 96.6436 | 0.026530 | 97.8038 | 94.7800 | 97.1515 | 0.111771 | | |
| | OvisOCR2 | 96.5586 | 0.026492 | 97.5317 | 94.7933 | 97.1697 | 0.111737 | | |
| *Source: Both Mu-OCR and OvisOCR2 results are from our local evaluation under the same inference and evaluation settings.* | |
| ## Reproduce on OmniDocBench | |
| ### 1. Clone the repository and download the model | |
| Requirements: Linux, Docker, NVIDIA Container Toolkit, Git, Python 3 and a BF16-capable NVIDIA GPU with a driver compatible with the inference Docker image. The reported experiments used NVIDIA A100 80GB GPUs. | |
| Clone the repository: | |
| ```bash | |
| git clone https://github.com/AndyLiuYS-AI/Mu-OCR.git | |
| cd Mu-OCR | |
| ``` | |
| Download the model: | |
| ```bash | |
| python -m pip install -U huggingface_hub | |
| hf download AndyLiuys/Mu-OCR --local-dir ./models/Mu-OCR | |
| ``` | |
| The evaluation script automatically pulls the pinned inference and evaluation Docker images if they are not available locally. No separate installation of vLLM or evaluation dependencies on the host is required. | |
| ### 2. Run full inference and evaluation | |
| Use the [OmniDocBench v1.6 full dataset](https://huggingface.co/datasets/opendatalab/OmniDocBench) (1,651 pages). From the repository root, run: | |
| ```bash | |
| DATA="/path/to/OmniDocBench" GPU=1 bash eval_omnidocbench.sh | |
| ``` | |
| Replace `/path/to/OmniDocBench` with the actual dataset path and `GPU=1` with the index of an available GPU. The dataset directory should contain `OmniDocBench.json` and `images/`. | |
| The script completes full inference and automatically runs the [official OmniDocBench evaluator](https://github.com/opendatalab/OmniDocBench). The inference configuration uses vLLM 0.25.1, BF16, a batch size of 8, greedy decoding and a maximum generation length of 16,384 tokens. The evaluation uses `quick_match`, direct CDM scoring and page-level aggregation. The evaluator checkout and Docker image digests are pinned in the script. Minor numerical differences may occur across hardware and runtime environments. | |
| The Markdown predictions, inference logs, detailed evaluation results and `score/summary.json` are saved in the evaluation directory (`omnidocbench_eval_*`) printed at the end of the run. | |
| ## Additional Benchmark Results | |
| ### Real5-OmniDocBench | |
| | Model | Average β | Scanning β | Warping β | Screen-Photography β | Illumination β | Skew β | | |
| | --- | ---: | ---: | ---: | ---: | ---: | ---: | | |
| | Mu-OCR | 92.35 | 93.77 | 91.52 | 92.98 | 93.13 | 90.37 | | |
| | OvisOCR2 | 92.23 | 93.73 | 91.27 | 93.05 | 92.90 | 90.22 | | |
| *Source: Both Mu-OCR and OvisOCR2 results are from our local evaluation under the same inference and evaluation settings, using the official OmniDocBench v1.5 evaluator and Docker environment.* | |
| ### Wild-OmniDocBench | |
| **Page-level results** | |
| | Model | Overall β | Text<sup>Edit</sup> β | Formula<sup>CDM</sup> β | Table<sup>TEDS</sup> β | Table<sup>TEDS-S</sup> β | Read Order<sup>Edit</sup> β | | |
| | --- | ---: | ---: | ---: | ---: | ---: | ---: | | |
| | Mu-OCR | 87.75 | 0.128 | 90.03 | 86.00 | 90.19 | 0.195 | | |
| | OvisOCR2 | 87.56 | 0.131 | 90.28 | 85.52 | 89.50 | 0.199 | | |
| *Source: Both Mu-OCR and OvisOCR2 results are from our local evaluation under the same inference and evaluation settings, using the official OmniDocBench v1.6 evaluator and Docker environment.* | |
| In addition to the page-level evaluation, we also report element-level results on Wild-OmniDocBench under the same settings. | |
| **Element-level results** | |
| | Model | Overall β | Text<sup>Edit</sup> β | Formula<sup>CDM</sup> β | Table<sup>TEDS</sup> β | Table<sup>TEDS-S</sup> β | Read Order<sup>Edit</sup> β | | |
| | --- | ---: | ---: | ---: | ---: | ---: | ---: | | |
| | Mu-OCR | 78.24 | 0.366 | 92.03 | 79.33 | 83.35 | 0.195 | | |
| | OvisOCR2 | 77.71 | 0.375 | 91.69 | 78.97 | 82.95 | 0.199 | | |
| Although the page-level formula CDM decreases slightly, the element-level formula CDM increases from 91.69 to 92.03. The two aggregation schemes weight pages and individual elements differently. Mu-OCR improves the overall score under both aggregation schemes, with improvements across all reported element-level metrics. | |
| ## License | |
| Mu-OCR is released under the [Apache License 2.0](LICENSE). The model is derived from [OvisOCR2](https://huggingface.co/ATH-MaaS/OvisOCR2), and the inference code is adapted from its original inference examples. The original copyright (Copyright 2026 Alibaba Cloud), license and attribution notices are retained. See [NOTICE](https://github.com/AndyLiuYS-AI/Mu-OCR/blob/main/NOTICE) for details of the modifications. | |
| We thank the OvisOCR2 authors for releasing their model and inference code. Please refer to the [OvisOCR2 Technical Report](https://arxiv.org/abs/2607.13639) for the original work. | |