Instructions to use tiny-random/minicpm-ocr-1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/minicpm-ocr-1.0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="tiny-random/minicpm-ocr-1.0") 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("tiny-random/minicpm-ocr-1.0") model = AutoModelForMultimodalLM.from_pretrained("tiny-random/minicpm-ocr-1.0", 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 tiny-random/minicpm-ocr-1.0 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/minicpm-ocr-1.0" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/minicpm-ocr-1.0", "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/tiny-random/minicpm-ocr-1.0
- SGLang
How to use tiny-random/minicpm-ocr-1.0 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/minicpm-ocr-1.0" \ --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": "tiny-random/minicpm-ocr-1.0", "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 "tiny-random/minicpm-ocr-1.0" \ --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": "tiny-random/minicpm-ocr-1.0", "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 tiny-random/minicpm-ocr-1.0 with Docker Model Runner:
docker model run hf.co/tiny-random/minicpm-ocr-1.0
|
Download README.md from tiny-random/minicpm-ocr-1.0: direct link, hf CLI and curl.
- Browser
- Download file 3.47 kB
-
https://huggingface.co/tiny-random/minicpm-ocr-1.0/resolve/main/README.md
- Command line
-
hf download hf://tiny-random/minicpm-ocr-1.0/README.md
-
curl -L -o README.md https://huggingface.co/tiny-random/minicpm-ocr-1.0/resolve/main/README.md
3.47 kB
| library_name: transformers | |
| pipeline_tag: image-text-to-text | |
| base_model: | |
| - openbmb/MiniCPM-OCR-1.0 | |
| This is a randomly initialized tiny model based on [openbmb/MiniCPM-OCR-1.0](https://huggingface.co/openbmb/MiniCPM-OCR-1.0) for testing and debugging. | |
| | Feature | Source | This repo | | |
| |---|---|---| | |
| | Checkpoint tensor elements | 1.30B BF16 | 7.58M BF16 | | |
| | Safetensors weight files | 2.60 GB (model.safetensors) | 15.18 MB (model.safetensors) | | |
| | Architecture / input | MiniCPM-OCR; text and document image | Same | | |
| | Vocabulary rows / tied embeddings | 248,100 / tied | Same | | |
| | Backbone layers / layer cadence | 24 / six 3-linear + 1-full cycles | 8 / two complete cycles | | |
| | Hidden width / MLP width | 1,024 / 3,584 | 16 / 32 | | |
| | Q heads / KV heads / head dimension | 8 / 2 / 256 | Same | | |
| | Linear-attention key/value heads and dimensions | 16/16, 128/128 | Same | | |
| | Vision layers / width / insert merger | 27 / 1,152 / after layer 6 | 4 / 128 / after layer 2 | | |
| | Visual downsampling | 4x | Same | | |
| | M-RoPE | sections 11/11/10; partial 0.25 | sections 11/11/10; partial 0.25 | | |
| | MTP | disabled | Same | | |
| | Checkpoint precision | BF16 | Same | | |
| The tokenizer embedding and output head stay tied, so the checkpoint contains one BF16 token table. Two complete linear/linear/linear/full cycles are retained. The Qwen3.5 linear-attention path requires CUDA and Triton. The exact public snippet was verified on an NVIDIA A800-SXM4-80GB. | |
| | File path | Size | | |
| |------|------| | |
| | model.safetensors | 15.2MB | | |
| ### Example usage | |
| #### Transformers (✅ verified) | |
| The Qwen3.5 linear-attention path requires CUDA and Triton. Install `transformers[torch]>=5.21.0` and `Pillow`. | |
| ```python | |
| def run_transformers(model_id: str): | |
| import torch | |
| from PIL import Image, ImageDraw | |
| from transformers import AutoModelForImageTextToText, AutoProcessor | |
| model_id = str(model_id) | |
| processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True) | |
| model = AutoModelForImageTextToText.from_pretrained( | |
| model_id, | |
| dtype=torch.bfloat16, | |
| device_map="cuda", | |
| attn_implementation="sdpa", | |
| ) | |
| image = Image.new("RGB", (448, 448), "white") | |
| ImageDraw.Draw(image).text((20, 20), "Hello OCR", fill="black") | |
| messages = [ | |
| { | |
| "role": "user", | |
| "content": [ | |
| {"type": "image", "image": image}, | |
| {"type": "text", "text": "Read this document."}, | |
| ], | |
| } | |
| ] | |
| inputs = processor.apply_chat_template( | |
| messages, | |
| tokenize=True, | |
| add_generation_prompt=True, | |
| return_dict=True, | |
| return_tensors="pt", | |
| downsample_mode="4x", | |
| max_slice_nums=1, | |
| use_image_id=False, | |
| ).to(model.device) | |
| with torch.no_grad(): | |
| logits = model(**inputs).logits | |
| assert torch.isfinite(logits).all() | |
| output = model.generate(**inputs, downsample_mode="4x", do_sample=False, max_new_tokens=10) | |
| print(processor.decode(output[0, inputs["input_ids"].shape[1] :], skip_special_tokens=True)) | |
| if __name__ == "__main__": | |
| run_transformers(model_id="tiny-random/minicpm-ocr-1.0") | |
| ``` | |
| ### Creating this repo | |
| - Code: [.meta/create_model.py](.meta/create_model.py) | |
| - Model structure: [.meta/model.log](.meta/model.log) | |
| - Environment: [.meta/env.json](.meta/env.json) | |
| ### Change log | |
| - 2026-11-01: Initial tiny MiniCPM-OCR 1.0 checkpoint. | |
| *This repo is generated by DeepSeek-V4.1-Flash.* |