Instructions to use tiny-random/unlimited-ocr-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/unlimited-ocr-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="tiny-random/unlimited-ocr-2", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("tiny-random/unlimited-ocr-2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tiny-random/unlimited-ocr-2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/unlimited-ocr-2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/unlimited-ocr-2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/tiny-random/unlimited-ocr-2
- SGLang
How to use tiny-random/unlimited-ocr-2 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 "tiny-random/unlimited-ocr-2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/unlimited-ocr-2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "tiny-random/unlimited-ocr-2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/unlimited-ocr-2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use tiny-random/unlimited-ocr-2 with Docker Model Runner:
docker model run hf.co/tiny-random/unlimited-ocr-2
Download config.json from tiny-random/unlimited-ocr-2: direct link, hf CLI and curl.
- Browser
- Download file 5.25 kB
-
https://huggingface.co/tiny-random/unlimited-ocr-2/resolve/main/config.json
- Command line
-
hf download hf://tiny-random/unlimited-ocr-2/config.json
-
curl -L -o config.json https://huggingface.co/tiny-random/unlimited-ocr-2/resolve/main/config.json
5.25 kB
| { | |
| "_ring_window": 128, | |
| "architectures": [ | |
| "UnlimitedOCRForCausalLM" | |
| ], | |
| "attention_bias": false, | |
| "attention_dropout": 0.0, | |
| "auto_map": { | |
| "AutoConfig": "modeling_unlimitedocr.UnlimitedOCRConfig", | |
| "AutoModel": "modeling_unlimitedocr.UnlimitedOCRForCausalLM" | |
| }, | |
| "aux_loss_alpha": 0.001, | |
| "bos_token_id": 0, | |
| "candidate_resolutions": [ | |
| [ | |
| 1024, | |
| 1024 | |
| ] | |
| ], | |
| "eos_token_id": 1, | |
| "ep_size": 1, | |
| "first_k_dense_replace": 1, | |
| "global_view_pos": "head", | |
| "hidden_act": "silu", | |
| "hidden_size": 32, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 256, | |
| "kv_lora_rank": null, | |
| "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": 32, | |
| "intermediate_size": 256, | |
| "kv_lora_rank": null, | |
| "lm_head": true, | |
| "max_position_embeddings": 131072, | |
| "moe_intermediate_size": 64, | |
| "n_group": 1, | |
| "n_routed_experts": 16, | |
| "n_shared_experts": 2, | |
| "num_attention_heads": 4, | |
| "num_experts_per_tok": 6, | |
| "num_hidden_layers": 4, | |
| "num_key_value_heads": 4, | |
| "q_lora_rank": null, | |
| "qk_nope_head_dim": 0, | |
| "qk_rope_head_dim": 0, | |
| "rm_head": false, | |
| "rope_scaling": { | |
| "attention_factor": 1.0, | |
| "beta_fast": 32, | |
| "beta_slow": 1, | |
| "factor": 4.0, | |
| "original_max_position_embeddings": 32768, | |
| "rope_type": "yarn", | |
| "type": "yarn" | |
| }, | |
| "rope_theta": 500000.0, | |
| "sliding_window_size": 128, | |
| "topk_group": 1, | |
| "topk_method": "greedy", | |
| "torch_dtype": "bfloat16", | |
| "use_mla": false, | |
| "v_head_dim": 32, | |
| "vocab_size": 129280, | |
| "head_dim": 32 | |
| }, | |
| "lm_head": true, | |
| "max_position_embeddings": 131072, | |
| "model_type": "unlimited-ocr", | |
| "moe_intermediate_size": 64, | |
| "moe_layer_freq": 1, | |
| "n_group": 1, | |
| "n_routed_experts": 16, | |
| "n_shared_experts": 2, | |
| "norm_topk_prob": false, | |
| "num_attention_heads": 4, | |
| "num_experts_per_tok": 6, | |
| "num_hidden_layers": 4, | |
| "num_key_value_heads": 4, | |
| "pad_token_id": 2, | |
| "pretraining_tp": 1, | |
| "projector_config": { | |
| "input_dim": 64, | |
| "model_type": "mlp_projector", | |
| "n_embed": 32, | |
| "projector_type": "linear" | |
| }, | |
| "q_lora_rank": null, | |
| "qk_nope_head_dim": 0, | |
| "qk_rope_head_dim": 0, | |
| "rm_head": false, | |
| "rms_norm_eps": 1e-06, | |
| "rope_scaling": { | |
| "attention_factor": 1.0, | |
| "beta_fast": 32, | |
| "beta_slow": 1, | |
| "factor": 4.0, | |
| "original_max_position_embeddings": 32768, | |
| "rope_type": "yarn", | |
| "type": "yarn" | |
| }, | |
| "rope_theta": 500000.0, | |
| "routed_scaling_factor": 1.0, | |
| "scoring_func": "softmax", | |
| "seq_aux": true, | |
| "sliding_window": null, | |
| "sliding_window_size": 128, | |
| "sparse_attention_config": { | |
| "dash_floor_per_layer": [ | |
| 0.0001, | |
| 0.0001, | |
| 0.0001, | |
| 0.0001 | |
| ], | |
| "dash_image_only": true, | |
| "dash_prior_floor": 0.0001, | |
| "dash_query_chunk": 2048, | |
| "dash_router": "entmax_topk_perlayer", | |
| "dash_scale_per_layer": [ | |
| 128.0, | |
| 128.0, | |
| 128.0, | |
| 128.0 | |
| ], | |
| "dash_scaling_factor": 128.0, | |
| "dash_sigma": 1.0, | |
| "dash_stage0": "head_cls", | |
| "dash_topk_blocks": 12, | |
| "dash_use_triton": true, | |
| "image_bucket_constraint": true, | |
| "image_token_id": 128815, | |
| "kl_chunk_size": 1024, | |
| "kl_log_interval": 1, | |
| "kl_loss_weight": 1.0, | |
| "page_token_id": 128827, | |
| "per_page_image_tokens": 273, | |
| "sparse_attention_freq": [ | |
| 1, | |
| 1, | |
| 1, | |
| 1 | |
| ], | |
| "sparse_block_size": 32, | |
| "sparse_index_dim": 32, | |
| "sparse_init_block": 1, | |
| "sparse_local_block": 4, | |
| "sparse_main_rope_mode": "page2d", | |
| "sparse_main_rope_tok_freq_mode": "resample", | |
| "sparse_num_index_heads": 1, | |
| "sparse_rope_mode": "page2d", | |
| "sparse_rope_page_mod": 2, | |
| "sparse_rope_page_pairs": 1, | |
| "sparse_rope_page_span": 0, | |
| "sparse_rope_page_theta": 256.0, | |
| "sparse_rope_theta": 500000.0, | |
| "sparse_rope_tok_freq_mode": "resample", | |
| "sparse_rope_tok_theta": 10000.0, | |
| "sparse_topk_blocks": 16, | |
| "training_stage": "dash", | |
| "use_flex_attention": false, | |
| "use_kl_loss": false, | |
| "use_sparse_attention": true, | |
| "use_xformers": false | |
| }, | |
| "tie_word_embeddings": false, | |
| "tile_tag": "2D", | |
| "topk_group": 1, | |
| "topk_method": "greedy", | |
| "torch_dtype": "bfloat16", | |
| "transformers_version": "4.52.1", | |
| "use_cache": false, | |
| "use_mla": false, | |
| "v_head_dim": 32, | |
| "vision_config": { | |
| "image_size": 1024, | |
| "mlp_ratio": 3.7362, | |
| "model_name": "deeplip_b_l", | |
| "model_type": "vision", | |
| "width": { | |
| "clip-l-14-224": { | |
| "heads": 4, | |
| "image_size": 224, | |
| "layers": 4, | |
| "patch_size": 14, | |
| "width": 32 | |
| }, | |
| "sam_vit_b": { | |
| "downsample_channels": [ | |
| 16, | |
| 32 | |
| ], | |
| "global_attn_indexes": [ | |
| 2, | |
| 5 | |
| ], | |
| "heads": 4, | |
| "layers": 6, | |
| "width": 32, | |
| "neck_channels": 8 | |
| } | |
| } | |
| }, | |
| "vocab_size": 129280, | |
| "head_dim": 32 | |
| } | |