Image-Text-to-Text
Transformers
Safetensors
multilingual
unlimited_ocr
feature-extraction
baidu
vision-language
ocr
custom_code
conversational
Eval Results
Run this model with HF Jobs
Run baidu/Unlimited-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/baidu/Unlimited-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/baidu/Unlimited-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/baidu/Unlimited-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/baidu/Unlimited-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 baidu/Unlimited-OCR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use baidu/Unlimited-OCR with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="baidu/Unlimited-OCR", trust_remote_code=True) 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, AutoModel processor = AutoProcessor.from_pretrained("baidu/Unlimited-OCR", trust_remote_code=True) model = AutoModel.from_pretrained("baidu/Unlimited-OCR", trust_remote_code=True, 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 baidu/Unlimited-OCR with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "baidu/Unlimited-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": "baidu/Unlimited-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/baidu/Unlimited-OCR
- SGLang
How to use baidu/Unlimited-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 "baidu/Unlimited-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": "baidu/Unlimited-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 "baidu/Unlimited-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": "baidu/Unlimited-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 baidu/Unlimited-OCR with Docker Model Runner:
docker model run hf.co/baidu/Unlimited-OCR
Download config.json from baidu/Unlimited-OCR: direct link, hf CLI and curl.
- Browser
- Download file 2.88 kB
-
https://huggingface.co/baidu/Unlimited-OCR/resolve/refs%2Fpr%2F21/config.json
- Command line
-
hf download hf://baidu/Unlimited-OCR@refs/pr/21/config.json
-
curl -L -o config.json https://huggingface.co/baidu/Unlimited-OCR/resolve/refs%2Fpr%2F21/config.json
2.88 kB
| { | |
| "_name_or_path": "Unlimited-OCR", | |
| "candidate_resolutions": [ | |
| [ | |
| 1024, | |
| 1024 | |
| ] | |
| ], | |
| "global_view_pos": "head", | |
| "architectures": [ | |
| "UnlimitedOCRForCausalLM" | |
| ], | |
| "auto_map": { | |
| "AutoConfig": "modeling_unlimitedocr.UnlimitedOCRConfig", | |
| "AutoModel": "modeling_unlimitedocr.UnlimitedOCRForCausalLM" | |
| }, | |
| "language_config": { | |
| "architectures": [ | |
| "DeepseekOCRForCausalLM" | |
| ], | |
| "auto_map": { | |
| "AutoConfig": "configuration_deepseekv2.DeepseekV2Config", | |
| "AutoModel": "modeling_deepseek.DeepseekV2Model", | |
| "AutoModelForCausalLM": "modeling_deepseek.DeepseekV2ForCausalLM" | |
| }, | |
| "bos_token_id": 0, | |
| "eos_token_id": 1, | |
| "first_k_dense_replace": 1, | |
| "hidden_size": 1280, | |
| "intermediate_size": 6848, | |
| "kv_lora_rank": null, | |
| "lm_head": true, | |
| "max_position_embeddings": 32768, | |
| "moe_intermediate_size": 896, | |
| "n_group": 1, | |
| "n_routed_experts": 64, | |
| "n_shared_experts": 2, | |
| "num_attention_heads": 10, | |
| "num_experts_per_tok": 6, | |
| "num_hidden_layers": 12, | |
| "num_key_value_heads": 10, | |
| "q_lora_rank": null, | |
| "qk_nope_head_dim": 0, | |
| "qk_rope_head_dim": 0, | |
| "rm_head": false, | |
| "topk_group": 1, | |
| "topk_method": "greedy", | |
| "torch_dtype": "bfloat16", | |
| "use_mla": false, | |
| "v_head_dim": 128, | |
| "vocab_size": 129280, | |
| "sliding_window_size": 128 | |
| }, | |
| "model_type": "unlimited-ocr", | |
| "projector_config": { | |
| "input_dim": 2048, | |
| "model_type": "mlp_projector", | |
| "n_embed": 1280, | |
| "projector_type": "linear" | |
| }, | |
| "tile_tag": "2D", | |
| "torch_dtype": "bfloat16", | |
| "transformers_version": "4.46.3", | |
| "vision_config": { | |
| "image_size": 1024, | |
| "mlp_ratio": 3.7362, | |
| "model_name": "deeplip_b_l", | |
| "model_type": "vision", | |
| "width": { | |
| "clip-l-14-224": { | |
| "heads": 16, | |
| "image_size": 224, | |
| "layers": 24, | |
| "patch_size": 14, | |
| "width": 1024 | |
| }, | |
| "sam_vit_b": { | |
| "downsample_channels": [ | |
| 512, | |
| 1024 | |
| ], | |
| "global_attn_indexes": [ | |
| 2, | |
| 5, | |
| 8, | |
| 11 | |
| ], | |
| "heads": 12, | |
| "layers": 12, | |
| "width": 768 | |
| } | |
| } | |
| }, | |
| "bos_token_id": 0, | |
| "eos_token_id": 1, | |
| "first_k_dense_replace": 1, | |
| "hidden_size": 1280, | |
| "intermediate_size": 6848, | |
| "kv_lora_rank": null, | |
| "lm_head": true, | |
| "max_position_embeddings": 32768, | |
| "moe_intermediate_size": 896, | |
| "n_group": 1, | |
| "n_routed_experts": 64, | |
| "n_shared_experts": 2, | |
| "num_attention_heads": 10, | |
| "num_experts_per_tok": 6, | |
| "num_hidden_layers": 12, | |
| "num_key_value_heads": 10, | |
| "q_lora_rank": null, | |
| "qk_nope_head_dim": 0, | |
| "qk_rope_head_dim": 0, | |
| "rm_head": false, | |
| "topk_group": 1, | |
| "topk_method": "greedy", | |
| "use_mla": false, | |
| "v_head_dim": 128, | |
| "vocab_size": 129280, | |
| "sliding_window_size": 128, | |
| "sliding_window": 128 | |
| } |