Instructions to use zai-org/GLM-Z1-32B-0414 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/GLM-Z1-32B-0414 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="zai-org/GLM-Z1-32B-0414") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("zai-org/GLM-Z1-32B-0414") model = AutoModelForCausalLM.from_pretrained("zai-org/GLM-Z1-32B-0414") messages = [ {"role": "user", "content": "Who are you?"}, ] 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-Z1-32B-0414 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zai-org/GLM-Z1-32B-0414" # 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-Z1-32B-0414", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/zai-org/GLM-Z1-32B-0414
- SGLang
How to use zai-org/GLM-Z1-32B-0414 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-Z1-32B-0414" \ --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-Z1-32B-0414", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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-Z1-32B-0414" \ --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-Z1-32B-0414", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use zai-org/GLM-Z1-32B-0414 with Docker Model Runner:
docker model run hf.co/zai-org/GLM-Z1-32B-0414
zRzRzRzRzRzRzR commited on
Commit ·
013871a
1
Parent(s): 6913792
LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
MIT License
|
| 2 |
|
| 3 |
-
Copyright (c) 2025
|
| 4 |
|
| 5 |
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
| 1 |
MIT License
|
| 2 |
|
| 3 |
+
Copyright (c) 2025 Zhipu AI
|
| 4 |
|
| 5 |
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
of this software and associated documentation files (the "Software"), to deal
|
README.md
CHANGED
|
@@ -1,51 +1,45 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
language:
|
| 4 |
-
- zh
|
| 5 |
-
- en
|
| 6 |
-
pipeline_tag: text-generation
|
| 7 |
-
library_name: transformers
|
| 8 |
-
---
|
| 9 |
-
|
| 10 |
-
# GLM-4-Z1-32B-0414
|
| 11 |
-
|
| 12 |
-
## Introduction
|
| 13 |
-
|
| 14 |
-
Based on our latest technological advancements, we have trained a `GLM-4-0414` series model. During pretraining, we incorporated more code-related and reasoning-related data. In the alignment phase, we optimized the model specifically for agent capabilities. As a result, the model's performance in agent tasks such as tool use, web search, and coding has been significantly improved.
|
| 15 |
-
|
| 16 |
-
##
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
```
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
"attention_mask": inputs["attention_mask"],
|
| 46 |
-
"max_new_tokens": 4096,
|
| 47 |
-
"do_sample": False,
|
| 48 |
-
}
|
| 49 |
-
out = model.generate(**generate_kwargs)
|
| 50 |
-
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
| 51 |
```
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- zh
|
| 5 |
+
- en
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
library_name: transformers
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# GLM-4-Z1-32B-0414
|
| 11 |
+
|
| 12 |
+
## Introduction
|
| 13 |
+
|
| 14 |
+
Based on our latest technological advancements, we have trained a `GLM-4-0414` series model. During pretraining, we incorporated more code-related and reasoning-related data. In the alignment phase, we optimized the model specifically for agent capabilities. As a result, the model's performance in agent tasks such as tool use, web search, and coding has been significantly improved.
|
| 15 |
+
|
| 16 |
+
## Inference Code
|
| 17 |
+
|
| 18 |
+
Make Sure Using `transforemrs>=4.51.3`.
|
| 19 |
+
|
| 20 |
+
```python
|
| 21 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 22 |
+
|
| 23 |
+
MODEL_PATH = "THUDM/GLM-4-Z1-32B-0414"
|
| 24 |
+
|
| 25 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
|
| 26 |
+
model = AutoModelForCausalLM.from_pretrained(MODEL_PATH, device_map="auto")
|
| 27 |
+
|
| 28 |
+
message = [{"role": "user", "content": "Let a, b be positive real numbers such that ab = a + b + 3. Determine the range of possible values for a + b."}]
|
| 29 |
+
|
| 30 |
+
inputs = tokenizer.apply_chat_template(
|
| 31 |
+
message,
|
| 32 |
+
return_tensors="pt",
|
| 33 |
+
add_generation_prompt=True,
|
| 34 |
+
return_dict=True,
|
| 35 |
+
).to(model.device)
|
| 36 |
+
|
| 37 |
+
generate_kwargs = {
|
| 38 |
+
"input_ids": inputs["input_ids"],
|
| 39 |
+
"attention_mask": inputs["attention_mask"],
|
| 40 |
+
"max_new_tokens": 4096,
|
| 41 |
+
"do_sample": False,
|
| 42 |
+
}
|
| 43 |
+
out = model.generate(**generate_kwargs)
|
| 44 |
+
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
```
|