Instructions to use zai-org/GLM-4.5V with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/GLM-4.5V with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="zai-org/GLM-4.5V") 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 AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("zai-org/GLM-4.5V") model = AutoModelForImageTextToText.from_pretrained("zai-org/GLM-4.5V") 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zai-org/GLM-4.5V with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zai-org/GLM-4.5V" # 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-4.5V", "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-4.5V
- SGLang
How to use zai-org/GLM-4.5V 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-4.5V" \ --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-4.5V", "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-4.5V" \ --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-4.5V", "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-4.5V with Docker Model Runner:
docker model run hf.co/zai-org/GLM-4.5V
zRzRzRzRzRzRzR commited on
Commit ·
f33f585
1
Parent(s): a78e5f2
update for new format config of transformers lib / sglang lib
Browse files- README.md +3 -3
- config.json +10 -10
- generation_config.json +1 -1
README.md
CHANGED
|
@@ -86,14 +86,14 @@ GLM-4.1V-9B-Thinking integrates the **Chain-of-Thought** reasoning mechanism, im
|
|
| 86 |
For `SGLang` and `transformers`:
|
| 87 |
|
| 88 |
```bash
|
| 89 |
-
pip install
|
|
|
|
| 90 |
```
|
| 91 |
|
| 92 |
For `vLLM`:
|
| 93 |
|
| 94 |
```bash
|
| 95 |
-
pip install
|
| 96 |
-
pip install transformers-v4.55.0-GLM-4.5V-preview
|
| 97 |
```
|
| 98 |
|
| 99 |
### Quick Start with Transformers
|
|
|
|
| 86 |
For `SGLang` and `transformers`:
|
| 87 |
|
| 88 |
```bash
|
| 89 |
+
pip install transformers>=4.57.1
|
| 90 |
+
pip install sglang>=0.5.3
|
| 91 |
```
|
| 92 |
|
| 93 |
For `vLLM`:
|
| 94 |
|
| 95 |
```bash
|
| 96 |
+
pip install vllm>=0.10.2
|
|
|
|
| 97 |
```
|
| 98 |
|
| 99 |
### Quick Start with Transformers
|
config.json
CHANGED
|
@@ -3,7 +3,16 @@
|
|
| 3 |
"Glm4vMoeForConditionalGeneration"
|
| 4 |
],
|
| 5 |
"model_type": "glm4v_moe",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
"text_config": {
|
|
|
|
| 7 |
"pad_token_id": 151329,
|
| 8 |
"vocab_size": 151552,
|
| 9 |
"eos_token_id": [
|
|
@@ -11,9 +20,6 @@
|
|
| 11 |
151336,
|
| 12 |
151338
|
| 13 |
],
|
| 14 |
-
"image_end_token_id": 151340,
|
| 15 |
-
"image_start_token_id": 151339,
|
| 16 |
-
"image_token_id": 151363,
|
| 17 |
"head_dim": 128,
|
| 18 |
"attention_bias": true,
|
| 19 |
"attention_dropout": 0.0,
|
|
@@ -23,7 +29,6 @@
|
|
| 23 |
"initializer_range": 0.02,
|
| 24 |
"intermediate_size": 10944,
|
| 25 |
"max_position_embeddings": 65536,
|
| 26 |
-
"model_type": "glm4v_moe_text",
|
| 27 |
"moe_intermediate_size": 1408,
|
| 28 |
"n_group": 1,
|
| 29 |
"n_routed_experts": 128,
|
|
@@ -50,12 +55,8 @@
|
|
| 50 |
"use_cache": true,
|
| 51 |
"use_qk_norm": false
|
| 52 |
},
|
| 53 |
-
"torch_dtype": "bfloat16",
|
| 54 |
-
"transformers_version": "4.55.0.dev0",
|
| 55 |
-
"video_end_token_id": 151342,
|
| 56 |
-
"video_start_token_id": 151341,
|
| 57 |
-
"video_token_id": 151364,
|
| 58 |
"vision_config": {
|
|
|
|
| 59 |
"attention_bias": false,
|
| 60 |
"attention_dropout": 0.0,
|
| 61 |
"depth": 24,
|
|
@@ -65,7 +66,6 @@
|
|
| 65 |
"in_channels": 3,
|
| 66 |
"initializer_range": 0.02,
|
| 67 |
"intermediate_size": 10944,
|
| 68 |
-
"model_type": "glm4v_moe",
|
| 69 |
"num_heads": 12,
|
| 70 |
"out_hidden_size": 4096,
|
| 71 |
"patch_size": 14,
|
|
|
|
| 3 |
"Glm4vMoeForConditionalGeneration"
|
| 4 |
],
|
| 5 |
"model_type": "glm4v_moe",
|
| 6 |
+
"image_start_token_id": 151339,
|
| 7 |
+
"image_end_token_id": 151340,
|
| 8 |
+
"video_start_token_id": 151341,
|
| 9 |
+
"video_end_token_id": 151342,
|
| 10 |
+
"image_token_id": 151363,
|
| 11 |
+
"video_token_id": 151364,
|
| 12 |
+
"tie_word_embeddings": false,
|
| 13 |
+
"transformers_version": "4.57.1",
|
| 14 |
"text_config": {
|
| 15 |
+
"model_type": "glm4v_moe_text",
|
| 16 |
"pad_token_id": 151329,
|
| 17 |
"vocab_size": 151552,
|
| 18 |
"eos_token_id": [
|
|
|
|
| 20 |
151336,
|
| 21 |
151338
|
| 22 |
],
|
|
|
|
|
|
|
|
|
|
| 23 |
"head_dim": 128,
|
| 24 |
"attention_bias": true,
|
| 25 |
"attention_dropout": 0.0,
|
|
|
|
| 29 |
"initializer_range": 0.02,
|
| 30 |
"intermediate_size": 10944,
|
| 31 |
"max_position_embeddings": 65536,
|
|
|
|
| 32 |
"moe_intermediate_size": 1408,
|
| 33 |
"n_group": 1,
|
| 34 |
"n_routed_experts": 128,
|
|
|
|
| 55 |
"use_cache": true,
|
| 56 |
"use_qk_norm": false
|
| 57 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
"vision_config": {
|
| 59 |
+
"model_type": "glm4v_moe",
|
| 60 |
"attention_bias": false,
|
| 61 |
"attention_dropout": 0.0,
|
| 62 |
"depth": 24,
|
|
|
|
| 66 |
"in_channels": 3,
|
| 67 |
"initializer_range": 0.02,
|
| 68 |
"intermediate_size": 10944,
|
|
|
|
| 69 |
"num_heads": 12,
|
| 70 |
"out_hidden_size": 4096,
|
| 71 |
"patch_size": 14,
|
generation_config.json
CHANGED
|
@@ -10,5 +10,5 @@
|
|
| 10 |
"temperature": 1.0,
|
| 11 |
"top_k": 1,
|
| 12 |
"top_p": 0.0001,
|
| 13 |
-
"transformers_version": "4.
|
| 14 |
}
|
|
|
|
| 10 |
"temperature": 1.0,
|
| 11 |
"top_k": 1,
|
| 12 |
"top_p": 0.0001,
|
| 13 |
+
"transformers_version": "4.57.1"
|
| 14 |
}
|