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
- 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
zR commited on
Add files using upload-large-folder tool
Browse files- config.json +76 -0
config.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Glm4vMoeForConditionalGeneration"
|
| 4 |
+
],
|
| 5 |
+
"model_type": "glm4v_moe",
|
| 6 |
+
"text_config": {
|
| 7 |
+
"pad_token_id": 151329,
|
| 8 |
+
"vocab_size": 151552,
|
| 9 |
+
"eos_token_id": [
|
| 10 |
+
151329,
|
| 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,
|
| 20 |
+
"first_k_dense_replace": 1,
|
| 21 |
+
"hidden_act": "silu",
|
| 22 |
+
"hidden_size": 4096,
|
| 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,
|
| 30 |
+
"n_shared_experts": 1,
|
| 31 |
+
"norm_topk_prob": true,
|
| 32 |
+
"num_attention_heads": 96,
|
| 33 |
+
"num_experts_per_tok": 8,
|
| 34 |
+
"num_hidden_layers": 46,
|
| 35 |
+
"num_key_value_heads": 8,
|
| 36 |
+
"partial_rotary_factor": 0.5,
|
| 37 |
+
"rms_norm_eps": 1e-05,
|
| 38 |
+
"torch_dtype": "bfloat16",
|
| 39 |
+
"rope_scaling": {
|
| 40 |
+
"rope_type": "default",
|
| 41 |
+
"mrope_section": [
|
| 42 |
+
8,
|
| 43 |
+
12,
|
| 44 |
+
12
|
| 45 |
+
]
|
| 46 |
+
},
|
| 47 |
+
"rope_theta": 10000.0,
|
| 48 |
+
"routed_scaling_factor": 1.0,
|
| 49 |
+
"topk_group": 1,
|
| 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,
|
| 62 |
+
"hidden_act": "silu",
|
| 63 |
+
"hidden_size": 1536,
|
| 64 |
+
"image_size": 336,
|
| 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,
|
| 72 |
+
"rms_norm_eps": 1e-05,
|
| 73 |
+
"spatial_merge_size": 2,
|
| 74 |
+
"temporal_patch_size": 2
|
| 75 |
+
}
|
| 76 |
+
}
|