Improve model card with paper link, system requirements, and sample usage

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +154 -5
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
- license: mit
3
  language:
4
  - en
5
  - zh
6
- pipeline_tag: text-generation
7
  library_name: transformers
 
 
8
  ---
9
 
10
  # GLM-4.5-Air-Base
@@ -21,7 +21,9 @@ library_name: transformers
21
  <br>
22
  👉 One click to <a href="https://chat.z.ai">GLM-4.5</a>.
23
  </p>
24
-
 
 
25
  ## Model Introduction
26
 
27
  The **GLM-4.5** series models are foundation models designed for intelligent agents. GLM-4.5 has **355** billion total parameters with **32** billion active parameters, while GLM-4.5-Air adopts a more compact design with **106** billion total parameters and **12** billion active parameters. GLM-4.5 models unify reasoning, coding, and intelligent agent capabilities to meet the complex demands of intelligent agent applications.
@@ -30,7 +32,7 @@ Both GLM-4.5 and GLM-4.5-Air are hybrid reasoning models that provide two modes:
30
 
31
  We have open-sourced the base models, hybrid reasoning models, and FP8 versions of the hybrid reasoning models for both GLM-4.5 and GLM-4.5-Air. They are released under the MIT open-source license and can be used commercially and for secondary development.
32
 
33
- As demonstrated in our comprehensive evaluation across 12 industry-standard benchmarks, GLM-4.5 achieves exceptional performance with a score of **63.2**, in the **3rd** place among all the proprietary and open-source models. Notably, GLM-4.5-Air delivers competitive results at **59.8** while maintaining superior efficiency.
34
 
