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, AutoModelForImageTextToText tokenizer = AutoTokenizer.from_pretrained("zai-org/GLM-OCR") model = AutoModelForImageTextToText.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
- 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
Tag as image-to-text (revert https://huggingface.co/zai-org/GLM-OCR/discussions/57)
#58 opened 5 days ago
by
Wauplin
ValueError: Task 'image-to-text' not supported for provider 'zai-org'. Available tasks: ['conversational', 'text-to-image']
#56 opened 9 days ago
by
procioni
Please support vietnamese
#55 opened 18 days ago
by
Duonglv
Add ParseBench evaluation results
#53 opened about 1 month ago
by
boyang-runllama
Inconsistent results
#50 opened about 1 month ago
by
TheMrguiller
'image-to-text' not supported for provider 'zai-org'
#49 opened about 1 month ago
by
BelegNeurion
instructions dont do anything is there way to actualy make it listen to it?
#48 opened about 2 months ago
by
dimitarx
Retail Flyer - Constant hallucination despite prompt injection.
#47 opened about 2 months ago
by
bradomni
What is the testing setup?
2
#46 opened 2 months ago
by
wamreyaz
Why does the chat template include reasoning/thinking components?
👀 1
#45 opened 2 months ago
by
usrlocalben
Critical Hallucinations and Cross-Script Confusion in Multilingual Stress Test (CJK + Cyrillic)
3
#42 opened 3 months ago
by
The1Just
Upload Covid Instructions.jpg
#40 opened 3 months ago
by
manikandannet
📋 Documentation Enhancement Suggestion
#38 opened 3 months ago
by
CroviaTrust
Easy install without transformers
👍 1
#35 opened 3 months ago
by
PartyParrot
how to start with zero knowledge ?
🤗 1
1
#32 opened 3 months ago
by
JRYAN723
this is good
#29 opened 3 months ago
by
n0tdapo
Table regonition doesn't work well for multiple table
5
#28 opened 3 months ago
by
OumarDicko
Please Add the ARABIC language also
4
#26 opened 3 months ago
by
ANASDAVOODTK
MTP and trading
#22 opened 3 months ago
by
Maryann8106
jkhjk
1
#19 opened 3 months ago
by
nameless98
Rename README.md to READing
1
#18 opened 4 months ago
by
Lyonblaze
what do we really have to know
3
#17 opened 4 months ago
by
smarttech445
Update README.md
#16 opened 4 months ago
by
wisemansaids
GLM-OCR very slow on Tesla T4 (~40s per image) even with GPU — is this expected?
4
#13 opened 4 months ago
by
905saini
Could this model extract text location or coordinate?
3
#12 opened 4 months ago
by
ExChaosen
Training data details - sources and license
#11 opened 4 months ago
by
nramrakhiyani
Requesting Example for Structured Information Extraction via cURL
👍 3
2
#10 opened 4 months ago
by
andynoodles
No text output inferencing with ollama?
➕ 3
11
#8 opened 4 months ago
by
frankslin
GLM-OCR: A Tiny 0.9B-Parameter Model That Punches Far Above Its Weight
🤗 3
1
#7 opened 4 months ago
by
Javedalam
When will there be better support for vLLM?
6
#6 opened 4 months ago
by
Xiakj
Installation Video and Testing - Step by Step
❤️🤗 5
1
#1 opened 4 months ago
by
fahdmirzac