Text Generation
Transformers
Safetensors
English
Chinese
glm_moe_dsa
conversational
Eval Results
fp8
Instructions to use zai-org/GLM-5.1-FP8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/GLM-5.1-FP8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="zai-org/GLM-5.1-FP8") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("zai-org/GLM-5.1-FP8") model = AutoModelForCausalLM.from_pretrained("zai-org/GLM-5.1-FP8", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zai-org/GLM-5.1-FP8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zai-org/GLM-5.1-FP8" # 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-5.1-FP8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/zai-org/GLM-5.1-FP8
- SGLang
How to use zai-org/GLM-5.1-FP8 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-5.1-FP8" \ --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-5.1-FP8", "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-5.1-FP8" \ --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-5.1-FP8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use zai-org/GLM-5.1-FP8 with Docker Model Runner:
docker model run hf.co/zai-org/GLM-5.1-FP8
Add a response template and fix tool calls with null content
#8
by Rocketknight1 HF Staff - opened
- chat_template.jinja +1 -1
- tokenizer_config.json +48 -1
chat_template.jinja
CHANGED
|
@@ -42,7 +42,7 @@ For each function call, output the function name and arguments within the follow
|
|
| 42 |
{{- item }}
|
| 43 |
{%- endif -%}
|
| 44 |
{%- endfor -%}
|
| 45 |
-
{%-
|
| 46 |
{{- content }}
|
| 47 |
{%- endif -%}
|
| 48 |
{%- endmacro -%}
|
|
|
|
| 42 |
{{- item }}
|
| 43 |
{%- endif -%}
|
| 44 |
{%- endfor -%}
|
| 45 |
+
{%- elif content is not none -%}
|
| 46 |
{{- content }}
|
| 47 |
{%- endif -%}
|
| 48 |
{%- endmacro -%}
|
tokenizer_config.json
CHANGED
|
@@ -29,5 +29,52 @@
|
|
| 29 |
"pad_token": "<|endoftext|>",
|
| 30 |
"padding_side": "left",
|
| 31 |
"remove_space": false,
|
| 32 |
-
"tokenizer_class": "TokenizersBackend"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
}
|
|
|
|
| 29 |
"pad_token": "<|endoftext|>",
|
| 30 |
"padding_side": "left",
|
| 31 |
"remove_space": false,
|
| 32 |
+
"tokenizer_class": "TokenizersBackend",
|
| 33 |
+
"response_template": {
|
| 34 |
+
"defaults": {
|
| 35 |
+
"role": "assistant"
|
| 36 |
+
},
|
| 37 |
+
"start_anchor": "<|assistant|>",
|
| 38 |
+
"fields": {
|
| 39 |
+
"reasoning_content": {
|
| 40 |
+
"open_pattern": "<think>|(?=</think>)",
|
| 41 |
+
"close_pattern": "</think>|(?=<tool_call>)",
|
| 42 |
+
"content": "text",
|
| 43 |
+
"content_args": {
|
| 44 |
+
"strip": true
|
| 45 |
+
},
|
| 46 |
+
"repeats": true,
|
| 47 |
+
"join": ""
|
| 48 |
+
},
|
| 49 |
+
"tool_calls": {
|
| 50 |
+
"open_pattern": "\\s*<tool_call>\\s*(?P<name>[^<]*?)\\s*(?=<arg_key>|</tool_call>)",
|
| 51 |
+
"close": "</tool_call>",
|
| 52 |
+
"repeats": true,
|
| 53 |
+
"content": "xml-inline",
|
| 54 |
+
"content_args": {
|
| 55 |
+
"tag_pattern": "<arg_key>\\s*(?P<key>.*?)\\s*</arg_key>\\s*<arg_value>(?P<value>.*?)</arg_value>"
|
| 56 |
+
},
|
| 57 |
+
"transform": {
|
| 58 |
+
"type": "function",
|
| 59 |
+
"function": {
|
| 60 |
+
"name": "{name}",
|
| 61 |
+
"arguments": "{content}"
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
},
|
| 65 |
+
"content": {
|
| 66 |
+
"close": [
|
| 67 |
+
"<|user|>",
|
| 68 |
+
"<|observation|>",
|
| 69 |
+
"<|endoftext|>"
|
| 70 |
+
],
|
| 71 |
+
"content": "text",
|
| 72 |
+
"content_args": {
|
| 73 |
+
"strip": false
|
| 74 |
+
},
|
| 75 |
+
"repeats": true,
|
| 76 |
+
"join": ""
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
}
|