35
  ![bench](https://raw.githubusercontent.com/zai-org/GLM-4.5/refs/heads/main/resources/bench.png)
36
 
@@ -39,8 +41,155 @@ our [technical blog](https://z.ai/blog/glm-4.5). The technical report will be re
39
 
40
  The model code, tool parser and reasoning parser can be found in the implementation of [transformers](https://github.com/huggingface/transformers/tree/main/src/transformers/models/glm4_moe), [vLLM](https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/glm4_moe_mtp.py) and [SGLang](https://github.com/sgl-project/sglang/blob/main/python/sglang/srt/models/glm4_moe.py).
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  ## Quick Start
43
 
44
  **Note**: This is a base model, not for chat.
45
 
46
- Please refer to our [github page](https://github.com/zai-org/GLM-4.5) for more details.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
 
2
  language:
3
  - en
4
  - zh
 
5
  library_name: transformers
6
+ license: mit
7
+ pipeline_tag: text-generation
8
  ---
9
 
10
  # GLM-4.5-Air-Base
 
21
  <br>
22
  👉 One click to <a href="https://chat.z.ai">GLM-4.5</a>.
23
  </p>
24
+
25
+ This repository contains the base model presented in the paper [GLM-4.5: Agentic, Reasoning, and Coding (ARC) Foundation Models](https://huggingface.co/papers/2508.06471).
26
+
27
  ## Model Introduction
28
 
29
  The **GLM-4.5** series models are foundation models designed for intelligent agents. GLM-4.5 has **355** billion total parameters with **32** billion active parameters, while GLM-4.5-Air adopts a more compact design with **106** billion total parameters and **12** billion active parameters. GLM-4.5 models unify reasoning, coding, and intelligent agent capabilities to meet the complex demands of intelligent agent applications.
 
32
 
33
  We have open-sourced the base models, hybrid reasoning models, and FP8 versions of the hybrid reasoning models for both GLM-4.5 and GLM-4.5-Air. They are released under the MIT open-source license and can be used commercially and for secondary development.
34
 
35
+ As demonstrated in our comprehensive evaluation across 12 industry-standard benchmarks, GLM-4.5 achieves exceptional performance with a score of **63.2**, in the **3rd** place among all the proprietary and open-source models. Notably, GLM-4.5-Air delivers competitive results at **59.8** while maintaining superior efficiency.
36
 
37
  ![bench](https://raw.githubusercontent.com/zai-org/GLM-4.5/refs/heads/main/resources/bench.png)
38
 
 
41
 
42
  The model code, tool parser and reasoning parser can be found in the implementation of [transformers](https://github.com/huggingface/transformers/tree/main/src/transformers/models/glm4_moe), [vLLM](https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/glm4_moe_mtp.py) and [SGLang](https://github.com/sgl-project/sglang/blob/main/python/sglang/srt/models/glm4_moe.py).
43
 
44
+ ## System Requirements
45
+
46
+ ### Inference
47
+
48
+ We provide minimum and recommended configurations for "full-featured" model inference. The data in the table below is
49
+ based on the following conditions:
50
+
51
+ 1. All models use MTP layers and specify
52
+ `--speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4` to ensure competitive
53
+ inference speed.
54
+ 2. The `cpu-offload` parameter is not used.
55
+ 3. Inference batch size does not exceed `8`.
56
+ 4. All are executed on devices that natively support FP8 inference, ensuring both weights and cache are in FP8 format.
57
+ 5. Server memory must exceed `1T` to ensure normal model loading and operation.
58
+
59
+ The models can run under the configurations in the table below:
60
+
61
+ | Model | Precision | GPU Type and Count | Test Framework |
62
+ |---|---|---|---|
63
+ | GLM-4.5 | BF16 | H100 x 16 / H200 x 8 | sglang |
64
+ | GLM-4.5 | FP8 | H100 x 8 / H200 x 4 | sglang |
65
+ | GLM-4.5-Air | BF16 | H100 x 4 / H200 x 2 | sglang |
66
+ | GLM-4.5-Air | FP8 | H100 x 2 / H200 x 1 | sglang |
67
+
68
+ Under the configurations in the table below, the models can utilize their full 128K context length:
69
+
70
+ | Model | Precision | GPU Type and Count | Test Framework |
71
+ |---|---|---|---|
72
+ | GLM-4.5 | BF16 | H100 x 32 / H200 x 16 | sglang |
73
+ | GLM-4.5 | FP8 | H100 x 16 / H200 x 8 | sglang |
74
+ | GLM-4.5-Air | BF16 | H100 x 8 / H200 x 4 | sglang |
75
+ | GLM-4.5-Air | FP8 | H100 x 4 / H200 x 2 | sglang |
76
+
77
+ ### Fine-tuning
78
+
79
+ The code can run under the configurations in the table below
80
+ using [Llama Factory](https://github.com/hiyouga/LLaMA-Factory):
81
+
82
+ | Model | GPU Type and Count | Strategy | Batch Size (per GPU) |
83
+ |---|---|---|---|
84
+ | GLM-4.5 | H100 x 16 | Lora | 1 |
85
+ | GLM-4.5-Air | H100 x 4 | Lora | 1 |
86
+
87
+ The code can run under the configurations in the table below using [Swift](https://github.com/modelscope/ms-swift):
88
+
89
+ | Model | GPU Type and Count | Strategy | Batch Size (per GPU) |
90
+ |---|---|---|---|
91
+ | GLM-4.5 | H20 (96GiB) x 16 | Lora | 1 |
92
+ | GLM-4.5-Air | H20 (96GiB) x 4 | Lora | 1 |
93
+ | GLM-4.5 | H20 (96GiB) x 128 | SFT | 1 |
94
+ | GLM-4.5-Air | H20 (96GiB) x 32 | SFT | 1 |
95
+ | GLM-4.5 | H20 (96GiB) x 128 | RL | 1 |
96
+ | GLM-4.5-Air | H20 (96GiB) x 32 | RL | 1 |
97
+
98
  ## Quick Start
99
 
100
  **Note**: This is a base model, not for chat.
101
 
102
+ Please install the required packages according to `requirements.txt`.
103
+
104
+ ```bash
105
+ pip install -r requirements.txt
106
+ ```
107
+
108
+ ### transformers
109
+
110
+ Here's a basic example to use the model with the `transformers` library for text generation:
111
+
112
+ ```python
113
+ from transformers import AutoTokenizer, AutoModelForCausalLM
114
+ import torch
115
+
116
+ model_id = "zai-org/GLM-4.5-Air-Base"
117
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
118
+ # Ensure to load with the correct dtype, e.g., bfloat16 as specified in config.json
119
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16)
120
+
121
+ prompt = "Hello, I'm a language model,"
122
+ inputs = tokenizer(prompt, return_tensors="pt")
123
+
124
+ # Generate
125
+ generate_ids = model.generate(inputs.input_ids, max_new_tokens=100)
126
+ print(tokenizer.batch_decode(generate_ids, skip_special_tokens=True)[0])
127
+ ```
128
+
129
+ The GitHub repository provides more detailed examples, including `trans_infer_cli.py`.
130
+
131
+ ### vLLM
132
+
133
+ Both BF16 and FP8 can be started with the following code:
134
+
135
+ ```bash
136
+ vllm serve zai-org/GLM-4.5-Air \
137
+ --tensor-parallel-size 8 \
138
+ --tool-call-parser glm45 \
139
+ --reasoning-parser glm45 \
140
+ --enable-auto-tool-choice \
141
+ --served-model-name glm-4.5-air
142
+ ```
143
+
144
+ If you're using 8x H100 GPUs and encounter insufficient memory when running the GLM-4.5 model, you'll need
145
+ `--cpu-offload-gb 16` (only applicable to vLLM).
146
+
147
+ If you encounter `flash infer` issues, use `VLLM_ATTENTION_BACKEND=XFORMERS` as a temporary replacement. You can also
148
+ specify `TORCH_CUDA_ARCH_LIST='9.0+PTX'` to use `flash infer` (different GPUs have different TORCH_CUDA_ARCH_LIST
149
+ values, please check accordingly).
150
+
151
+ ### SGLang
152
+
153
+ + BF16
154
+
155
+ ```bash
156
+ python3 -m sglang.launch_server \
157
+ --model-path zai-org/GLM-4.5-Air \
158
+ --tp-size 8 \
159
+ --tool-call-parser glm45 \
160
+ --reasoning-parser glm45 \
161
+ --speculative-algorithm EAGLE \
162
+ --speculative-num-steps 3 \
163
+ --speculative-eagle-topk 1 \
164
+ --speculative-num-draft-tokens 4 \
165
+ --mem-fraction-static 0.7 \
166
+ --served-model-name glm-4.5-air \
167
+ --host 0.0.0.0 \
168
+ --port 8000
169
+ ```
170
+
171
+ + FP8
172
+
173
+ ```bash
174
+ python3 -m sglang.launch_server \
175
+ --model-path zai-org/GLM-4.5-Air-FP8 \
176
+ --tp-size 4 \
177
+ --tool-call-parser glm45 \
178
+ --reasoning-parser glm45 \
179
+ --speculative-algorithm EAGLE \
180
+ --speculative-num-steps 3 \
181
+ --speculative-eagle-topk 1 \
182
+ --speculative-num-draft-tokens 4 \
183
+ --mem-fraction-static 0.7 \
184
+ --disable-shared-experts-fusion \
185
+ --served-model-name glm-4.5-air-fp8 \
186
+ --host 0.0.0.0 \
187
+ --port 8000
188
+ ```
189
+
190
+ ### Request Parameter Instructions
191
+
192
+ + When using `vLLM` and `SGLang`, thinking mode is enabled by default when sending requests. If you want to disable the
193
+ thinking switch, you need to add the `extra_body={"chat_template_kwargs": {"enable_thinking": False}}` parameter.
194
+ + Both support tool calling. Please use OpenAI-style tool description format for calls.
195
+ + For specific code, please refer to `api_request.py` in the `inference` folder.