Instructions to use zai-org/GLM-OCR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/GLM-OCR with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="zai-org/GLM-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)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("zai-org/GLM-OCR") model = AutoModelForMultimodalLM.from_pretrained("zai-org/GLM-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?"} ] }, ] inputs = tokenizer.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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zai-org/GLM-OCR with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zai-org/GLM-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": "zai-org/GLM-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/zai-org/GLM-OCR
- SGLang
How to use zai-org/GLM-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 "zai-org/GLM-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": "zai-org/GLM-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 "zai-org/GLM-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": "zai-org/GLM-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 zai-org/GLM-OCR with Docker Model Runner:
docker model run hf.co/zai-org/GLM-OCR
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: overall | |
| value: 67.3 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: digital | |
| value: 77.9 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: photographed | |
| value: 63.7 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: latin | |
| value: 78.7 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: de | |
| value: 82.7 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: en | |
| value: 84.5 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: es | |
| value: 75.8 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: fr | |
| value: 76.2 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: id | |
| value: 79.7 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: it | |
| value: 82.8 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: nl | |
| value: 80.2 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: pt | |
| value: 77.4 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: vi | |
| value: 69.2 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: non_latin | |
| value: 54.3 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: ar | |
| value: 21.7 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: hi | |
| value: 39.6 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: jp | |
| value: 65.5 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: ko | |
| value: 61.2 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: ru | |
| value: 64.2 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: th | |
| value: 27.4 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: zh | |
| value: 78.5 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |
| - dataset: | |
| id: Delores-Lin/MDPBench | |
| task_id: zh_t | |
| value: 76.7 | |
| date: "2026-04-14" | |
| source: | |
| url: https://huggingface.co/datasets/Delores-Lin/MDPBench | |
| name: MDPBench leaderboard | |
| user: Delores-Lin | |