Instructions to use tiny-random/minicpm-ocr-jev with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/minicpm-ocr-jev 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-jev") 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, AutoModelForSequenceClassification processor = AutoProcessor.from_pretrained("tiny-random/minicpm-ocr-jev") model = AutoModelForSequenceClassification.from_pretrained("tiny-random/minicpm-ocr-jev", 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-jev 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-jev" # 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-jev", "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-jev
- SGLang
How to use tiny-random/minicpm-ocr-jev 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-jev" \ --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-jev", "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-jev" \ --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-jev", "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-jev with Docker Model Runner:
docker model run hf.co/tiny-random/minicpm-ocr-jev
|
Download README.md from tiny-random/minicpm-ocr-jev: direct link, hf CLI and curl.
- Browser
- Download file 4.13 kB
-
https://huggingface.co/tiny-random/minicpm-ocr-jev/resolve/main/README.md
- Command line
-
hf download hf://tiny-random/minicpm-ocr-jev/README.md
-
curl -L -o README.md https://huggingface.co/tiny-random/minicpm-ocr-jev/resolve/main/README.md
4.13 kB
| library_name: transformers | |
| pipeline_tag: image-text-to-text | |
| base_model: | |
| - openbmb/MiniCPM-OCR-Jev | |
| This is a randomly initialized tiny model based on [openbmb/MiniCPM-OCR-Jev](https://huggingface.co/openbmb/MiniCPM-OCR-Jev) for testing and debugging. | |
| | Feature | Source | This repo | | |
| |---|---|---| | |
| | Checkpoint tensor elements | 2.21B BF16 | 6.64M BF16 | | |
| | Safetensors weight files | 4.43 GB (model.safetensors) | 13.31 MB (model.safetensors) | | |
| | Architecture / input | Qwen3.5 vision-language correctness scorer | Same | | |
| | Vocabulary rows / tied embeddings | 248,320 / false | Same | | |
| | Backbone layers / layer cadence | 24 / six 3-linear + 1-full cycles | 8 / two complete cycles | | |
| | Hidden width / MLP width | 2,048 / 6,144 | 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 depth / width / output width | 24 / 1,024 / 2,048 | 4 / 128 / 16 | | |
| | Vision patch / temporal patch / spatial merge | 16 / 2 / 2 | Same | | |
| | Task head | binary `score` [2, 2,048]; no `lm_head` | binary `score` [2, 16]; no `lm_head` | | |
| | MTP | config declares one layer; no MTP tensors | Same | | |
| | Checkpoint precision | BF16 | Same | | |
| Load this checkpoint with `AutoModelForSequenceClassification`; it keeps the source binary `score` head and does not contain `lm_head`. 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 | 13.3MB | | |
| ### Example usage | |
| #### Transformers (✅ verified) | |
| The example sends two images: the original block and a rendered image of the candidate text. Load with `AutoModelForSequenceClassification`; the checkpoint has a binary `score` head instead of `lm_head`. Install `transformers>=5.10.4` and `Pillow`; the Qwen3.5 linear-attention path requires CUDA and Triton. | |
| ```python | |
| def run_transformers(model_id: str): | |
| import torch | |
| from PIL import Image, ImageDraw | |
| from transformers import AutoModelForSequenceClassification, AutoProcessor | |
| model_id = str(model_id) | |
| processor = AutoProcessor.from_pretrained(model_id) | |
| model = AutoModelForSequenceClassification.from_pretrained( | |
| model_id, | |
| dtype=torch.bfloat16, | |
| device_map="cuda", | |
| attn_implementation="sdpa", | |
| ) | |
| candidate = "Hello" | |
| original = Image.new("RGB", (448, 448), "white") | |
| ImageDraw.Draw(original).text((20, 20), candidate, fill="black") | |
| rendered = Image.new("RGB", (448, 448), "white") | |
| ImageDraw.Draw(rendered).text((20, 20), candidate, fill="black") | |
| instruction = ( | |
| "第一张图是原图,第二张图是上述 OCR 文本渲染得到的图片。\n" | |
| "请判断该 OCR 文本及其对应渲染图是否与原图内容一致。\n" | |
| "这是一个二分类任务:一致标为 1,不一致标为 0。" | |
| ) | |
| messages = [ | |
| { | |
| "role": "user", | |
| "content": [ | |
| {"type": "image", "image": original}, | |
| {"type": "text", "text": f"\nOCR文本:\n{candidate}\n"}, | |
| {"type": "image", "image": rendered}, | |
| {"type": "text", "text": "\n" + instruction}, | |
| ], | |
| } | |
| ] | |
| inputs = processor.apply_chat_template( | |
| messages, | |
| tokenize=True, | |
| add_generation_prompt=True, | |
| return_dict=True, | |
| return_tensors="pt", | |
| ).to(model.device) | |
| with torch.no_grad(): | |
| logits = model(**inputs).logits | |
| assert torch.isfinite(logits).all() | |
| score = torch.softmax(logits.float(), dim=-1)[:, 1] | |
| print(float(score[0])) | |
| if __name__ == "__main__": | |
| run_transformers(model_id="tiny-random/minicpm-ocr-jev") | |
| ``` | |
| ### 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 Jev checkpoint. | |
| *This repo is generated by DeepSeek-V4.1-Flash.* |