Instructions to use zai-org/GLM-4.1V-9B-Thinking with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/GLM-4.1V-9B-Thinking 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.1V-9B-Thinking") 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.1V-9B-Thinking") model = AutoModelForImageTextToText.from_pretrained("zai-org/GLM-4.1V-9B-Thinking") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zai-org/GLM-4.1V-9B-Thinking 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.1V-9B-Thinking" # 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.1V-9B-Thinking", "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.1V-9B-Thinking
- SGLang
How to use zai-org/GLM-4.1V-9B-Thinking 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.1V-9B-Thinking" \ --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.1V-9B-Thinking", "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.1V-9B-Thinking" \ --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.1V-9B-Thinking", "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.1V-9B-Thinking with Docker Model Runner:
docker model run hf.co/zai-org/GLM-4.1V-9B-Thinking
zRzRzRzRzRzRzR commited on
Commit ·
def1e44
1
Parent(s): 3e29ece
set 64000 to 65536
Browse files- config.json +1 -1
- tokenizer_config.json +1 -1
config.json
CHANGED
|
@@ -22,7 +22,7 @@
|
|
| 22 |
"hidden_size": 4096,
|
| 23 |
"initializer_range": 0.02,
|
| 24 |
"intermediate_size": 13696,
|
| 25 |
-
"max_position_embeddings":
|
| 26 |
"num_attention_heads": 32,
|
| 27 |
"num_hidden_layers": 40,
|
| 28 |
"num_key_value_heads": 2,
|
|
|
|
| 22 |
"hidden_size": 4096,
|
| 23 |
"initializer_range": 0.02,
|
| 24 |
"intermediate_size": 13696,
|
| 25 |
+
"max_position_embeddings": 65536,
|
| 26 |
"num_attention_heads": 32,
|
| 27 |
"num_hidden_layers": 40,
|
| 28 |
"num_key_value_heads": 2,
|
tokenizer_config.json
CHANGED
|
@@ -211,7 +211,7 @@
|
|
| 211 |
"input_ids",
|
| 212 |
"attention_mask"
|
| 213 |
],
|
| 214 |
-
"model_max_length":
|
| 215 |
"padding_side": "left",
|
| 216 |
"remove_space": false,
|
| 217 |
"tokenizer_class": "PreTrainedTokenizer"
|
|
|
|
| 211 |
"input_ids",
|
| 212 |
"attention_mask"
|
| 213 |
],
|
| 214 |
+
"model_max_length": 65536,
|
| 215 |
"padding_side": "left",
|
| 216 |
"remove_space": false,
|
| 217 |
"tokenizer_class": "PreTrainedTokenizer"
|