Instructions to use zai-org/GLM-5.2-FP8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/GLM-5.2-FP8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="zai-org/GLM-5.2-FP8") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("zai-org/GLM-5.2-FP8") model = AutoModelForCausalLM.from_pretrained("zai-org/GLM-5.2-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=40) 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.2-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.2-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.2-FP8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/zai-org/GLM-5.2-FP8
- SGLang
How to use zai-org/GLM-5.2-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.2-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.2-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.2-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.2-FP8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use zai-org/GLM-5.2-FP8 with Docker Model Runner:
docker model run hf.co/zai-org/GLM-5.2-FP8
Add files using upload-large-folder tool
Browse files- chat_template.jinja +7 -0
chat_template.jinja
CHANGED
|
@@ -42,6 +42,9 @@ For each function call, output the function name and arguments within the follow
|
|
| 42 |
{{- item.text }}
|
| 43 |
{%- elif item is string -%}
|
| 44 |
{{- item }}
|
|
|
|
|
|
|
|
|
|
| 45 |
{%- endif -%}
|
| 46 |
{%- endfor -%}
|
| 47 |
{%- else -%}
|
|
@@ -100,6 +103,10 @@ For each function call, output the function name and arguments within the follow
|
|
| 100 |
{%- endfor -%}
|
| 101 |
{%- endfor -%}
|
| 102 |
{{- '</tools></tool_response>' -}}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
{%- else -%}
|
| 104 |
{{- '<tool_response>' + visible_text(m.content) + '</tool_response>' -}}
|
| 105 |
{% endif -%}
|
|
|
|
| 42 |
{{- item.text }}
|
| 43 |
{%- elif item is string -%}
|
| 44 |
{{- item }}
|
| 45 |
+
{%- elif item is mapping and item.type in ['image', 'image_url', 'video', 'video_url', 'audio', 'audio_url', 'input_audio'] -%}
|
| 46 |
+
{%- set media_type = item.type | replace('_url', '') | replace('input_', '') -%}
|
| 47 |
+
{{- "<reminder>You are unable to process this " ~ media_type ~ " because you don't have multi-modal input ability. Try different methods.</reminder>" }}
|
| 48 |
{%- endif -%}
|
| 49 |
{%- endfor -%}
|
| 50 |
{%- else -%}
|
|
|
|
| 103 |
{%- endfor -%}
|
| 104 |
{%- endfor -%}
|
| 105 |
{{- '</tools></tool_response>' -}}
|
| 106 |
+
{%- elif m.content is iterable and m.content is not mapping and m.content and m.content.0 is mapping and m.content.0.output is defined -%}
|
| 107 |
+
{%- for tr in m.content -%}
|
| 108 |
+
{{- '<tool_response>' + tr.output + '</tool_response>' -}}
|
| 109 |
+
{%- endfor -%}
|
| 110 |
{%- else -%}
|
| 111 |
{{- '<tool_response>' + visible_text(m.content) + '</tool_response>' -}}
|
| 112 |
{% endif -%}
|