Image-Text-to-Text
Transformers
Safetensors
English
Chinese
glm5_next
conversational
Eval Results
fp8
Instructions to use zai-org/GLM-5.3-Flash with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/GLM-5.3-Flash with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="zai-org/GLM-5.3-Flash") 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, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("zai-org/GLM-5.3-Flash") model = AutoModelForMultimodalLM.from_pretrained("zai-org/GLM-5.3-Flash", device_map="auto") 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]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zai-org/GLM-5.3-Flash 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.3-Flash" # 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.3-Flash", "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-5.3-Flash
- SGLang
How to use zai-org/GLM-5.3-Flash 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.3-Flash" \ --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.3-Flash", "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-5.3-Flash" \ --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.3-Flash", "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-5.3-Flash with Docker Model Runner:
docker model run hf.co/zai-org/GLM-5.3-Flash
chat template: early break in tool result reordering check
Browse filesFollowing the optimization in [this SGLang PR](https://github.com/sgl-project/sglang/pull/36957), added four `break` statements so the loop stops early once it detects that the results can't be reordered.
- chat_template.jinja +10 -6
chat_template.jinja
CHANGED
|
@@ -68,8 +68,8 @@ For each function call, output the function name and arguments within the follow
|
|
| 68 |
{{- emit_audio() -}}
|
| 69 |
{%- endif -%}
|
| 70 |
{%- endfor -%}
|
| 71 |
-
{%-
|
| 72 |
-
{{- content }}
|
| 73 |
{%- endif -%}
|
| 74 |
{%- endmacro -%}
|
| 75 |
{%- macro tool_response(text) -%}
|
|
@@ -159,7 +159,7 @@ For each function call, output the function name and arguments within the follow
|
|
| 159 |
{%- if tc.function %}
|
| 160 |
{%- set tc = tc.function %}
|
| 161 |
{%- endif %}
|
| 162 |
-
{{- '<tool_call>'
|
| 163 |
{% set _args = tc.arguments %}{% for k, v in _args.items() %}<arg_key>{{ k }}</arg_key><arg_value>{{ v | tojson(ensure_ascii=False) if v is not string else v }}</arg_value>{% endfor %}</tool_call>{% endfor %}
|
| 164 |
{% endif %}
|
| 165 |
{%- elif m.role == 'tool' -%}
|
|
@@ -183,9 +183,11 @@ For each function call, output the function name and arguments within the follow
|
|
| 183 |
{%- set ns_chk.can_sort = false -%}
|
| 184 |
{%- else -%}
|
| 185 |
{%- for k in range(block_start, ns_blk.end + 1) -%}
|
|
|
|
| 186 |
{%- set m = messages[k] -%}
|
| 187 |
{%- if is_list_of_outputs(m) -%}
|
| 188 |
{%- for entry in m.content -%}
|
|
|
|
| 189 |
{%- set eid = id_of(entry) -%}
|
| 190 |
{%- if not eid -%}
|
| 191 |
{%- set ns_chk.can_sort = false -%}
|
|
@@ -207,6 +209,7 @@ For each function call, output the function name and arguments within the follow
|
|
| 207 |
{%- endif -%}
|
| 208 |
{%- endfor -%}
|
| 209 |
{%- for i in range(ns_a.tool_calls | length) -%}
|
|
|
|
| 210 |
{%- set tc_id = id_of(ns_a.tool_calls[i]) -%}
|
| 211 |
{%- if not tc_id -%}
|
| 212 |
{%- set ns_chk.can_sort = false -%}
|
|
@@ -214,9 +217,10 @@ For each function call, output the function name and arguments within the follow
|
|
| 214 |
{%- for j in range(i + 1, ns_a.tool_calls | length) -%}
|
| 215 |
{%- if id_of(ns_a.tool_calls[j]) == tc_id -%}
|
| 216 |
{%- set ns_chk.can_sort = false -%}
|
|
|
|
| 217 |
{%- endif -%}
|
| 218 |
{%- endfor -%}
|
| 219 |
-
|
| 220 |
{%- endif -%}
|
| 221 |
{%- if ns_chk.can_sort -%}
|
| 222 |
{%- for tc in ns_a.tool_calls -%}
|
|
@@ -233,8 +237,8 @@ For each function call, output the function name and arguments within the follow
|
|
| 233 |
{{- tool_response(visible_text(entry.output)) -}}
|
| 234 |
{%- endif -%}
|
| 235 |
{%- endif -%}
|
| 236 |
-
|
| 237 |
-
{%- else -%}
|
| 238 |
{%- set tk_id = id_of(m) -%}
|
| 239 |
{%- if tk_id == tc_id -%}
|
| 240 |
{{- render_tool_response(m) -}}
|
|
|
|
| 68 |
{{- emit_audio() -}}
|
| 69 |
{%- endif -%}
|
| 70 |
{%- endfor -%}
|
| 71 |
+
{%- elif content is not none -%}
|
| 72 |
+
{{- content -}}
|
| 73 |
{%- endif -%}
|
| 74 |
{%- endmacro -%}
|
| 75 |
{%- macro tool_response(text) -%}
|
|
|
|
| 159 |
{%- if tc.function %}
|
| 160 |
{%- set tc = tc.function %}
|
| 161 |
{%- endif %}
|
| 162 |
+
{{- '<tool_call>' ~ tc.name -}}
|
| 163 |
{% set _args = tc.arguments %}{% for k, v in _args.items() %}<arg_key>{{ k }}</arg_key><arg_value>{{ v | tojson(ensure_ascii=False) if v is not string else v }}</arg_value>{% endfor %}</tool_call>{% endfor %}
|
| 164 |
{% endif %}
|
| 165 |
{%- elif m.role == 'tool' -%}
|
|
|
|
| 183 |
{%- set ns_chk.can_sort = false -%}
|
| 184 |
{%- else -%}
|
| 185 |
{%- for k in range(block_start, ns_blk.end + 1) -%}
|
| 186 |
+
{%- if not ns_chk.can_sort -%}{%- break -%}{%- endif -%}
|
| 187 |
{%- set m = messages[k] -%}
|
| 188 |
{%- if is_list_of_outputs(m) -%}
|
| 189 |
{%- for entry in m.content -%}
|
| 190 |
+
{%- if not ns_chk.can_sort -%}{%- break -%}{%- endif -%}
|
| 191 |
{%- set eid = id_of(entry) -%}
|
| 192 |
{%- if not eid -%}
|
| 193 |
{%- set ns_chk.can_sort = false -%}
|
|
|
|
| 209 |
{%- endif -%}
|
| 210 |
{%- endfor -%}
|
| 211 |
{%- for i in range(ns_a.tool_calls | length) -%}
|
| 212 |
+
{%- if not ns_chk.can_sort -%}{%- break -%}{%- endif -%}
|
| 213 |
{%- set tc_id = id_of(ns_a.tool_calls[i]) -%}
|
| 214 |
{%- if not tc_id -%}
|
| 215 |
{%- set ns_chk.can_sort = false -%}
|
|
|
|
| 217 |
{%- for j in range(i + 1, ns_a.tool_calls | length) -%}
|
| 218 |
{%- if id_of(ns_a.tool_calls[j]) == tc_id -%}
|
| 219 |
{%- set ns_chk.can_sort = false -%}
|
| 220 |
+
{%- break -%}
|
| 221 |
{%- endif -%}
|
| 222 |
{%- endfor -%}
|
| 223 |
+
{%- endfor -%}
|
| 224 |
{%- endif -%}
|
| 225 |
{%- if ns_chk.can_sort -%}
|
| 226 |
{%- for tc in ns_a.tool_calls -%}
|
|
|
|
| 237 |
{{- tool_response(visible_text(entry.output)) -}}
|
| 238 |
{%- endif -%}
|
| 239 |
{%- endif -%}
|
| 240 |
+
{%- endfor -%}
|
| 241 |
+
{%- else -%}
|
| 242 |
{%- set tk_id = id_of(m) -%}
|
| 243 |
{%- if tk_id == tc_id -%}
|
| 244 |
{{- render_tool_response(m) -}}
|